mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-19 03:54:55 +08:00
183 lines
6.2 KiB
Diff
183 lines
6.2 KiB
Diff
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index c4cb920..eeb17ee 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -126,8 +126,8 @@ ENDIF()
|
||
|
# CPPFLAGS, CXXFLAGS and LDFLAGS from the environment
|
||
|
|
||
|
SET(FreeBSD11Up False)
|
||
|
-if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND
|
||
|
- ${CMAKE_SYSTEM_VERSION} GREATER "10")
|
||
|
+if ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" AND
|
||
|
+ "${CMAKE_SYSTEM_VERSION}" GREATER "10")
|
||
|
SET(FreeBSD11Up True)
|
||
|
endif()
|
||
|
|
||
|
@@ -490,10 +490,12 @@ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/driver/nativeapi)
|
||
|
ADD_SUBDIRECTORY(cppconn)
|
||
|
ADD_SUBDIRECTORY(driver)
|
||
|
ADD_SUBDIRECTORY(examples)
|
||
|
+IF(MYSQLCPPCONN_BUILD_TESTS)
|
||
|
ADD_SUBDIRECTORY(test)
|
||
|
ADD_SUBDIRECTORY(test/framework)
|
||
|
ADD_SUBDIRECTORY(test/CJUnitTestsPort)
|
||
|
ADD_SUBDIRECTORY(test/unit)
|
||
|
+ENDIF(MYSQLCPPCONN_BUILD_TESTS)
|
||
|
|
||
|
IF(DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
|
||
|
# see also README
|
||
|
diff --git a/driver/CMakeLists.txt b/driver/CMakeLists.txt
|
||
|
index e7136aa..740defa 100644
|
||
|
--- a/driver/CMakeLists.txt
|
||
|
+++ b/driver/CMakeLists.txt
|
||
|
@@ -181,9 +181,13 @@ IF(WIN32)
|
||
|
ENDIF(WIN32)
|
||
|
|
||
|
|
||
|
+IF(ENABLE_BUILD_DYNAMIC)
|
||
|
ADD_LIBRARY(mysqlcppconn SHARED ${MYSQLCPPCONN_SOURCES})
|
||
|
+ENDIF(ENABLE_BUILD_DYNAMIC)
|
||
|
+IF(ENABLE_BUILD_STATIC)
|
||
|
ADD_LIBRARY(mysqlcppconn-static STATIC ${MYSQLCPPCONN_SOURCES})
|
||
|
-SET(MYSQL_LIB_OBJECTS "${MYSQL_LIBRARIES}")
|
||
|
+ENDIF(ENABLE_BUILD_STATIC)
|
||
|
+SET(MYSQL_LIB_OBJECTS "")
|
||
|
|
||
|
IF(WIN32)
|
||
|
INCLUDE_DIRECTORIES(${MYSQL_DIR}/include)
|
||
|
@@ -200,8 +204,10 @@ IF(WIN32)
|
||
|
#Disables bunch of pretty useless warnings on win
|
||
|
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS")
|
||
|
|
||
|
+ IF(ENABLE_BUILD_DYNAMIC)
|
||
|
ADD_LIBRARY(mysqlclient STATIC IMPORTED)
|
||
|
SET_TARGET_PROPERTIES(mysqlclient PROPERTIES IMPORTED_LOCATION "${MYSQL_LIB}" )
|
||
|
+ ENDIF(ENABLE_BUILD_DYNAMIC)
|
||
|
|
||
|
IF(MYSQLCLIENT_STATIC_BINDING)
|
||
|
SET(MY_TARGET_LINK_LIBRARIES_DYNAMIC mysqlclient ws2_32)
|
||
|
@@ -240,6 +246,7 @@ ELSEIF(NOT WIN32)
|
||
|
FILE(TO_NATIVE_PATH ${OBJ} OBJ)
|
||
|
SET(MYSQL_STATIC_LIB_OBJECTS "${MYSQL_STATIC_LIB_OBJECTS} ${OBJ}")
|
||
|
ENDFOREACH(OBJ ${MYSQL_STATIC_OBJECTS})
|
||
|
+ FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/.MYSQL_ARCHIVES ${CMAKE_CURRENT_BINARY_DIR}/../.MYSQL_ARCHIVES)
|
||
|
ENDIF(MYSQLCLIENT_STATIC_LINKING)
|
||
|
SET(MYSQL_LIB_OBJECTS "${MYSQL_STATIC_LIB_OBJECTS}")
|
||
|
ENDIF(WIN32)
|
||
|
@@ -250,24 +257,28 @@ IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE)
|
||
|
ENDIF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE)
|
||
|
|
||
|
|
||
|
-TARGET_LINK_LIBRARIES(mysqlcppconn ${MY_TARGET_LINK_LIBRARIES_DYNAMIC}
|
||
|
+IF(ENABLE_BUILD_DYNAMIC)
|
||
|
+TARGET_LINK_LIBRARIES(mysqlcppconn PRIVATE ${MYSQL_LIBRARIES}
|
||
|
${MY_GCOV_LINK_LIBRARIES}
|
||
|
${MYSQLCPPCONN_BOOST_SYSTEM_LIBS}
|
||
|
${MYSQLCPPCONN_BOOST_THREAD_LIBS}
|
||
|
${MYSQLCPPCONN_EXTRA_LIBRARIES}
|
||
|
${MYSQLCPPCONN_ICU_LIBRARY})
|
||
|
+ENDIF(ENABLE_BUILD_DYNAMIC)
|
||
|
|
||
|
# Need to find way it's defined for mysqlcppconn-static only
|
||
|
#IF(WIN32)
|
||
|
# ADD_DEFINITIONS("-DCPPCONN_PUBLIC_FUNC=\"\"")
|
||
|
#ENDIF(WIN32)
|
||
|
|
||
|
-TARGET_LINK_LIBRARIES(mysqlcppconn-static ${MY_TARGET_LINK_LIBRARIES_STATIC}
|
||
|
+IF(ENABLE_BUILD_STATIC)
|
||
|
+TARGET_LINK_LIBRARIES(mysqlcppconn-static PRIVATE ${MYSQL_LIBRARIES}
|
||
|
${MY_GCOV_LINK_LIBRARIES}
|
||
|
${MYSQLCPPCONN_BOOST_SYSTEM_LIBS}
|
||
|
${MYSQLCPPCONN_BOOST_THREAD_LIBS}
|
||
|
${MYSQLCPPCONN_EXTRA_LIBRARIES}
|
||
|
${MYSQLCPPCONN_ICU_LIBRARY})
|
||
|
+ENDIF(ENABLE_BUILD_STATIC)
|
||
|
|
||
|
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||
|
# We pass objects from our C client library in the
|
||
|
@@ -284,12 +295,15 @@ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||
|
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||
|
ENDIF()
|
||
|
|
||
|
+IF(ENABLE_BUILD_STATIC)
|
||
|
SET_TARGET_PROPERTIES(mysqlcppconn-static PROPERTIES
|
||
|
LINK_FLAGS "${MYSQLCPPCONN_LINK_FLAGS_ENV} ${MYSQL_LINK_FLAGS}"
|
||
|
COMPILE_FLAGS "${MYSQLCPPCONN_COMPILE_FLAGS_ENV}"
|
||
|
COMPILE_DEFINITIONS CPPCONN_LIB_BUILD=""
|
||
|
STATIC_LIBRARY_FLAGS "${MYSQL_LIB_OBJECTS}")
|
||
|
+ENDIF(ENABLE_BUILD_STATIC)
|
||
|
|
||
|
+IF(ENABLE_BUILD_DYNAMIC)
|
||
|
SET_TARGET_PROPERTIES(mysqlcppconn
|
||
|
PROPERTIES
|
||
|
SOVERSION "${MYSQLCPPCONN_SOVERSION}"
|
||
|
@@ -298,6 +312,7 @@ SET_TARGET_PROPERTIES(mysqlcppconn
|
||
|
COMPILE_FLAGS "${MYSQLCPPCONN_COMPILE_FLAGS_ENV}"
|
||
|
COMPILE_DEFINITIONS CPPCONN_SO_BUILD=""
|
||
|
LINK_INTERFACE_LIBRARIES "")
|
||
|
+ENDIF(ENABLE_BUILD_DYNAMIC)
|
||
|
|
||
|
IF(WIN32)
|
||
|
# SET_TARGET_PROPERTIES(mysqlcppconn PROPERTIES
|
||
|
@@ -316,14 +331,29 @@ IF(WIN32)
|
||
|
# CHANGE_CRT("/MD")
|
||
|
# ENDIF()
|
||
|
|
||
|
- INSTALL(TARGETS mysqlcppconn mysqlcppconn-static
|
||
|
- RUNTIME DESTINATION lib
|
||
|
+ IF(ENABLE_BUILD_STATIC)
|
||
|
+ IF(STATIC_CRT)
|
||
|
+ INCLUDE(${CMAKE_SOURCE_DIR}/changeCrt.cmake)
|
||
|
+ CHANGE_CRT("T")
|
||
|
+ ENDIF(STATIC_CRT)
|
||
|
+ INSTALL(TARGETS mysqlcppconn-static
|
||
|
+ EXPORT unofficial-mysql-connector-cpp-targets
|
||
|
+ RUNTIME DESTINATION bin
|
||
|
ARCHIVE DESTINATION lib
|
||
|
)
|
||
|
+ ENDIF(ENABLE_BUILD_STATIC)
|
||
|
+ IF(ENABLE_BUILD_DYNAMIC)
|
||
|
+ INSTALL(TARGETS mysqlcppconn
|
||
|
+ EXPORT unofficial-mysql-connector-cpp-targets
|
||
|
+ RUNTIME DESTINATION bin
|
||
|
+ ARCHIVE DESTINATION lib
|
||
|
+ )
|
||
|
+ ENDIF(ENABLE_BUILD_DYNAMIC)
|
||
|
ELSE(WIN32)
|
||
|
IF(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_STATIC)
|
||
|
IF(ENABLE_BUILD_DYNAMIC)
|
||
|
INSTALL(TARGETS mysqlcppconn
|
||
|
+ EXPORT unofficial-mysql-connector-cpp-targets
|
||
|
LIBRARY DESTINATION ${INSTALL_LIBDIR}
|
||
|
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
|
||
|
)
|
||
|
@@ -331,6 +361,7 @@ ELSE(WIN32)
|
||
|
|
||
|
IF(ENABLE_BUILD_STATIC)
|
||
|
INSTALL(TARGETS mysqlcppconn-static
|
||
|
+ EXPORT unofficial-mysql-connector-cpp-targets
|
||
|
LIBRARY DESTINATION ${INSTALL_LIBDIR}
|
||
|
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
|
||
|
)
|
||
|
@@ -343,6 +374,12 @@ ELSE(WIN32)
|
||
|
ENDIF(ENABLE_BUILD_DYNAMIC OR ENABLE_BUILD_STATIC)
|
||
|
ENDIF(WIN32)
|
||
|
|
||
|
+include(CMakePackageConfigHelpers)
|
||
|
+configure_package_config_file(
|
||
|
+ "${CMAKE_SOURCE_DIR}/mysql-connector-cpp-config.cmake.in"
|
||
|
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mysql-connector-cpp-config.cmake"
|
||
|
+ INSTALL_DESTINATION "share/unofficial-mysql-connector-cpp"
|
||
|
+)
|
||
|
|
||
|
# Install some MySQL specific headers
|
||
|
SET(MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS
|
||
|
@@ -352,5 +389,7 @@ SET(MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS
|
||
|
|
||
|
INSTALL(FILES ${MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS} DESTINATION include)
|
||
|
|
||
|
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mysql-connector-cpp-config.cmake" DESTINATION "share/unofficial-mysql-connector-cpp")
|
||
|
+install(EXPORT unofficial-mysql-connector-cpp-targets DESTINATION share/unofficial-mysql-connector-cpp)
|
||
|
|
||
|
MESSAGE(STATUS "Configuring driver")
|