@@ -33,26 +33,55 @@ PROJECT(MySQL_CONCPP_TEST)
33
33
#
34
34
# Settings using by this project:
35
35
#
36
- # WITH_CONCPP (required) location of Connector/C++ 8.0 installation
36
+ # WITH_CONCPP location of Connector/C++ 8.0 installation
37
+ # CONCPP_INCLUDE_DIR location of Connector/C++ 8.0 headers
38
+ # CONCPP_LIB_DIR location of Connector/C++ 8.0 libraries
39
+ #
37
40
# BUILD_STATIC whether to link with connector statically
38
41
# or dynamically (the default)
39
- # WITH_BOOST (optional) where to look for Boost (required only when building
42
+ # WITH_BOOST where to look for Boost (required only when building
40
43
# JDBC API application)
41
44
#
42
45
# WITH_JDBC build JDBC API test application
43
46
#
47
+ # Note: Either WITH_CONCPP or CONCPP_INCLUDE_DIR and CONCPP_LIB_DIR must be
48
+ # set.
49
+ #
50
+
51
+
52
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
53
+ set (IS64BIT 1 )
54
+ message ("Generating 64bit code" )
55
+ else ()
56
+ message ("Generating 32bit code" )
57
+ endif ()
44
58
45
- option (WITH_JDBC "Also build the JDBC API test application" OFF )
46
59
47
60
set (WITH_CONCPP $ENV{WITH_CONCPP} CACHE PATH "MySQL Connector/C++ 8.0 install location" )
48
61
49
- if (NOT WITH_CONCPP )
62
+ if (WITH_CONCPP )
63
+ if (NOT DEFINED CONCPP_INCLUDE_DIR )
64
+ set (CONCPP_INCLUDE_DIR "${WITH_CONCPP} /include" )
65
+ endif ()
66
+ if (NOT DEFINED CONCPP_LIB_DIR )
67
+ if (IS64BIT )
68
+ set (CONCPP_LIB_DIR "${WITH_CONCPP} /lib64" )
69
+ else ()
70
+ set (CONCPP_LIB_DIR "${WITH_CONCPP} /lib" )
71
+ endif ()
72
+ endif ()
73
+ endif ()
74
+
75
+ if (NOT DEFINED CONCPP_INCLUDE_DIR OR NOT DEFINED CONCPP_LIB_DIR )
50
76
message (FATAL_ERROR
51
77
"This project requires MySQL Connector/C++ 8.0, please specify install location"
52
- " using WITH_CONCPP setting"
78
+ " using WITH_CONCPP setting or set header/library paths with CONCPP_INCLUDE_DIR"
79
+ " and CONCPP_LIB_DIR settings."
53
80
)
54
81
endif ()
55
82
83
+ option (WITH_JDBC "Also build the JDBC API test application" OFF )
84
+
56
85
option (BUILD_STATIC "Link statically with the connector library" OFF )
57
86
58
87
if (BUILD_STATIC )
@@ -85,13 +114,6 @@ if(NOT DEFINED WITH_SSL)
85
114
endif ()
86
115
87
116
88
- if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
89
- set (IS64BIT 1 )
90
- message ("Generating 64bit code" )
91
- else ()
92
- message ("Generating 32bit code" )
93
- endif ()
94
-
95
117
if (WIN32 )
96
118
set (VS "vs14" )
97
119
endif ()
@@ -101,25 +123,18 @@ endif()
101
123
# Find MySQL Connector/C++ at specified location.
102
124
#
103
125
104
- set (CONCPP_INCLUDES "${WITH_CONCPP} /include" )
105
126
106
- if (NOT EXISTS "${CONCPP_INCLUDES } /mysqlx/xdevapi.h" )
127
+ if (NOT EXISTS "${CONCPP_INCLUDE_DIR } /mysqlx/xdevapi.h" )
107
128
message (FATAL_ERROR
108
129
"Could not find MySQL Connector/C++ 8.0 headers at specified"
109
- " location: ${CONCPP_INCLUDES } "
130
+ " location: ${CONCPP_INCLUDE_DIR } "
110
131
)
111
132
endif ()
112
133
113
134
114
- if (IS64BIT )
115
- set (LIB_PATH "${WITH_CONCPP} /lib64" )
116
- else ()
117
- set (LIB_PATH "${WITH_CONCPP} /lib" )
118
- endif ()
119
-
120
- set (LIB_PATH_STATIC "${LIB_PATH} " )
135
+ set (CONCPP_STATIC_LIB_DIR "${CONCPP_LIB_DIR} " )
121
136
if (VS )
122
- set (LIB_PATH_STATIC "${LIB_PATH_STATIC } /${VS} " )
137
+ set (CONCPP_STATIC_LIB_DIR "${CONCPP_STATIC_LIB_DIR } /${VS} " )
123
138
endif ()
124
139
125
140
#
@@ -147,24 +162,24 @@ endif()
147
162
endforeach ()
148
163
149
164
150
- message ("Looking for connector libraries here: ${LIB_PATH_STATIC } " )
165
+ message ("Looking for connector libraries here: ${CONCPP_STATIC_LIB_DIR } " )
151
166
152
167
message ("Looking for the main library ${libconcpp_name} " )
153
168
154
169
find_library (CONCPP_LIB NAMES ${libconcpp_name}
155
- PATHS "${LIB_PATH_STATIC } "
170
+ PATHS "${CONCPP_STATIC_LIB_DIR } "
156
171
NO_DEFAULT_PATH
157
172
)
158
173
159
174
find_library (CONCPP_LIB_DEBUG NAMES ${libconcpp_name}
160
- PATHS "${LIB_PATH_STATIC } /debug"
175
+ PATHS "${CONCPP_STATIC_LIB_DIR } /debug"
161
176
NO_DEFAULT_PATH
162
177
)
163
178
164
179
if (NOT CONCPP_LIB AND NOT CONCPP_LIB_DEBUG )
165
180
message (FATAL_ERROR
166
181
"Could not find MySQL Connector/C++ 8.0 library ${libconcpp_name} at specified"
167
- " location: ${LIB_PATH_STATIC } "
182
+ " location: ${CONCPP_STATIC_LIB_DIR } "
168
183
)
169
184
endif ()
170
185
@@ -196,12 +211,12 @@ message("Using Connector/C++ 8.0 libraries: ${CONCPP_LIBS}")
196
211
message ("Looking for the legacy library ${libconcpp_jdbc_name} " )
197
212
198
213
find_library (CONCPP_JDBC NAMES ${libconcpp_jdbc_name}
199
- PATHS "${LIB_PATH_STATIC } "
214
+ PATHS "${CONCPP_STATIC_LIB_DIR } "
200
215
NO_DEFAULT_PATH
201
216
)
202
217
203
218
find_library (CONCPP_JDBC_DEBUG NAMES ${libconcpp_jdbc_name}
204
- PATHS "${LIB_PATH_STATIC } /debug"
219
+ PATHS "${CONCPP_STATIC_LIB_DIR } /debug"
205
220
NO_DEFAULT_PATH
206
221
)
207
222
@@ -210,7 +225,7 @@ if(CONCPP_JDBC OR CONCPP_JDBC_DEBUG)
210
225
elseif (WITH_JDBC )
211
226
message (FATAL_ERROR
212
227
"Could not find MySQL Connector/C++ 8.0 legacy library"
213
- " ${libconcpp_jdbc_name} at specified location ${LIB_PATH_STATIC } "
228
+ " ${libconcpp_jdbc_name} at specified location ${CONCPP_STATIC_LIB_DIR } "
214
229
)
215
230
endif ()
216
231
@@ -375,14 +390,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG run/debug)
375
390
# Test programs that use MySQL Connector/C++.
376
391
#
377
392
378
- include_directories (${CONCPP_INCLUDES } )
393
+ include_directories (${CONCPP_INCLUDE_DIR } )
379
394
380
395
#
381
396
# Note: Adding this so that bundled libraries such as openSSL can be found
382
397
# at link time in case they are not installed on the system.
383
398
#
384
399
385
- link_directories (${LIB_PATH_STATIC } )
400
+ link_directories (${CONCPP_STATIC_LIB_DIR } )
386
401
387
402
388
403
add_executable (xapi_test xapi_test.c )
@@ -433,7 +448,7 @@ endif()
433
448
434
449
message ("Installing shared library dependencies." )
435
450
436
- file (GLOB libs "${LIB_PATH } /*${CMAKE_SHARED_LIBRARY_SUFFIX} *" )
451
+ file (GLOB libs "${CONCPP_LIB_DIR } /*${CMAKE_SHARED_LIBRARY_SUFFIX} *" )
437
452
file (INSTALL ${libs} DESTINATION run )
438
453
439
454
#
@@ -450,7 +465,7 @@ endif()
450
465
# Overwrite libs in run/debug with debug versions if present.
451
466
#
452
467
453
- file (GLOB debug_libs "${LIB_PATH } /debug/*${CMAKE_SHARED_LIBRARY_SUFFIX} *" )
468
+ file (GLOB debug_libs "${CONCPP_LIB_DIR } /debug/*${CMAKE_SHARED_LIBRARY_SUFFIX} *" )
454
469
file (INSTALL ${debug_libs} DESTINATION run/debug )
455
470
456
471
#
@@ -459,6 +474,6 @@ file(INSTALL ${debug_libs} DESTINATION run/debug)
459
474
#
460
475
461
476
if (NOT WIN32 AND NOT libs )
462
- file (INSTALL ${debug_libs} DESTINATAION run )
477
+ file (INSTALL ${debug_libs} DESTINATION run )
463
478
endif ()
464
479
0 commit comments