diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ option(WITH_PLAYER "Enable building of main Amarok player" ON) option(WITH_MP3Tunes "Enable mp3tunes in the Amarok player, requires multiple extra dependencies" ON) option(WITH_IPOD "Enable iPod support in Amarok" ON) -option(WITH_MYSQL_EMBEDDED "Build the embedded database library -- highly recommended" ON) option(WITH_PLAYGROUND "Enable building of playground scripts and applets (WARNING: some of them might have legal issues!)" OFF) ############### Taglib @@ -195,18 +194,21 @@ find_package(X11) find_package(Threads REQUIRED) - find_package(MySQL REQUIRED) - if( WITH_MYSQL_EMBEDDED ) + find_package(MySQL) + + if( NOT MySQL_FOUND ) + find_package(MariaDB REQUIRED) + endif() + + find_package(MySQLe) + if( MySQLe_FOUND ) set( BUILD_MYSQLE_COLLECTION TRUE ) - set_package_properties( MYSQLD PROPERTIES DESCRIPTION "Embedded MySQL Libraries" URL "http://www.mysql.com" TYPE REQUIRED ) + # zlib is required for mysql embedded + find_package(ZLIB REQUIRED) + set_package_properties( ZLIB PROPERTIES DESCRIPTION "zlib" TYPE REQUIRED ) else() add_definitions( "-DNO_MYSQL_EMBEDDED" ) endif() - set_package_properties( MYSQL PROPERTIES DESCRIPTION "MySQL Server Libraries" URL "http://www.mysql.com" TYPE REQUIRED ) - - # zlib is required for mysql embedded - find_package(ZLIB REQUIRED) - set_package_properties( ZLIB PROPERTIES DESCRIPTION "zlib" TYPE REQUIRED ) # We tell users that we need 1.0.3, but we really check just >= 1.0.0. This is because # upstream forgot to update version in lastfm/global.h, so it looks like 1.0.2. :-( diff --git a/cmake/modules/FindMariaDB.cmake b/cmake/modules/FindMariaDB.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/FindMariaDB.cmake @@ -0,0 +1,66 @@ +# - Try to find MariaDB library +# Find the MariaDB includes and client library +# This module defines +# MYSQL_INCLUDE_DIR, where to find mysql.h +# MYSQL_LIBRARIES, the libraries needed to use MariaDB. +# MariaDB_FOUND, If false, do not try to use MariaDB. + +# Copyright (c) 2006-2018, Jarosław Staniek +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(CheckCXXSourceCompiles) +include(CMakePushCheckState) + +# First try to get information from mariadb_config which might be a shell script +# or an executable. Unfortunately not every distro has pkgconfig files for +# MariaDB. +find_program(MARIADBCONFIG_EXECUTABLE + NAMES mariadb_config + HINTS ${BIN_INSTALL_DIR} +) + +if(MARIADBCONFIG_EXECUTABLE) + execute_process( + COMMAND ${MARIADBCONFIG_EXECUTABLE} --libs + RESULT_VARIABLE MC_return_libraries + OUTPUT_VARIABLE MYSQL_LIBRARIES + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +# Try searching manually via find_path/find_library, possibly with hints +# from pkg-config +find_package(PkgConfig) +pkg_check_modules(PC_MARIADB libmariadb) + +find_path(MYSQL_INCLUDE_DIR mysql.h + PATHS + $ENV{MYSQL_INCLUDE_DIR} + $ENV{MYSQL_DIR}/include + ${PC_MARIADB_INCLUDEDIR} + ${PC_MARIADB_INCLUDE_DIRS} + /usr/local/mariadb/include + /opt/mariadb/mariadb/include + PATH_SUFFIXES + mariadb +) + +if(PC_MARIADB_VERSION) + set(MySQL_VERSION_STRING ${PC_MARIADB_VERSION}) +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(MariaDB + REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIR + VERSION_VAR MySQL_VERSION_STRING +) + +mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES) + +set_package_properties(MariaDB PROPERTIES + DESCRIPTION "MariaDB Client Library (libmariadb)" + URL "https://mariadb.org/" +) diff --git a/cmake/modules/FindMySQL.cmake b/cmake/modules/FindMySQL.cmake --- a/cmake/modules/FindMySQL.cmake +++ b/cmake/modules/FindMySQL.cmake @@ -1,11 +1,9 @@ -# - Try to find MySQL / MySQL Embedded library +# - Try to find MySQL library # Find the MySQL includes and client library # This module defines # MYSQL_INCLUDE_DIR, where to find mysql.h # MYSQL_LIBRARIES, the libraries needed to use MySQL. -# MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded. # MySQL_FOUND, If false, do not try to use MySQL. -# MySQL_Embedded_FOUND, If false, do not try to use MySQL Embedded. # Copyright (c) 2006-2018, Jarosław Staniek # @@ -30,22 +28,6 @@ OUTPUT_VARIABLE MYSQL_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE ) - - execute_process( - COMMAND ${MYSQLCONFIG_EXECUTABLE} --libmysqld-libs - RESULT_VARIABLE MC_return_embedded - OUTPUT_VARIABLE MC_MYSQL_EMBEDDED_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - if(NOT MC_MYSQL_EMBEDDED_LIBRARIES) - # At least on OpenSUSE --libmysql-libs doesn't exist, so we just use - # MYSQL_LIBRARIES for that. We'll see if that's enough when testing - # below. - set(MYSQL_EMBEDDED_LIBRARIES ${MYSQL_LIBRARIES}) - else() - set(MYSQL_EMBEDDED_LIBRARIES ${MC_MYSQL_EMBEDDED_LIBRARIES}) - endif() endif() # Try searching manually via find_path/find_library, possibly with hints @@ -65,7 +47,7 @@ mysql ) -if(NOT MYSQL_LIBRARIES AND NOT MYSQL_EMBEDDED_LIBRARIES) +if(NOT MYSQL_LIBRARIES) find_library(MYSQL_LIBRARIES NAMES mysqlclient PATHS $ENV{MYSQL_DIR}/libmysql_r/.libs @@ -76,53 +58,22 @@ PATH_SUFFIXES mysql ) - - find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld libmysqld - PATHS - $ENV{MYSQL_DIR}/libmysql_r/.libs - $ENV{MYSQL_DIR}/lib - $ENV{MYSQL_DIR}/lib/mysql - ${PC_MYSQL_LIBDIR} - ${PC_MYSQL_LIBRARY_DIRS} - PATH_SUFFIXES - mysql - ) endif() if(PC_MYSQL_VERSION) set(MySQL_VERSION_STRING ${PC_MYSQL_VERSION}) endif() -if(MYSQL_EMBEDDED_LIBRARIES) - # libmysqld on FreeBSD apparently doesn't properly report what libraries - # it likes to link with, libmysqlclient does though. - #if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD") - # string(REGEX REPLACE "-lmysqlclient" "-lmysqld" _mysql_libs ${MYSQL_LIBRARIES}) - # string(STRIP ${_mysql_libs} _mysql_libs) - # set(MYSQL_EMBEDDED_LIBRARIES ${_mysql_libs}) - #endif() - cmake_push_check_state() - set(CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES}) - check_cxx_source_compiles( "#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION ) - cmake_pop_check_state() -endif() - include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MySQL REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIR VERSION_VAR MySQL_VERSION_STRING ) -find_package_handle_standard_args(MySQL_Embedded - REQUIRED_VARS MYSQL_EMBEDDED_LIBRARIES MYSQL_INCLUDE_DIR HAVE_MYSQL_OPT_EMBEDDED_CONNECTION -) +mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES) -mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES - MYSQL_EMBEDDED_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION -) set_package_properties(MySQL PROPERTIES DESCRIPTION "MySQL Client Library (libmysqlclient)" - URL "http://www.mysql.com" + URL "https://www.mysql.com" ) diff --git a/cmake/modules/FindMySQLe.cmake b/cmake/modules/FindMySQLe.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/FindMySQLe.cmake @@ -0,0 +1,106 @@ +# - Try to find MySQL Embedded library +# Find the MySQL embedded library +# This module defines +# MYSQLE_LIBRARIES, the libraries needed to use MySQL Embedded. +# MySQLe_FOUND, If false, do not try to use MySQL Embedded. + +# Copyright (c) 2006-2018, Jarosław Staniek +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(CheckCXXSourceCompiles) +include(CMakePushCheckState) + +if(NOT MySQL_FOUND) + find_package(MySQL) + + if( NOT MySQL_FOUND ) + find_package(MariaDB REQUIRED) + endif() +endif() + +if(MySQL_FOUND OR MariaDB_FOUND) + +# First try to get information from mysql_config which might be a shell script +# or an executable. Unfortunately not every distro has pkgconfig files for +# MySQL/MariaDB. +find_program(MYSQLCONFIG_EXECUTABLE + NAMES mysql_config mysql_config5 + HINTS ${BIN_INSTALL_DIR} +) + +if(MYSQLCONFIG_EXECUTABLE) + execute_process( + COMMAND ${MYSQLCONFIG_EXECUTABLE} --libmysqld-libs + RESULT_VARIABLE MC_return_embedded + OUTPUT_VARIABLE MC_MYSQLE_LIBRARIES + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(NOT MC_MYSQLE_LIBRARIES) + # At least on OpenSUSE --libmysql-libs doesn't exist, so we just use + # MYSQL_LIBRARIES for that. We'll see if that's enough when testing + # below. + set(MYSQLE_LIBRARIES ${MYSQL_LIBRARIES}) + else() + set(MYSQLE_LIBRARIES ${MC_MYSQLE_LIBRARIES}) + endif() +endif() + +# Try searching manually via find_path/find_library, possibly with hints +# from pkg-config +find_package(PkgConfig) +pkg_check_modules(PC_MYSQL QUIET mysql mariadb) + +if(NOT MYSQLE_LIBRARIES) + find_library(MYSQLE_LIBRARIES NAMES mysqld libmysqld + PATHS + $ENV{MYSQL_DIR}/libmysql_r/.libs + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/lib/mysql + ${PC_MYSQL_LIBDIR} + ${PC_MYSQL_LIBRARY_DIRS} + PATH_SUFFIXES + mysql + ) +endif() + +if(PC_MYSQL_VERSION) + set(MySQLe_VERSION_STRING ${PC_MYSQL_VERSION}) +endif() + +if(MYSQLE_LIBRARIES) + # libmysqld on FreeBSD apparently doesn't properly report what libraries + # it likes to link with, libmysqlclient does though. + #if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD") + # string(REGEX REPLACE "-lmysqlclient" "-lmysqld" _mysql_libs ${MYSQL_LIBRARIES}) + # string(STRIP ${_mysql_libs} _mysql_libs) + # set(MYSQLE_LIBRARIES ${_mysql_libs}) + #endif() + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MYSQLE_LIBRARIES}) + check_cxx_source_compiles( "#include \nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION ) + cmake_pop_check_state() +endif() + +if(PC_MYSQL_VERSION) + set(MySQLe_VERSION_STRING ${PC_MYSQL_VERSION}) +endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(MySQLe + REQUIRED_VARS MYSQLE_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION + VERSION_VAR MySQLe_VERSION_STRING +) + +mark_as_advanced(MYSQLE_LIBRARIES HAVE_MYSQL_OPT_EMBEDDED_CONNECTION) + +set_package_properties(MySQLe PROPERTIES + DESCRIPTION "MySQL Embedded Library (libmysqld)" + URL "https://www.mysql.com" +) diff --git a/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt b/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt --- a/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt +++ b/src/core-impl/collections/db/sql/mysqlcollection/CMakeLists.txt @@ -21,12 +21,11 @@ Qt5::Core Qt5::Gui ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} ) -if(WITH_MYSQL_EMBEDDED) - target_link_libraries( amarok_collection-mysqlcollection ${MYSQL_EMBEDDED_LIBRARIES} ) -endif(WITH_MYSQL_EMBEDDED) +if(BUILD_MYSQLE_COLLECTION) + target_link_libraries( amarok_collection-mysqlcollection ${MYSQLE_LIBRARIES} ) +endif() if(APPLE) SET_TARGET_PROPERTIES(amarok_collection-mysqlcollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") diff --git a/src/core-impl/storage/sql/CMakeLists.txt b/src/core-impl/storage/sql/CMakeLists.txt --- a/src/core-impl/storage/sql/CMakeLists.txt +++ b/src/core-impl/storage/sql/CMakeLists.txt @@ -1,6 +1,6 @@ if( BUILD_MYSQLE_COLLECTION ) add_subdirectory( mysqlestorage ) endif() -if( MySQL_FOUND ) +if( MySQL_FOUND OR MariaDB_FOUND ) add_subdirectory( mysqlserverstorage ) endif() diff --git a/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt b/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt --- a/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt +++ b/src/core-impl/storage/sql/mysqlestorage/CMakeLists.txt @@ -22,7 +22,7 @@ amaroklib Qt5::Core Qt5::Gui - ${MYSQL_EMBEDDED_LIBRARIES} + ${MYSQLE_LIBRARIES} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES} ) diff --git a/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt b/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt --- a/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt +++ b/src/core-impl/storage/sql/mysqlserverstorage/CMakeLists.txt @@ -24,7 +24,6 @@ Qt5::Gui ${MYSQL_LIBRARIES} ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} ) if(NOT WIN32 AND NOT APPLE) diff --git a/tests/core-impl/collections/db/sql/CMakeLists.txt b/tests/core-impl/collections/db/sql/CMakeLists.txt --- a/tests/core-impl/collections/db/sql/CMakeLists.txt +++ b/tests/core-impl/collections/db/sql/CMakeLists.txt @@ -24,9 +24,8 @@ KF5::ThreadWeaver Qt5::Test Qt5::Core - ${MYSQL_EMBEDDED_LIBRARIES} + ${MYSQLE_LIBRARIES} ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} ) if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "FreeBSD") diff --git a/tests/dynamic/CMakeLists.txt b/tests/dynamic/CMakeLists.txt --- a/tests/dynamic/CMakeLists.txt +++ b/tests/dynamic/CMakeLists.txt @@ -18,7 +18,7 @@ ${CMAKE_DL_LIBS} # ${TAGLIB-EXTRAS_LIBRARIES} # ${TAGLIB_LIBRARIES} - ${ZLIB_LIBRARIES}) + ) endmacro(link_database_test) diff --git a/tests/scanner/CMakeLists.txt b/tests/scanner/CMakeLists.txt --- a/tests/scanner/CMakeLists.txt +++ b/tests/scanner/CMakeLists.txt @@ -31,7 +31,6 @@ Qt5::Test Qt5::Core ${CMAKE_DL_LIBS} - ${ZLIB_LIBRARIES} ${GOOGLEMOCK_LIBRARIES}) endmacro(add_database_test)