mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-27 15:29:01 +08:00
74844c7546
* [libmysql/libmariadb] Add vcpkg-cmake-wrapper and usage * [libmysql] Export target unofficial-libmysql * [libmariadb] Export target unofficial-libmariadb * Add conditions * Remove empty folder * [libmysql] Enable static build, generate library mysqlclient * Update ports/libmysql/CONTROL * [libmysql] Re-write portfile.cmake * [vcpkg_clean_executables_in_bin] clean up the pdbs * [libmysql] Fix tools on non-Windows * [libmysql] Fix tools, fix wrapper * [libmysql] Add macro libmysql_FOUND * [vcpkg_clean_executables_in_bin] Revert changes * [libmysql] Export unofficial-libmysql on both dynamic and static * Update ports/libmariadb/export-cmake-targets.patch Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com> Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
124 lines
4.5 KiB
Diff
124 lines
4.5 KiB
Diff
diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
|
|
index c3a05ec..0d44ef2 100644
|
|
--- a/cmake/install_macros.cmake
|
|
+++ b/cmake/install_macros.cmake
|
|
@@ -100,7 +100,7 @@ ENDFUNCTION()
|
|
|
|
FUNCTION(MYSQL_INSTALL_TARGETS)
|
|
MYSQL_PARSE_ARGUMENTS(ARG
|
|
- "DESTINATION;COMPONENT"
|
|
+ "DESTINATION;COMPONENT;EXPORT"
|
|
""
|
|
${ARGN}
|
|
)
|
|
@@ -115,7 +115,20 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
|
|
IF(ARG_COMPONENT)
|
|
SET(COMP COMPONENT ${ARG_COMPONENT})
|
|
ENDIF()
|
|
- INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP})
|
|
+ IF (ARG_EXPORT)
|
|
+ FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${ARG_EXPORT}-config.cmake"
|
|
+"include(CMakeFindDependencyMacro)
|
|
+find_dependency(ZLIB)
|
|
+find_dependency(OpenSSL)
|
|
+include(\"\${CMAKE_CURRENT_LIST_DIR}/${ARG_EXPORT}-targets.cmake\")
|
|
+")
|
|
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ARG_EXPORT}-config.cmake DESTINATION share/${ARG_EXPORT})
|
|
+ set(EXPORT_ARGS EXPORT ${ARG_EXPORT}-targets)
|
|
+ ENDIF()
|
|
+ INSTALL(TARGETS ${TARGETS} ${EXPORT_ARGS} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ${COMP})
|
|
+ IF (ARG_EXPORT)
|
|
+ INSTALL(${EXPORT_ARGS} DESTINATION share/${ARG_EXPORT})
|
|
+ ENDIF()
|
|
SET(INSTALL_LOCATION ${ARG_DESTINATION} )
|
|
INSTALL_DEBUG_SYMBOLS("${TARGETS}")
|
|
SET(INSTALL_LOCATION)
|
|
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
|
|
index 5481fae..3fa58da 100644
|
|
--- a/cmake/libutils.cmake
|
|
+++ b/cmake/libutils.cmake
|
|
@@ -237,7 +237,7 @@ MACRO(MERGE_LIBRARIES_SHARED)
|
|
IF(ARG_COMPONENT)
|
|
SET(COMP COMPONENT ${ARG_COMPONENT})
|
|
ENDIF()
|
|
- MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP})
|
|
+ MYSQL_INSTALL_TARGETS(${TARGET} EXPORT unofficial-libmysql DESTINATION "${INSTALL_LIBDIR}" ${COMP})
|
|
ENDIF()
|
|
ENDMACRO()
|
|
|
|
@@ -372,7 +372,7 @@ MACRO(MERGE_CONVENIENCE_LIBRARIES)
|
|
SET(COMP COMPONENT ${ARG_COMPONENT})
|
|
ENDIF()
|
|
IF(INSTALL_STATIC_LIBRARIES)
|
|
- MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP})
|
|
+ MYSQL_INSTALL_TARGETS(${TARGET} EXPORT unofficial-libmysql DESTINATION "${INSTALL_LIBDIR}" ${COMP})
|
|
ENDIF()
|
|
ENDIF()
|
|
ENDMACRO()
|
|
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
|
|
index 605288d..c5d0f5d 100644
|
|
--- a/libmysql/CMakeLists.txt
|
|
+++ b/libmysql/CMakeLists.txt
|
|
@@ -245,8 +245,16 @@ ENDIF()
|
|
# LDAP authentication SASL client plugin
|
|
ADD_SUBDIRECTORY(authentication_ldap)
|
|
|
|
+IF (BUILD_SHARED_LIBS)
|
|
+ set(INSTALL_SHARED )
|
|
+ set(INSTALL_STATIC SKIP_INSTALL)
|
|
+ELSE()
|
|
+ set(INSTALL_SHARED SKIP_INSTALL)
|
|
+ set(INSTALL_STATIC )
|
|
+ENDIF()
|
|
+
|
|
# Merge several convenience libraries into one big mysqlclient
|
|
-MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERGE} COMPONENT Development)
|
|
+MERGE_CONVENIENCE_LIBRARIES(mysqlclient ${LIBS_TO_MERGE} ${INSTALL_STATIC} COMPONENT Development)
|
|
TARGET_LINK_LIBRARIES(mysqlclient PRIVATE ${LIBS_TO_LINK})
|
|
|
|
# Visual Studio users need debug static library for debug projects
|
|
@@ -283,6 +291,7 @@ ENDIF()
|
|
# Merge several convenience libraries into one big mysqlclient
|
|
# and link them together into shared library.
|
|
MERGE_LIBRARIES_SHARED(libmysql ${LIBS_TO_MERGE}
|
|
+ ${INSTALL_SHARED}
|
|
EXPORTS
|
|
${CLIENT_API_FUNCTIONS}
|
|
${CLIENT_API_FUNCTIONS_UNDOCUMENTED}
|
|
@@ -370,6 +379,7 @@ CONFIGURE_FILE(api_test.c.in ${CMAKE_CURRENT_BINARY_DIR}/api_test.c)
|
|
# from @CLIENT_API_FUNCTIONS@ are declared by <mysql.h>. It will fail
|
|
# to run if not all of these symbols are exported by the library.
|
|
#
|
|
+IF (ENABLE_TESTING)
|
|
MYSQL_ADD_EXECUTABLE(libmysql_api_test
|
|
${CMAKE_CURRENT_BINARY_DIR}/api_test.c
|
|
LINK_LIBRARIES libmysql ${LIBRT}
|
|
@@ -398,3 +408,4 @@ ADD_CUSTOM_COMMAND(TARGET libmysql_api_test POST_BUILD
|
|
COMMAND libmysql_api_test
|
|
> ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
|
|
)
|
|
+ENDIF()
|
|
\ No newline at end of file
|
|
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
|
|
index a5fa18e..0f2e15c 100644
|
|
--- a/scripts/CMakeLists.txt
|
|
+++ b/scripts/CMakeLists.txt
|
|
@@ -329,13 +329,13 @@ MACRO(EXTRACT_LINK_LIBRARIES target var)
|
|
STRING(REGEX REPLACE "^[ ]+" "" ${var} "${${var}}")
|
|
STRING(REGEX REPLACE "[ ]+$" "" ${var} "${${var}}")
|
|
ENDMACRO()
|
|
-
|
|
+IF (NOT BUILD_SHARED_LIBS)
|
|
EXTRACT_LINK_LIBRARIES(mysqlclient CLIENT_LIBS)
|
|
-
|
|
-IF(MSVC)
|
|
+ENDIF()
|
|
+IF(MSVC AND NOT BUILD_SHARED_LIBS)
|
|
GET_TARGET_PROPERTY(LIBMYSQL_OS_SHLIB_VERSION mysqlclient VERSION)
|
|
GET_TARGET_PROPERTY(LIBMYSQL_OS_OUTPUT_NAME mysqlclient OUTPUT_NAME)
|
|
-ELSE()
|
|
+ELSEIF(BUILD_SHARED_LIBS)
|
|
GET_TARGET_PROPERTY(LIBMYSQL_OS_SHLIB_VERSION libmysql VERSION)
|
|
GET_TARGET_PROPERTY(LIBMYSQL_OS_OUTPUT_NAME libmysql OUTPUT_NAME)
|
|
ENDIF()
|