author | František Kučera <franta-hg@frantovo.cz> |
Fri, 05 Jun 2020 18:26:27 +0200 | |
branch | v_0 |
changeset 49 | 1d17192565bf |
parent 34 | 24c05e69d68f |
permissions | -rw-r--r-- |
34
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
# file Copyright.txt or https://cmake.org/licensing for details. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
#[=======================================================================[.rst: |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
FindODBC |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
-------- |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
Find an Open Database Connectivity (ODBC) include directory and library. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
On Windows, when building with Visual Studio, this module assumes the ODBC |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
library is provided by the available Windows SDK. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
On Unix, this module allows to search for ODBC library provided by |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
unixODBC or iODBC implementations of ODBC API. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
This module reads hint about location of the config program: |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
.. variable:: ODBC_CONFIG |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
Location of odbc_config or iodbc-config program |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
Otherwise, this module tries to find the config program, |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
first from unixODBC, then from iODBC. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
If no config program found, this module searches for ODBC header |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
and library in list of known locations. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
Imported targets |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
^^^^^^^^^^^^^^^^ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
This module defines the following :prop_tgt:`IMPORTED` targets: |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
.. variable:: ODBC::ODBC |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
Imported target for using the ODBC library, if found. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
Result variables |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
^^^^^^^^^^^^^^^^ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
.. variable:: ODBC_FOUND |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
Set to true if ODBC library found, otherwise false or undefined. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
.. variable:: ODBC_INCLUDE_DIRS |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
Paths to include directories listed in one variable for use by ODBC client. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
May be empty on Windows, where the include directory corresponding to the |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
expected Windows SDK is already available in the compilation environment. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
.. variable:: ODBC_LIBRARIES |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
Paths to libraries to linked against to use ODBC. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
May just a library name on Windows, where the library directory corresponding |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
to the expected Windows SDK is already available in the compilation environment. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
.. variable:: ODBC_CONFIG |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
Path to unixODBC or iODBC config program, if found or specified. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
Cache variables |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
^^^^^^^^^^^^^^^ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
For users who wish to edit and control the module behavior, this module |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
reads hints about search locations from the following variables: |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
.. variable:: ODBC_INCLUDE_DIR |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
Path to ODBC include directory with ``sql.h`` header. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
.. variable:: ODBC_LIBRARY |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
Path to ODBC library to be linked. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
These variables should not be used directly by project code. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
Limitations |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
^^^^^^^^^^^ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
On Windows, this module does not search for iODBC. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
On Unix, there is no way to prefer unixODBC over iODBC, or vice versa, |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
other than providing the config program location using the ``ODBC_CONFIG``. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
This module does not allow to search for a specific ODBC driver. |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
#]=======================================================================] |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
# Define lists used internally |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
set(_odbc_include_paths) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
set(_odbc_lib_paths) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
set(_odbc_lib_names) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
set(_odbc_required_libs_names) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
### Try Windows Kits ########################################################## |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
91 |
if(WIN32) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
# List names of ODBC libraries on Windows |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
if(NOT MINGW) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
set(ODBC_LIBRARY odbc32.lib) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
else() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
set(ODBC_LIBRARY libodbc32.a) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
set(_odbc_lib_names odbc32;) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
100 |
# List additional libraries required to use ODBC library |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
101 |
if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
set(_odbc_required_libs_names odbccp32;ws2_32) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
elseif(MINGW) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
set(_odbc_required_libs_names odbccp32) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
108 |
### Try unixODBC or iODBC config program ###################################### |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
if (UNIX) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
find_program(ODBC_CONFIG |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
111 |
NAMES odbc_config iodbc-config |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
112 |
DOC "Path to unixODBC or iODBC config program") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
mark_as_advanced(ODBC_CONFIG) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
if (UNIX AND ODBC_CONFIG) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
# unixODBC and iODBC accept unified command line options |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
execute_process(COMMAND ${ODBC_CONFIG} --cflags |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
execute_process(COMMAND ${ODBC_CONFIG} --libs |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
121 |
OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
122 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
123 |
# Collect paths of include directories from CFLAGS |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
124 |
separate_arguments(_cflags NATIVE_COMMAND "${_cflags}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
125 |
foreach(arg IN LISTS _cflags) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
126 |
if("${arg}" MATCHES "^-I(.*)$") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
list(APPEND _odbc_include_paths "${CMAKE_MATCH_1}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
129 |
endforeach() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
130 |
unset(_cflags) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
131 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
132 |
# Collect paths of library names and directories from LIBS |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
133 |
separate_arguments(_libs NATIVE_COMMAND "${_libs}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
134 |
foreach(arg IN LISTS _libs) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
135 |
if("${arg}" MATCHES "^-L(.*)$") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
136 |
list(APPEND _odbc_lib_paths "${CMAKE_MATCH_1}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
137 |
elseif("${arg}" MATCHES "^-l(.*)$") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
set(_lib_name ${CMAKE_MATCH_1}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
string(REGEX MATCH "odbc" _is_odbc ${_lib_name}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
140 |
if(_is_odbc) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
141 |
list(APPEND _odbc_lib_names ${_lib_name}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
142 |
else() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
143 |
list(APPEND _odbc_required_libs_names ${_lib_name}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
144 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
145 |
unset(_lib_name) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
146 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
147 |
endforeach() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
148 |
unset(_libs) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
149 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
150 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
151 |
### Try unixODBC or iODBC in include/lib filesystems ########################## |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
152 |
if (UNIX AND NOT ODBC_CONFIG) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
153 |
# List names of both ODBC libraries, unixODBC and iODBC |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
154 |
set(_odbc_lib_names odbc;iodbc;unixodbc;) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
155 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
156 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
157 |
### Find include directories ################################################## |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
158 |
find_path(ODBC_INCLUDE_DIR |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
159 |
NAMES sql.h |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
160 |
PATHS ${_odbc_include_paths}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
161 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
162 |
if(NOT ODBC_INCLUDE_DIR AND WIN32) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
163 |
set(ODBC_INCLUDE_DIR "") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
164 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
165 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
166 |
### Find libraries ############################################################ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
167 |
if(NOT ODBC_LIBRARY) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
168 |
find_library(ODBC_LIBRARY |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
169 |
NAMES ${_odbc_lib_names} |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
170 |
PATHS ${_odbc_lib_paths} |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
171 |
PATH_SUFFIXES odbc) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
172 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
173 |
foreach(_lib IN LISTS _odbc_required_libs_names) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
174 |
find_library(_lib_path |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
175 |
NAMES ${_lib} |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
176 |
PATHS ${_odbc_lib_paths} # system parths or collected from ODBC_CONFIG |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
177 |
PATH_SUFFIXES odbc) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
178 |
if(_lib_path) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
179 |
list(APPEND _odbc_required_libs_paths ${_lib_path}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
180 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
181 |
unset(_lib_path CACHE) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
182 |
endforeach() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
183 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
184 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
185 |
# Unset internal lists as no longer used |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
186 |
unset(_odbc_include_paths) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
187 |
unset(_odbc_lib_paths) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
188 |
unset(_odbc_lib_names) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
189 |
unset(_odbc_required_libs_names) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
190 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
191 |
### Set result variables ###################################################### |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
192 |
set(_odbc_required_vars ODBC_LIBRARY) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
193 |
if(NOT WIN32) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
194 |
list(APPEND _odbc_required_vars ODBC_INCLUDE_DIR) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
195 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
196 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
197 |
include(FindPackageHandleStandardArgs) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
198 |
find_package_handle_standard_args(ODBC DEFAULT_MSG ${_odbc_required_vars}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
199 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
200 |
unset(_odbc_required_vars) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
201 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
202 |
mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
203 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
204 |
set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
205 |
list(APPEND ODBC_LIBRARIES ${ODBC_LIBRARY}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
206 |
list(APPEND ODBC_LIBRARIES ${_odbc_required_libs_paths}) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
207 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
208 |
### Import targets ############################################################ |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
209 |
if(ODBC_FOUND) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
210 |
if(NOT TARGET ODBC::ODBC) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
211 |
if(IS_ABSOLUTE "${ODBC_LIBRARY}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
212 |
add_library(ODBC::ODBC UNKNOWN IMPORTED) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
213 |
set_target_properties(ODBC::ODBC PROPERTIES |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
214 |
IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
215 |
IMPORTED_LOCATION "${ODBC_LIBRARY}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
216 |
else() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
217 |
add_library(ODBC::ODBC INTERFACE IMPORTED) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
218 |
set_target_properties(ODBC::ODBC PROPERTIES |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
219 |
IMPORTED_LIBNAME "${ODBC_LIBRARY}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
220 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
221 |
set_target_properties(ODBC::ODBC PROPERTIES |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
222 |
INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
223 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
224 |
if(_odbc_required_libs_paths) |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
225 |
set_property(TARGET ODBC::ODBC APPEND PROPERTY |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
226 |
INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}") |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
227 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
228 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
229 |
endif() |
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
230 |
|
24c05e69d68f
add ODBC library and --list-data-sources mode (DSN)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
231 |
unset(_odbc_required_libs_paths) |