From 6df9f812e9989dab7a7d5b58d9a68ebd651e0bf2 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 27 May 2022 17:44:21 +0800 Subject: [PATCH] chore: make odbc cmake file compatible with lower version cmake (#13086) * chore: make odbc cmake file compatible with lower version cmake [TD-16059] * chore: check cmake version --- src/connector/odbc/CMakeLists.txt | 2 +- src/connector/odbc/examples/c/CMakeLists.txt | 6 +++++- src/connector/odbc/src/CMakeLists.txt | 6 +++++- src/connector/odbc/tools/CMakeLists.txt | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/connector/odbc/CMakeLists.txt b/src/connector/odbc/CMakeLists.txt index 5e8095c7dd..3f0439dd96 100644 --- a/src/connector/odbc/CMakeLists.txt +++ b/src/connector/odbc/CMakeLists.txt @@ -58,7 +58,7 @@ macro(check_odbc_requirement) check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV) IF (NOT HAVE_ODBC_DEV) - message(WARNING "odbc requirement not satisfied, check detail in ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log") + message(WARNING "odbc requirement not satisfied, please install unixodbc-dev. Check detail in ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log") return () ENDIF () diff --git a/src/connector/odbc/examples/c/CMakeLists.txt b/src/connector/odbc/examples/c/CMakeLists.txt index 4298549655..999f0d19f7 100644 --- a/src/connector/odbc/examples/c/CMakeLists.txt +++ b/src/connector/odbc/examples/c/CMakeLists.txt @@ -4,7 +4,11 @@ ADD_EXECUTABLE(tcodbc main.c ../../src/todbc_log.c) IF (TD_LINUX OR TD_DARWIN) target_include_directories(tcodbc PRIVATE ${ODBC_INCLUDE_DIRECTORY}) - target_link_directories(tcodbc PUBLIC ${ODBC_LIBRARY_DIRECTORY}) + IF (CMAKE_VERSION VERSION_LESS 3.13) + link_directories(AFTER ${ODBC_LIBRARY_DIRECTORY}) + ELSE () + target_link_directories(tcodbc PUBLIC ${ODBC_LIBRARY_DIRECTORY}) + ENDIF () TARGET_LINK_LIBRARIES(tcodbc taos odbc) ENDIF () diff --git a/src/connector/odbc/src/CMakeLists.txt b/src/connector/odbc/src/CMakeLists.txt index f0df94795a..a616c7df48 100644 --- a/src/connector/odbc/src/CMakeLists.txt +++ b/src/connector/odbc/src/CMakeLists.txt @@ -19,7 +19,11 @@ IF (TD_LINUX_64) SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) TARGET_LINK_LIBRARIES(todbc todbc_base taos odbcinst) target_include_directories(todbc PRIVATE . ${ODBC_INCLUDE_DIRECTORY}) - target_link_directories(todbc PUBLIC ${ODBC_LIBRARY_DIRECTORY}) + IF (CMAKE_VERSION VERSION_LESS 3.13) + link_directories(AFTER ${ODBC_LIBRARY_DIRECTORY}) + ELSE () + target_link_directories(todbc PUBLIC ${ODBC_LIBRARY_DIRECTORY}) + ENDIF () install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install.sh ${CMAKE_BINARY_DIR})") ENDIF () diff --git a/src/connector/odbc/tools/CMakeLists.txt b/src/connector/odbc/tools/CMakeLists.txt index d49d334ef5..790620dd1d 100644 --- a/src/connector/odbc/tools/CMakeLists.txt +++ b/src/connector/odbc/tools/CMakeLists.txt @@ -5,7 +5,11 @@ ADD_EXECUTABLE(tconv tconv.c) IF (TD_LINUX OR TD_DARWIN) target_include_directories(todbcinst PRIVATE . ${ODBC_INCLUDE_DIRECTORY} ${ODBCINST_INCLUDE_DIRECTORY}) - target_link_directories(todbcinst PUBLIC ${ODBC_LIBRARY_DIRECTORY} ${ODBCINST_LIBRARY_DIRECTORY}) + IF (CMAKE_VERSION VERSION_LESS 3.13) + link_directories(AFTER ${ODBC_LIBRARY_DIRECTORY}) + ELSE () + target_link_directories(todbcinst PUBLIC ${ODBC_LIBRARY_DIRECTORY} ${ODBCINST_LIBRARY_DIRECTORY}) + ENDIF () TARGET_LINK_LIBRARIES(todbcinst odbc odbcinst) ENDIF () -- GitLab