[libmariadb] Fix build error on Linux (#26704)

* [libmariadb] Fix build error on Linux

* x-add-version

* Revert ci.baseline.txt

* fix CMake export

* change ci.baseline.txt to open test libmariadb

* x-add-version

* Revert ci.baseline.txt

* remove CMAKE_SHARED_LIBRARY_C_FLAGS

* x-add-version
This commit is contained in:
Lily Wang 2022-09-12 13:50:09 -07:00 committed by GitHub
parent 16f5ba45a9
commit 4e73d1b47a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 112 deletions

View File

@ -1,45 +0,0 @@
diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt
index d4e07f7..4823858 100644
--- a/libmariadb/CMakeLists.txt
+++ b/libmariadb/CMakeLists.txt
@@ -423,6 +423,7 @@ ELSE()
ADD_LIBRARY(libmariadb ${libmariadb_RC} ${MARIADB_OBJECTS} mariadbclient.def)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINKER_LANGUAGE C)
ENDIF()
+TARGET_INCLUDE_DIRECTORIES(libmariadb PUBLIC $<INSTALL_INTERFACE:include/mysql>)
TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS})
@@ -472,13 +473,32 @@ ENDIF()
INSTALL(TARGETS mariadbclient
COMPONENT Development
+ EXPORT unofficial-libmariadb-targets
LIBRARY DESTINATION lib)
IF(WIN32)
INSTALL(TARGETS libmariadb
COMPONENT SharedLibraries
+ EXPORT unofficial-libmariadb-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
+
+install(EXPORT unofficial-libmariadb-targets
+ NAMESPACE unofficial::
+ DESTINATION share/unofficial-libmariadb
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake.in"
+[[include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+if("@WITH_SSL@" STREQUAL "OPENSSL")
+ find_dependency(OpenSSL)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-libmariadb-targets.cmake")
+]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake DESTINATION share/unofficial-libmariadb)
+
ELSE()
# in cmake 3.12+ we can use
#INSTALL(TARGETS libmariadb LIBRARY DESTINATION ${INSTALL_LIBDIR}

View File

@ -0,0 +1,83 @@
diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt
index 7faf827..d7300b0 100644
--- a/libmariadb/CMakeLists.txt
+++ b/libmariadb/CMakeLists.txt
@@ -417,13 +417,13 @@ ADD_LIBRARY(mariadbclient STATIC ${MARIADB_OBJECTS} ${EMPTY_FILE})
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
IF(UNIX)
- ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE})
- SET_TARGET_PROPERTIES(libmariadb PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+ ADD_LIBRARY(libmariadb ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE})
ELSE()
- ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} mariadbclient.def)
+ ADD_LIBRARY(libmariadb ${libmariadb_RC} ${MARIADB_OBJECTS} mariadbclient.def)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINKER_LANGUAGE C)
ENDIF()
+TARGET_INCLUDE_DIRECTORIES(libmariadb PUBLIC $<INSTALL_INTERFACE:include/mysql>)
TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS})
SIGN_TARGET(libmariadb)
@@ -460,7 +460,9 @@ IF(WITH_MYSQLCOMPAT)
ENDIF()
ENDIF()
+IF(0)
create_symlink(libmariadb${CMAKE_STATIC_LIBRARY_SUFFIX} mariadbclient ${INSTALL_LIBDIR})
+ENDIF()
SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION
${CPACK_PACKAGE_VERSION_MAJOR}
@@ -470,13 +472,39 @@ IF(NOT WIN32)
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES OUTPUT_NAME "${LIBMARIADB_STATIC_NAME}")
ENDIF()
+IF(VCPKG_MARIADBCLIENT)
INSTALL(TARGETS mariadbclient
COMPONENT Development
- DESTINATION ${INSTALL_LIBDIR})
-IF(WIN32)
+ EXPORT unofficial-libmariadb-targets
+ LIBRARY DESTINATION lib)
+ELSE()
+ set_target_properties(mariadbclient PROPERTIES EXCLUDE_FROM_ALL 1)
+ENDIF()
+
+IF(1)
INSTALL(TARGETS libmariadb
COMPONENT SharedLibraries
- DESTINATION ${INSTALL_LIBDIR})
+ EXPORT unofficial-libmariadb-targets
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+install(EXPORT unofficial-libmariadb-targets
+ NAMESPACE unofficial::
+ DESTINATION share/unofficial-libmariadb
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake.in"
+[[include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+if("@WITH_SSL@" STREQUAL "OPENSSL")
+ find_dependency(OpenSSL)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-libmariadb-targets.cmake")
+]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-libmariadb-config.cmake DESTINATION share/unofficial-libmariadb)
+
ELSE()
# in cmake 3.12+ we can use
#INSTALL(TARGETS libmariadb LIBRARY DESTINATION ${INSTALL_LIBDIR}
@@ -488,7 +516,7 @@ INSTALL(TARGETS libmariadb LIBRARY DESTINATION ${INSTALL_LIBDIR}
COMPONENT Development NAMELINK_ONLY)
ENDIF()
-IF(MSVC)
+IF(0)
# On Windows, install PDB
INSTALL(FILES $<TARGET_PDB_FILE:libmariadb> DESTINATION "${INSTALL_LIBDIR}"
CONFIGURATIONS Debug RelWithDebInfo

View File

@ -11,48 +11,6 @@ index a82dbb7..e9005fa 100644
/* mysqld compile time options */
#ifndef MYSQL_CHARSET
diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt
index 7faf827..d4e07f7 100644
--- a/libmariadb/CMakeLists.txt
+++ b/libmariadb/CMakeLists.txt
@@ -417,10 +417,10 @@ ADD_LIBRARY(mariadbclient STATIC ${MARIADB_OBJECTS} ${EMPTY_FILE})
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
IF(UNIX)
- ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE})
+ ADD_LIBRARY(libmariadb ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE})
SET_TARGET_PROPERTIES(libmariadb PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
ELSE()
- ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} mariadbclient.def)
+ ADD_LIBRARY(libmariadb ${libmariadb_RC} ${MARIADB_OBJECTS} mariadbclient.def)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINKER_LANGUAGE C)
ENDIF()
@@ -472,11 +472,13 @@ ENDIF()
INSTALL(TARGETS mariadbclient
COMPONENT Development
- DESTINATION ${INSTALL_LIBDIR})
+ LIBRARY DESTINATION lib)
IF(WIN32)
INSTALL(TARGETS libmariadb
COMPONENT SharedLibraries
- DESTINATION ${INSTALL_LIBDIR})
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
ELSE()
# in cmake 3.12+ we can use
#INSTALL(TARGETS libmariadb LIBRARY DESTINATION ${INSTALL_LIBDIR}
@@ -488,7 +490,7 @@ INSTALL(TARGETS libmariadb LIBRARY DESTINATION ${INSTALL_LIBDIR}
COMPONENT Development NAMELINK_ONLY)
ENDIF()
-IF(MSVC)
+IF(0)
# On Windows, install PDB
INSTALL(FILES $<TARGET_PDB_FILE:libmariadb> DESTINATION "${INSTALL_LIBDIR}"
CONFIGURATIONS Debug RelWithDebInfo
diff --git a/mariadb_config/mariadb_config.c.in b/mariadb_config/mariadb_config.c.in
index 36c0117..4184e4b 100644
--- a/mariadb_config/mariadb_config.c.in

View File

@ -1,20 +0,0 @@
diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt
index 4823858..018101f 100644
--- a/libmariadb/CMakeLists.txt
+++ b/libmariadb/CMakeLists.txt
@@ -471,10 +471,15 @@ IF(NOT WIN32)
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES OUTPUT_NAME "${LIBMARIADB_STATIC_NAME}")
ENDIF()
+if(VCPKG_MARIADBCLIENT)
INSTALL(TARGETS mariadbclient
COMPONENT Development
EXPORT unofficial-libmariadb-targets
LIBRARY DESTINATION lib)
+else()
+ set_target_properties(mariadbclient PROPERTIES EXCLUDE_FROM_ALL 1)
+endif()
+
IF(WIN32)
INSTALL(TARGETS libmariadb
COMPONENT SharedLibraries

View File

@ -17,16 +17,15 @@ vcpkg_from_github(
disable-test-build.patch
fix-InstallPath.patch
fix-iconv.patch
export-cmake-targets.patch
pkgconfig.patch
no-extra-static-lib.patch
fix-openssl.patch
fix-CMakeLists.patch
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
iconv WITH_ICONV
mariadbclient VCPKG_MARIADBCLIENT
iconv WITH_ICONV
mariadbclient VCPKG_MARIADBCLIENT
)
if("openssl" IN_LIST FEATURES)

View File

@ -1,6 +1,7 @@
{
"name": "libmariadb",
"version-semver": "3.3.1",
"port-version": 1,
"description": "MariaDB Connector/C is used to connect C/C++ applications to MariaDB and MySQL databases",
"homepage": "https://github.com/MariaDB/mariadb-connector-c",
"license": "LGPL-2.1-or-later",

View File

@ -3854,7 +3854,7 @@
},
"libmariadb": {
"baseline": "3.3.1",
"port-version": 0
"port-version": 1
},
"libmaxminddb": {
"baseline": "1.4.3",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "34106302d34bd62e9298357aa8b47b2c3aabf204",
"version-semver": "3.3.1",
"port-version": 1
},
{
"git-tree": "ab286c57741848d9bb9a806ad29f5366283af520",
"version-semver": "3.3.1",