mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
cmake: Fix odbc in unbudled
Signed-off-by: Konstantin Podshumok <kpp.live+signed@gmail.com>
This commit is contained in:
parent
8479da3033
commit
5097793872
@ -419,6 +419,7 @@ include (cmake/find/parquet.cmake)
|
||||
include (cmake/find/simdjson.cmake)
|
||||
include (cmake/find/rapidjson.cmake)
|
||||
include (cmake/find/fastops.cmake)
|
||||
include (cmake/find/odbc.cmake)
|
||||
|
||||
if(NOT USE_INTERNAL_PARQUET_LIBRARY)
|
||||
set (ENABLE_ORC OFF CACHE INTERNAL "")
|
||||
|
53
cmake/find/odbc.cmake
Normal file
53
cmake/find/odbc.cmake
Normal file
@ -0,0 +1,53 @@
|
||||
option (ENABLE_ODBC "Enable ODBC library" ${ENABLE_LIBRARIES})
|
||||
|
||||
if (NOT OS_LINUX)
|
||||
if (ENABLE_ODBC)
|
||||
message(STATUS "ODBC is only supported on Linux")
|
||||
endif()
|
||||
set (ENABLE_ODBC OFF CACHE INTERNAL "")
|
||||
endif ()
|
||||
|
||||
if (NOT ENABLE_ODBC)
|
||||
if (USE_INTERNAL_ODBC_LIBRARY)
|
||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't use internal ODBC with ENABLE_ODBC=OFF")
|
||||
endif()
|
||||
|
||||
add_library (unixodbc INTERFACE)
|
||||
target_compile_definitions (unixodbc INTERFACE USE_ODBC=0)
|
||||
|
||||
message (STATUS "Not using unixodbc")
|
||||
return()
|
||||
endif()
|
||||
|
||||
option (USE_INTERNAL_ODBC_LIBRARY "Use internal ODBC library" ${NOT_UNBUNDLED})
|
||||
|
||||
if (NOT USE_INTERNAL_ODBC_LIBRARY)
|
||||
find_library (LIBRARY_ODBC NAMES unixodbc odbc)
|
||||
find_path (INCLUDE_ODBC sql.h)
|
||||
|
||||
if(LIBRARY_ODBC AND INCLUDE_ODBC)
|
||||
add_library (unixodbc UNKNOWN IMPORTED)
|
||||
set_target_properties (unixodbc PROPERTIES IMPORTED_LOCATION ${LIBRARY_ODBC})
|
||||
set_target_properties (unixodbc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_ODBC})
|
||||
set_target_properties (unixodbc PROPERTIES INTERFACE_COMPILE_DEFINITIONS USE_ODBC=1)
|
||||
|
||||
if (USE_STATIC_LIBRARIES)
|
||||
find_library(LTDL_LIBRARY ltdl)
|
||||
if (LTDL_LIBRARY)
|
||||
target_link_libraries(unixodbc INTERFACE ${LTDL_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(EXTERNAL_ODBC_LIBRARY_FOUND 1)
|
||||
message (STATUS "Found odbc: ${LIBRARY_ODBC}")
|
||||
else()
|
||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system ODBC library")
|
||||
set(EXTERNAL_ODBC_LIBRARY_FOUND 0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT EXTERNAL_ODBC_LIBRARY_FOUND)
|
||||
set (USE_INTERNAL_ODBC_LIBRARY 1)
|
||||
endif ()
|
||||
|
||||
message (STATUS "Using unixodbc")
|
@ -1,4 +1,8 @@
|
||||
if (ENABLE_ODBC)
|
||||
if (NOT TARGET unixodbc)
|
||||
message(FATAL_ERROR "Configuration error: unixodbc is not a target")
|
||||
endif()
|
||||
|
||||
if (USE_INTERNAL_POCO_LIBRARY)
|
||||
set (SRCS
|
||||
${LIBRARY_DIR}/Data/ODBC/src/Binder.cpp
|
||||
|
@ -1,49 +1,12 @@
|
||||
option (ENABLE_ODBC "Enable ODBC library" ${ENABLE_LIBRARIES})
|
||||
|
||||
if (NOT OS_LINUX)
|
||||
if (ENABLE_ODBC)
|
||||
message(STATUS "ODBC is only supported on Linux")
|
||||
endif()
|
||||
set (ENABLE_ODBC OFF CACHE INTERNAL "")
|
||||
endif ()
|
||||
|
||||
if (NOT ENABLE_ODBC)
|
||||
if (USE_INTERNAL_ODBC_LIBRARY)
|
||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't use internal ODBC with ENABLE_ODBC=OFF")
|
||||
endif()
|
||||
|
||||
add_library (unixodbc INTERFACE)
|
||||
target_compile_definitions (unixodbc INTERFACE USE_ODBC=0)
|
||||
|
||||
message (STATUS "Not using unixodbc")
|
||||
if (NOT USE_INTERNAL_ODBC_LIBRARY)
|
||||
return()
|
||||
endif()
|
||||
|
||||
option (USE_INTERNAL_ODBC_LIBRARY "Use internal ODBC library" ${NOT_UNBUNDLED})
|
||||
set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/unixodbc)
|
||||
|
||||
if (NOT USE_INTERNAL_ODBC_LIBRARY)
|
||||
find_library (LIBRARY_ODBC unixodbc)
|
||||
find_path (INCLUDE_ODBC sql.h)
|
||||
# ltdl
|
||||
|
||||
if(LIBRARY_ODBC AND INCLUDE_ODBC)
|
||||
add_library (unixodbc UNKNOWN IMPORTED)
|
||||
set_target_properties (unixodbc PROPERTIES IMPORTED_LOCATION ${LIBRARY_ODBC})
|
||||
set_target_properties (unixodbc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_ODBC})
|
||||
set(EXTERNAL_ODBC_LIBRARY_FOUND 1)
|
||||
else()
|
||||
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system ODBC library")
|
||||
set(EXTERNAL_ODBC_LIBRARY_FOUND 0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT EXTERNAL_ODBC_LIBRARY_FOUND)
|
||||
set (USE_INTERNAL_ODBC_LIBRARY 1)
|
||||
|
||||
set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/unixodbc)
|
||||
|
||||
# ltdl
|
||||
|
||||
set (SRCS_LTDL
|
||||
set (SRCS_LTDL
|
||||
# This file is generated by 'libtool' inside libltdl directory and then removed.
|
||||
linux_x86_64/libltdl/libltdlcS.c
|
||||
|
||||
@ -55,23 +18,23 @@ if (NOT EXTERNAL_ODBC_LIBRARY_FOUND)
|
||||
${LIBRARY_DIR}/libltdl/lt_error.c
|
||||
${LIBRARY_DIR}/libltdl/loaders/dlopen.c
|
||||
${LIBRARY_DIR}/libltdl/loaders/preopen.c
|
||||
)
|
||||
)
|
||||
|
||||
add_library (ltdl ${SRCS_LTDL})
|
||||
add_library (ltdl ${SRCS_LTDL})
|
||||
|
||||
target_include_directories(ltdl
|
||||
target_include_directories(ltdl
|
||||
PRIVATE
|
||||
linux_x86_64/libltdl
|
||||
PUBLIC
|
||||
${LIBRARY_DIR}/libltdl
|
||||
${LIBRARY_DIR}/libltdl/libltdl
|
||||
)
|
||||
target_compile_definitions(ltdl PRIVATE -DHAVE_CONFIG_H -DLTDL -DLTDLOPEN=libltdlc)
|
||||
target_compile_options(ltdl PRIVATE -Wno-constant-logical-operand -Wno-unknown-warning-option -O2)
|
||||
)
|
||||
target_compile_definitions(ltdl PRIVATE -DHAVE_CONFIG_H -DLTDL -DLTDLOPEN=libltdlc)
|
||||
target_compile_options(ltdl PRIVATE -Wno-constant-logical-operand -Wno-unknown-warning-option -O2)
|
||||
|
||||
# odbc
|
||||
# odbc
|
||||
|
||||
set (SRCS
|
||||
set (SRCS
|
||||
${LIBRARY_DIR}/DriverManager/__attribute.c
|
||||
${LIBRARY_DIR}/DriverManager/__connection.c
|
||||
${LIBRARY_DIR}/DriverManager/__handles.c
|
||||
@ -304,23 +267,23 @@ if (NOT EXTERNAL_ODBC_LIBRARY_FOUND)
|
||||
${LIBRARY_DIR}/odbcinst/SQLWriteDSNToIni.c
|
||||
${LIBRARY_DIR}/odbcinst/SQLWriteFileDSN.c
|
||||
${LIBRARY_DIR}/odbcinst/SQLWritePrivateProfileString.c
|
||||
)
|
||||
)
|
||||
|
||||
add_library (unixodbc ${SRCS})
|
||||
add_library (unixodbc ${SRCS})
|
||||
|
||||
target_link_libraries (unixodbc PRIVATE ltdl)
|
||||
target_link_libraries (unixodbc PRIVATE ltdl)
|
||||
|
||||
# SYSTEM_FILE_PATH was changed to /etc
|
||||
# SYSTEM_FILE_PATH was changed to /etc
|
||||
|
||||
target_include_directories (unixodbc
|
||||
target_include_directories (unixodbc
|
||||
PRIVATE
|
||||
linux_x86_64/private
|
||||
PUBLIC
|
||||
linux_x86_64
|
||||
${LIBRARY_DIR}/include
|
||||
)
|
||||
target_compile_definitions (unixodbc PRIVATE -DHAVE_CONFIG_H)
|
||||
target_compile_options (unixodbc
|
||||
)
|
||||
target_compile_definitions (unixodbc PRIVATE -DHAVE_CONFIG_H)
|
||||
target_compile_options (unixodbc
|
||||
PRIVATE
|
||||
-Wno-dangling-else
|
||||
-Wno-parentheses
|
||||
@ -328,9 +291,5 @@ if (NOT EXTERNAL_ODBC_LIBRARY_FOUND)
|
||||
-Wno-unknown-warning-option
|
||||
-Wno-reserved-id-macro
|
||||
-O2
|
||||
)
|
||||
endif ()
|
||||
|
||||
)
|
||||
target_compile_definitions (unixodbc INTERFACE USE_ODBC=1)
|
||||
|
||||
message (STATUS "Using unixodbc")
|
||||
|
Loading…
Reference in New Issue
Block a user