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 $) 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 $ DESTINATION "${INSTALL_LIBDIR}" CONFIGURATIONS Debug RelWithDebInfo