diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/modules/FindMariaDBClient.cmake | 96 | ||||
-rw-r--r-- | xbmc/dbwrappers/CMakeLists.txt | 2 |
3 files changed, 46 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3488ab96de..59d7d301ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,7 @@ elseif(ENABLE_MYSQLCLIENT AND NOT ENABLE_MYSQLCLIENT STREQUAL AUTO) endif() core_optional_dep(MariaDBClient) -if(NOT MARIADBCLIENT_FOUND) +if(NOT TARGET MariaDBClient::MariaDBClient) core_optional_dep(MySqlClient) endif() diff --git a/cmake/modules/FindMariaDBClient.cmake b/cmake/modules/FindMariaDBClient.cmake index 108b5eedef..a34ac65aa3 100644 --- a/cmake/modules/FindMariaDBClient.cmake +++ b/cmake/modules/FindMariaDBClient.cmake @@ -3,81 +3,73 @@ # --------------- # Finds the MariaDBClient library # -# This will define the following variables:: -# -# MARIADBCLIENT_FOUND - system has MariaDBClient -# MARIADBCLIENT_INCLUDE_DIRS - the MariaDBClient include directory -# MARIADBCLIENT_LIBRARIES - the MariaDBClient libraries -# MARIADBCLIENT_DEFINITIONS - the MariaDBClient compile definitions -# -# and the following imported targets:: +# This will define the following target: # # MariaDBClient::MariaDBClient - The MariaDBClient library -# Don't find system wide installed version on Windows -if(WIN32) - set(EXTRA_FIND_ARGS NO_SYSTEM_ENVIRONMENT_PATH) -else() - set(EXTRA_FIND_ARGS) -endif() +if(NOT TARGET MariaDBClient::MariaDBClient) + # Don't find system wide installed version on Windows + if(WIN32) + set(EXTRA_FIND_ARGS NO_SYSTEM_ENVIRONMENT_PATH) + else() + set(EXTRA_FIND_ARGS) + endif() -if(PKG_CONFIG_FOUND) - pkg_search_module(PC_MARIADBCLIENT libmariadb mariadb QUIET) -endif() + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_MARIADBCLIENT libmariadb mariadb QUIET) + endif() -find_path(MARIADBCLIENT_INCLUDE_DIR NAMES mariadb/mysql.h mariadb/server/mysql.h - PATHS ${PC_MARIADBCLIENT_INCLUDEDIR}) -find_library(MARIADBCLIENT_LIBRARY_RELEASE NAMES mariadbclient mariadb libmariadb + find_path(MARIADBCLIENT_INCLUDE_DIR NAMES mariadb/mysql.h mariadb/server/mysql.h + PATHS ${PC_MARIADBCLIENT_INCLUDEDIR} + NO_CACHE) + find_library(MARIADBCLIENT_LIBRARY_RELEASE NAMES mariadbclient mariadb libmariadb + PATHS ${PC_MARIADBCLIENT_LIBDIR} + PATH_SUFFIXES mariadb + ${EXTRA_FIND_ARGS} + NO_CACHE) + find_library(MARIADBCLIENT_LIBRARY_DEBUG NAMES mariadbclient mariadb libmariadbd PATHS ${PC_MARIADBCLIENT_LIBDIR} PATH_SUFFIXES mariadb - ${EXTRA_FIND_ARGS}) -find_library(MARIADBCLIENT_LIBRARY_DEBUG NAMES mariadbclient mariadb libmariadbd - PATHS ${PC_MARIADBCLIENT_LIBDIR} - PATH_SUFFIXES mariadb - ${EXTRA_FIND_ARGS}) - -if(PC_MARIADBCLIENT_VERSION) - set(MARIADBCLIENT_VERSION_STRING ${PC_MARIADBCLIENT_VERSION}) -elseif(MARIADBCLIENT_INCLUDE_DIR AND EXISTS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h") - file(STRINGS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h" mariadb_version_str REGEX "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\".*\".*") - string(REGEX REPLACE "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\"([^\"]+)\".*" "\\1" MARIADBCLIENT_VERSION_STRING "${mariadb_version_str}") - unset(mariadb_version_str) -endif() - -include(SelectLibraryConfigurations) -select_library_configurations(MARIADBCLIENT) + ${EXTRA_FIND_ARGS} + NO_CACHE) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MariaDBClient - REQUIRED_VARS MARIADBCLIENT_LIBRARY MARIADBCLIENT_INCLUDE_DIR - VERSION_VAR MARIADBCLIENT_VERSION_STRING) + if(PC_MARIADBCLIENT_VERSION) + set(MARIADBCLIENT_VERSION_STRING ${PC_MARIADBCLIENT_VERSION}) + elseif(MARIADBCLIENT_INCLUDE_DIR AND EXISTS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h") + file(STRINGS "${MARIADBCLIENT_INCLUDE_DIR}/mariadb/mariadb_version.h" mariadb_version_str REGEX "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+MARIADB_CLIENT_VERSION_STR[\t ]+\"([^\"]+)\".*" "\\1" MARIADBCLIENT_VERSION_STRING "${mariadb_version_str}") + unset(mariadb_version_str) + endif() -if(MARIADBCLIENT_FOUND) - set(MARIADBCLIENT_LIBRARIES ${MARIADBCLIENT_LIBRARY}) - set(MARIADBCLIENT_INCLUDE_DIRS ${MARIADBCLIENT_INCLUDE_DIR}) - set(MARIADBCLIENT_DEFINITIONS -DHAS_MARIADB=1) + include(SelectLibraryConfigurations) + select_library_configurations(MARIADBCLIENT) - if(CORE_SYSTEM_NAME STREQUAL osx) - list(APPEND DEPLIBS "-lgssapi_krb5") - endif() + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(MariaDBClient + REQUIRED_VARS MARIADBCLIENT_LIBRARY MARIADBCLIENT_INCLUDE_DIR + VERSION_VAR MARIADBCLIENT_VERSION_STRING) - if(NOT TARGET MariaDBClient::MariaDBClient) + if(MARIADBCLIENT_FOUND) add_library(MariaDBClient::MariaDBClient UNKNOWN IMPORTED) if(MARIADBCLIENT_LIBRARY_RELEASE) set_target_properties(MariaDBClient::MariaDBClient PROPERTIES IMPORTED_CONFIGURATIONS RELEASE - IMPORTED_LOCATION "${MARIADBCLIENT_LIBRARY_RELEASE}") + IMPORTED_LOCATION_RELEASE "${MARIADBCLIENT_LIBRARY_RELEASE}") endif() if(MARIADBCLIENT_LIBRARY_DEBUG) set_target_properties(MariaDBClient::MariaDBClient PROPERTIES IMPORTED_CONFIGURATIONS DEBUG - IMPORTED_LOCATION "${MARIADBCLIENT_LIBRARY_DEBUG}") + IMPORTED_LOCATION_DEBUG "${MARIADBCLIENT_LIBRARY_DEBUG}") endif() set_target_properties(MariaDBClient::MariaDBClient PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MARIADBCLIENT_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS HAS_MARIADB=1) + if(CORE_SYSTEM_NAME STREQUAL osx) + target_link_libraries(MariaDBClient::MariaDBClient INTERFACE gssapi_krb5) + endif() + + set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP MariaDBClient::MariaDBClient) endif() endif() - -mark_as_advanced(MARIADBCLIENT_INCLUDE_DIR MARIADBCLIENT_LIBRARY) diff --git a/xbmc/dbwrappers/CMakeLists.txt b/xbmc/dbwrappers/CMakeLists.txt index 16a03f291a..743d5c9521 100644 --- a/xbmc/dbwrappers/CMakeLists.txt +++ b/xbmc/dbwrappers/CMakeLists.txt @@ -10,7 +10,7 @@ set(HEADERS Database.h qry_dat.h sqlitedataset.h) -if(MYSQLCLIENT_FOUND OR MARIADBCLIENT_FOUND) +if(MYSQLCLIENT_FOUND OR TARGET MariaDBClient::MariaDBClient) list(APPEND SOURCES mysqldataset.cpp) list(APPEND HEADERS mysqldataset.h) endif() |