@@ -60,7 +60,7 @@ if(EXT_ODBC AND EXT_PDO_ODBC AND NOT EXT_ODBC_TYPE STREQUAL EXT_PDO_ODBC_TYPE)
60
60
)
61
61
endif ()
62
62
63
- # Some ODBC drivers require setting ODBC_LIBRARY manually to find package .
63
+ # Some ODBC drivers require setting ODBC_LIBRARY manually to be found .
64
64
if (
65
65
EXT_ODBC
66
66
AND NOT EXT_ODBC_TYPE MATCHES "auto|unixODBC|iODBC"
@@ -120,12 +120,6 @@ target_sources(
120
120
121
121
target_compile_definitions (php_odbc PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE=1 )
122
122
123
- # TODO: Can this be fixed better?
124
- get_target_property (extension_type php_odbc TYPE )
125
- if (NOT extension_type MATCHES "^(MODULE|SHARED)_LIBRARY$" )
126
- target_link_libraries (php_odbc PRIVATE PHP::main )
127
- endif ()
128
-
129
123
if (NOT EXT_ODBC_TYPE STREQUAL "auto" )
130
124
set (ODBC_USE_DRIVER "${EXT_ODBC_TYPE} " )
131
125
endif ()
@@ -137,48 +131,65 @@ set_package_properties(
137
131
PURPOSE "Necessary to enable the odbc extension."
138
132
)
139
133
140
- if (ODBC_DRIVER AND EXT_ODBC_TYPE STREQUAL "auto" )
141
- set (EXT_ODBC_TYPE "${ODBC_DRIVER} " )
134
+ target_link_libraries (php_odbc PRIVATE ODBC::ODBC )
135
+
136
+ # Sanity checks.
137
+ if (EXT_ODBC_TYPE STREQUAL "ibm-db2" AND TARGET ODBC::ODBC )
138
+ cmake_push_check_state (RESET )
139
+ set (CMAKE_REQUIRED_LIBRARIES ODBC::ODBC )
140
+ check_include_file (sqlcli1.h HAVE_SQLCLI1_H )
141
+ check_library_exists (ODBC::ODBC "" SQLExecute HAVE_SQLEXECUTE )
142
+ cmake_pop_check_state ()
143
+ if (NOT HAVE_SQLCLI1_H )
144
+ message (FATAL_ERROR "Required <sqlcli1.h> header file not found" )
145
+ endif ()
146
+ if (NOT HAVE_SQLEXECUTE )
147
+ message (
148
+ FATAL_ERROR
149
+ "ODBC build test failed. SQLExecute not found. The DB2 environment "
150
+ "needs to be sourced. Run the command line:\n "
151
+ " . $IBM_DB2/db2profile"
152
+ )
153
+ endif ()
142
154
endif ()
143
155
144
- target_link_libraries (php_odbc PRIVATE ODBC::ODBC )
156
+ ################################################################################
157
+ # Set variables for main/build-defs.h and config.h file.
158
+ ################################################################################
159
+
160
+ # Set PHP_ODBC_TYPE for configuration header value.
161
+ if (ODBC_DRIVER STREQUAL "Windows" )
162
+ set (PHP_ODBC_TYPE "Win32" )
163
+ elseif (
164
+ (ODBC_DRIVER STREQUAL "iODBC" AND EXT_ODBC_TYPE STREQUAL "auto" )
165
+ OR EXT_ODBC_TYPE STREQUAL "iODBC"
166
+ )
167
+ # To match the native build system string:
168
+ set (PHP_ODBC_TYPE "iodbc" )
169
+ elseif (ODBC_DRIVER AND EXT_ODBC_TYPE STREQUAL "auto" )
170
+ set (PHP_ODBC_TYPE "${ODBC_DRIVER} " )
171
+ elseif (EXT_ODBC_TYPE STREQUAL "custom" )
172
+ # To match the native build system string:
173
+ set (PHP_ODBC_TYPE custom-odbc )
174
+ else ()
175
+ set (PHP_ODBC_TYPE "${EXT_ODBC_TYPE} " )
176
+ endif ()
145
177
146
- if (EXT_ODBC_TYPE STREQUAL "adabas" )
178
+ if (PHP_ODBC_TYPE STREQUAL "adabas" )
147
179
set (HAVE_ADABAS 1 )
148
- elseif (EXT_ODBC_TYPE STREQUAL "dbmaker" )
180
+ elseif (PHP_ODBC_TYPE STREQUAL "dbmaker" )
149
181
set (HAVE_DBMAKER 1 )
150
- elseif (EXT_ODBC_TYPE MATCHES "^(empress|empress-bcs)$" )
182
+ elseif (PHP_ODBC_TYPE MATCHES "^(empress|empress-bcs)$" )
151
183
set (HAVE_EMPRESS 1 )
152
- elseif (EXT_ODBC_TYPE STREQUAL "esoob" )
184
+ elseif (PHP_ODBC_TYPE STREQUAL "esoob" )
153
185
set (HAVE_ESOOB 1 )
154
- elseif (EXT_ODBC_TYPE STREQUAL "ibm-db2" )
155
- # Sanity check.
156
- if (TARGET ODBC::ODBC )
157
- cmake_push_check_state (RESET )
158
- set (CMAKE_REQUIRED_LIBRARIES ODBC::ODBC )
159
- check_include_file (sqlcli1.h HAVE_SQLCLI1_H )
160
- check_library_exists (ODBC::ODBC "" SQLExecute HAVE_SQLEXECUTE )
161
- cmake_pop_check_state ()
162
- if (NOT HAVE_SQLCLI1_H )
163
- message (FATAL_ERROR "Required <sqlcli1.h> header file not found" )
164
- endif ()
165
- if (NOT HAVE_SQLEXECUTE )
166
- message (
167
- FATAL_ERROR
168
- "ODBC build test failed. SQLExecute not found. The DB2 environment "
169
- "needs to be sourced. Run the command line:\n "
170
- " . $IBM_DB2/db2profile"
171
- )
172
- endif ()
173
- endif ()
186
+ elseif (PHP_ODBC_TYPE STREQUAL "ibm-db2" )
174
187
set (HAVE_IBMDB2 1 )
175
- elseif (EXT_ODBC_TYPE STREQUAL "iODBC " )
188
+ elseif (PHP_ODBC_TYPE STREQUAL "iodbc " )
176
189
set (HAVE_IODBC 1 )
177
- # To match the native build system string:
178
- set (EXT_ODBC_TYPE iodbc )
179
- elseif (EXT_ODBC_TYPE STREQUAL "sapdb" )
190
+ elseif (PHP_ODBC_TYPE STREQUAL "sapdb" )
180
191
set (HAVE_SAPDB 1 )
181
- elseif (EXT_ODBC_TYPE STREQUAL "solid" )
192
+ elseif (PHP_ODBC_TYPE STREQUAL "solid" )
182
193
# Set based on the Solid version:
183
194
if (ODBC_LIBRARY MATCHES "23\. (a|so)$" )
184
195
set (HAVE_SOLID 1 )
@@ -195,21 +206,16 @@ elseif(EXT_ODBC_TYPE STREQUAL "solid")
195
206
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
196
207
set (SS_FBX 1 )
197
208
endif ()
198
- elseif (EXT_ODBC_TYPE STREQUAL "unixODBC" )
209
+ elseif (PHP_ODBC_TYPE STREQUAL "unixODBC" )
199
210
set (HAVE_UNIXODBC 1 )
200
- elseif (EXT_ODBC_TYPE STREQUAL "custom" )
211
+ elseif (PHP_ODBC_TYPE STREQUAL "custom-odbc " )
201
212
set (HAVE_CODBC 1 )
202
- # To match the native build system string:
203
- set (EXT_ODBC_TYPE custom-odbc )
204
213
endif ()
205
214
206
215
if (NOT EXT_ODBC_TYPE MATCHES "^(dbmaker|solid)$" )
207
216
set (HAVE_SQLDATASOURCES 1 )
208
217
endif ()
209
218
210
- ################################################################################
211
- # Set ODBC_* variables for main/build-defs.h file.
212
- ################################################################################
213
219
if (TARGET ODBC::ODBC )
214
220
block (PROPAGATE PHP_ODBC_BUILD_DEFINITIONS_CODE )
215
221
get_target_property (definitions ODBC::ODBC INTERFACE_COMPILE_DEFINITIONS )
@@ -249,11 +255,10 @@ if(TARGET ODBC::ODBC)
249
255
set (PHP_ODBC_CFLAGS "${cflags} " CACHE INTERNAL "ODBC CFLAGS" )
250
256
set (PHP_ODBC_LFLAGS "${ldflags} " CACHE INTERNAL "ODBC linker flags" )
251
257
set (PHP_ODBC_LIBS "${libs} " CACHE INTERNAL "ODBC libraries" )
252
- set (PHP_ODBC_TYPE "${EXT_ODBC_TYPE } " CACHE INTERNAL "ODBC type" )
258
+ set (PHP_ODBC_TYPE "${PHP_ODBC_TYPE } " CACHE INTERNAL "ODBC type" )
253
259
254
260
if (
255
- NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
256
- AND NOT PHP_SOURCE_DIR
261
+ NOT ODBC_DRIVER STREQUAL "Windows"
257
262
AND NOT EXISTS ${PHP_SOURCE_DIR} /main/build-defs.h.in
258
263
)
259
264
set (
0 commit comments