Skip to content

Commit

Permalink
BI-1762, BI-1791: Supplemental commit to aid building of ODBC
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Evans committed Sep 5, 2018
1 parent aaf20b8 commit 93abdf8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
30 changes: 21 additions & 9 deletions driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ SET(DRIVER_LOCATION2 "")
SET(CONNECTOR_DRIVER_TYPE2 "")
SET(CONNECTOR_DRIVER_TYPE_SHORT2 "")

# The order here is significant and specific to linking static ICU.
# Work must be done to ensure a dynamic build works.
find_package(ICU REQUIRED COMPONENTS uc i18n data)
if (ICU_FOUND)
message (STATUS "ICU was found, version is ${ICU_VERSION}")
message (STATUS "Using ICU libraries from: ${ICU_LIBRARIES} with include dirs: ${ICU_INCLUDE_DIR}")
set (MONGOC_ENABLE_ICU 1)
include_directories ("${ICU_INCLUDE_DIR}")
elseif (ENABLE_ICU STREQUAL ON)
message (FATAL_ERROR "No ICU library found. If ICU is installed in a non-standard directory, define ICU_ROOT as the ICU installation path.")
endif()

WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})

LIST(GET IS_UNICODE_DRIVER ${DRIVER_INDEX} UNICODE)
Expand Down Expand Up @@ -80,13 +92,13 @@ WHILE(${DRIVER_INDEX} LESS ${DRIVERS_COUNT})

INSTALL(TARGETS ${DRIVER_NAME} DESTINATION ${LIB_SUBDIR})

IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET_TARGET_PROPERTIES(${DRIVER_NAME} PROPERTIES
LINK_FLAGS "${MYSQLODBCCONN_LINK_FLAGS_ENV} ${MYSQL_LINK_FLAGS}")
ELSE(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET_TARGET_PROPERTIES(${DRIVER_NAME} PROPERTIES
LINK_FLAGS "${MYSQLODBCCONN_LINK_FLAGS_ENV} ${MYSQL_LINK_FLAGS}") # -flto
ENDIF()
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET_TARGET_PROPERTIES(${DRIVER_NAME} PROPERTIES
LINK_FLAGS "${MYSQLODBCCONN_LINK_FLAGS_ENV} ${MYSQL_LINK_FLAGS}")
ELSE(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET_TARGET_PROPERTIES(${DRIVER_NAME} PROPERTIES
LINK_FLAGS "${MYSQLODBCCONN_LINK_FLAGS_ENV} ${MYSQL_LINK_FLAGS}") # -flto
ENDIF()

IF(UNICODE)
SET_TARGET_PROPERTIES(${DRIVER_NAME} PROPERTIES
Expand All @@ -111,7 +123,7 @@ ENDIF()

TARGET_LINK_LIBRARIES(${DRIVER_NAME} myodbc-util
${MYSQL_CLIENT_LIBS} ws2_32 ${ODBCINSTLIB} ${SECURE32_LIB}
${MONGO_KRB_LIBS} ${MONGO_CRYPTO_LIBS})
${MONGO_KRB_LIBS} ${MONGO_CRYPTO_LIBS} ${ICU_LIBRARIES})
ELSE(WIN32)

IF(DEV_STUDIO_RUNTIME_DIR)
Expand All @@ -123,7 +135,7 @@ ENDIF()
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ODBC_DRIVER_LINK_FLAGS}")
TARGET_LINK_LIBRARIES(${DRIVER_NAME}
${MYSQL_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT} m)
TARGET_LINK_LIBRARIES(${DRIVER_NAME} myodbc-util ${MONGO_KRB_LIBS} ${MONGO_CRYPTO_LIBS})
TARGET_LINK_LIBRARIES(${DRIVER_NAME} myodbc-util ${MONGO_KRB_LIBS} ${MONGO_CRYPTO_LIBS} ${ICU_LIBRARIES})
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
TARGET_LINK_LIBRARIES(${DRIVER_NAME} stdc++)
ENDIF()
Expand Down
10 changes: 9 additions & 1 deletion mongodb-odbc-driver/bin/build-mongo-odbc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@
UNIX_LIB="-DODBC_INCLUDES=$BUILD_DIR/install/include -DODBC_LIB_DIR=$BUILD_DIR/install/lib -DWITH_UNIXODBC=1"
fi

# Set locations for ICU
ICU_DIR="$MYSQL_PROJECT_DIR/bld/artifacts/icu"
ICU_SRC_DIR="$ICU_DIR/icu/source"
ICU_BUILD_DIR="$ICU_DIR/build"
ENABLE_ICU='ON'
CMAKE_ICU_ARGS="-DENABLE_ICU=$ENABLE_ICU -DICU_ROOT=$ICU_BUILD_DIR -DICU_INCLUDE_DIR=$ICU_SRC_DIR/common"
CMAKE_ARGS="$CMAKE_ARGS $CMAKE_ICU_ARGS"

# run CMake in the BUILD_DIR
cmake "$BUILD_SRC_DIR" -G "$CMAKE_GENERATOR" -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE -DCMAKE_MODULE_PATH="$CMAKE_MODULE_PATH" $UNIX_LIB
cmake "$BUILD_SRC_DIR" -G "$CMAKE_GENERATOR" -DMYSQLCLIENT_STATIC_LINKING:BOOL=TRUE -DCMAKE_MODULE_PATH="$CMAKE_MODULE_PATH" $UNIX_LIB $CMAKE_ARGS

echo 'building'
# build the ODBC driver
Expand Down
2 changes: 1 addition & 1 deletion mongodb-odbc-driver/libmongosql

0 comments on commit 93abdf8

Please sign in to comment.