[Amarok] 8c9bc80: Make the MySQL check far more robust. It now check

Myriam Schweingruber myriam at kde.org
Tue Jul 13 11:14:58 CEST 2010


Jefferai, it doesn't build on Debian/Kubuntu anymore. And the error
makes no sense, since MySQL in these distros is compiled with -fPIC.
Also I had to install a new lib dev package (libwrap0-dev), so do we
require new dependencies for that?

/usr/bin/ld: /usr/lib/mysql/libmysqld.a(client.o): relocation
R_X86_64_PC32 against symbol `not_error_sqlstate' can not be used when
making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/amarok_collection-mysqlecollection.so] Error 1
make[1]: *** [src/core-impl/collections/sqlcollection/mysqlecollection/CMakeFiles/amarok_collection-mysqlecollection.dir/all]
Error 2
make: *** [all] Error 2



On Tue, Jul 13, 2010 at 00:30, Jeff Mitchell <mitchell at kde.org> wrote:
> commit 8c9bc801c1ecd327bf221879858ec27024bb84d7
> Author: Jeff Mitchell <mitchell at kde.org>
> Date:   Mon Jul 12 18:29:18 2010 -0400
>
>    Make the MySQL check far more robust. It now checks for the existince of mysql_config and uses it when possible. This gets rid of the need for hardcoded lib configs in various places.
>
> diff --git a/cmake/modules/FindMySQLAmarok.cmake b/cmake/modules/FindMySQLAmarok.cmake
> index 68c6a38..2f90983 100644
> --- a/cmake/modules/FindMySQLAmarok.cmake
> +++ b/cmake/modules/FindMySQLAmarok.cmake
> @@ -12,59 +12,77 @@
>  # Redistribution and use is allowed according to the terms of the BSD license.
>  # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
>
> +if(NOT WIN32)
> +    find_program(MYSQLCONFIG_EXECUTABLE NAMES mysql_config PATHS ${BIN_INSTALL_DIR} ~/usr/bin /usr/local/bin)
> +endif(NOT WIN32)
>
> -find_path(MYSQL_INCLUDE_DIR mysql.h
> -   ~/usr/include/mysql
> -   /opt/local/include/mysql5/mysql
> -   /opt/mysqle/include/mysql
> -   /opt/mysql/mysql/include
> -   /usr/mysql/include/mysql
> -   /usr/include/mysql
> -   /usr/local/include/mysql
> -   /opt/local/include/mysql
> -   /opt/ports/include/mysql5/mysql
> -)
> +if(MYSQLCONFIG_EXECUTABLE)
>
> -if(WIN32)
> -    set(MYSQL_CLIENT_LIBRARY_NAME libmysql)
> -else(WIN32)
> -    set(MYSQL_CLIENT_LIBRARY_NAME mysqlclient)
> -endif(WIN32)
> +    exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --include RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_INCLUDE_DIR)
> +    exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_CFLAGS)
> +    exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_LIBRARIES)
> +    exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libmysqld-libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_EMBEDDED_LIBRARIES)
>
> -find_library(MYSQL_LIBRARIES NAMES ${MYSQL_CLIENT_LIBRARY_NAME}
> -   PATHS
> -   ~/usr/lib/mysql
> -   /opt/mysql/mysql/lib
> -   /usr/mysql/lib/mysql
> -   /opt/local/lib/mysql5/mysql
> -   /opt/mysqle/lib/mysql
> -   /usr/lib/mysql
> -   /usr/lib64/mysql
> -   /usr/lib64
> -   /usr/local/lib/mysql
> -   /opt/local/lib/mysql
> -   /opt/ports/lib/mysql5/mysql
> -)
> +    if(MYSQL_EMBEDDED_LIBRARIES)
> +        set( HAVE_MYSQL_EMBEDDED true )
> +    endif(MYSQL_EMBEDDED_LIBRARIES)
>
> -find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld_pic mysqld libmysqld
> -   PATHS
> -   ~/usr/lib/mysql
> -   /opt/local/lib/mysql5/mysql
> -   /opt/mysqle/lib/mysql
> -   /usr/lib/mysql
> -   /usr/lib64/mysql
> -   /usr/local/lib/mysql
> -   /opt/mysql/lib/mysql
> -   /opt/local/lib/mysql
> -   /opt/ports/lib/mysql5/mysql
> -)
> +else(MYSQLCONFIG_EXECUTABLE)
>
> -macro_push_required_vars()
> -set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
> -set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
> -include_directories( ${MYSQL_INCLUDE_DIR} )
> -check_cxx_source_compiles( "#if (defined(_WIN32) || defined(_WIN64))\n#define __LCC__\n#endif\n#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
> -macro_pop_required_vars()
> +    find_path(MYSQL_INCLUDE_DIR mysql.h
> +       ~/usr/include/mysql
> +       /opt/local/include/mysql5/mysql
> +       /opt/mysqle/include/mysql
> +       /opt/mysql/mysql/include
> +       /usr/mysql/include/mysql
> +       /usr/include/mysql
> +       /usr/local/include/mysql
> +       /opt/local/include/mysql
> +       /opt/ports/include/mysql5/mysql
> +    )
> +
> +    if(WIN32)
> +        set(MYSQL_CLIENT_LIBRARY_NAME libmysql)
> +    else(WIN32)
> +        set(MYSQL_CLIENT_LIBRARY_NAME mysqlclient)
> +    endif(WIN32)
> +
> +    find_library(MYSQL_LIBRARIES NAMES ${MYSQL_CLIENT_LIBRARY_NAME}
> +      PATHS
> +        ~/usr/lib/mysql
> +        /opt/mysql/mysql/lib
> +        usr/mysql/lib/mysql
> +        opt/local/lib/mysql5/mysql
> +        opt/mysqle/lib/mysql
> +        usr/lib/mysql
> +        usr/lib64/mysql
> +        usr/lib64
> +        usr/local/lib/mysql
> +        opt/local/lib/mysql
> +        opt/ports/lib/mysql5/mysql
> +    )
> +
> +    find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld_pic mysqld libmysqld
> +      PATHS
> +        ~/usr/lib/mysql
> +        /opt/local/lib/mysql5/mysql
> +        /opt/mysqle/lib/mysql
> +        /usr/lib/mysql
> +        /usr/lib64/mysql
> +        /usr/local/lib/mysql
> +        /opt/mysql/lib/mysql
> +        /opt/local/lib/mysql
> +        /opt/ports/lib/mysql5/mysql
> +    )
> +
> +    macro_push_required_vars()
> +    set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
> +    set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
> +    include_directories( ${MYSQL_INCLUDE_DIR} )
> +    check_cxx_source_compiles( "#if (defined(_WIN32) || defined(_WIN64))\n#define __LCC__\n#endif\n#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_EMBEDDED )
> +    macro_pop_required_vars()
> +
> +endif(MYSQLCONFIG_EXECUTABLE)
>
>  if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
>    set(MYSQL_FOUND TRUE)
> @@ -74,12 +92,12 @@ else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
>    message(STATUS "MySQL not found.")
>  endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
>
> -if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
> +if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED)
>    set(MYSQL_EMBEDDED_FOUND TRUE)
>    message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}")
> -else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
> +else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED)
>    set(MYSQL_EMBEDDED_FOUND FALSE)
>    message(STATUS "MySQL Embedded not found.")
> -endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
> +endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_EMBEDDED)
>
>  mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES)
> diff --git a/src/core-impl/collections/sqlcollection/mysqlecollection/CMakeLists.txt b/src/core-impl/collections/sqlcollection/mysqlecollection/CMakeLists.txt
> index 914a756..4419b21 100644
> --- a/src/core-impl/collections/sqlcollection/mysqlecollection/CMakeLists.txt
> +++ b/src/core-impl/collections/sqlcollection/mysqlecollection/CMakeLists.txt
> @@ -1,12 +1,13 @@
>  #build-time only dependency in XesamDbus.h
>  #remove at some point
>
> +ADD_DEFINITIONS(${MYSQL_CFLAGS})
> +
>  include_directories(
>         .
>         ..
>         ${CMAKE_SOURCE_DIR}/src
>         ${QT_QTCORE_INCLUDES}
> -        ${OPENSSL_INCLUDE_DIR}
>         ${MYSQL_INCLUDE_DIR}
>         )
>
> @@ -33,19 +34,11 @@ target_link_libraries(amarok_collection-mysqlecollection
>     ${KDE4_KDECORE_LIBS}
>     ${QT_QTCORE_LIBRARY}
>     ${QT_QTGUI_LIBRARY}
> -    ${OPENSSL_LIBRARIES}
>     ${MYSQL_EMBEDDED_LIBRARIES}
>     ${CMAKE_DL_LIBS}
>     ${ZLIB_LIBRARIES}
>  )
>
> -if(NOT WIN32)
> -    target_link_libraries(amarok_collection-mysqlecollection crypto ssl)
> -    if(NOT APPLE)
> -        target_link_libraries(amarok_collection-mysqlecollection crypt pthread)
> -    endif(NOT APPLE)
> -endif(NOT WIN32)
> -
>  if(APPLE)
>        SET_TARGET_PROPERTIES(amarok_collection-mysqlecollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
>  endif(APPLE)
> diff --git a/src/core-impl/collections/sqlcollection/mysqlservercollection/CMakeLists.txt b/src/core-impl/collections/sqlcollection/mysqlservercollection/CMakeLists.txt
> index 45fca94..a702dcc 100644
> --- a/src/core-impl/collections/sqlcollection/mysqlservercollection/CMakeLists.txt
> +++ b/src/core-impl/collections/sqlcollection/mysqlservercollection/CMakeLists.txt
> @@ -1,13 +1,14 @@
>  #build-time only dependency in XesamDbus.h
>  #remove at some point
>
> +ADD_DEFINITIONS(${MYSQL_CFLAGS})
> +
>  include_directories(
>         ..
>         .
>         ${CMAKE_SOURCE_DIR}/src
>         ${CMAKE_BINARY_DIR}/src
>         ${QTIQTCORE_INCLUDES}
> -        ${OPENSSL_INCLUDE_DIR}
>         ${MYSQL_INCLUDE_DIR}
>         )
>
> @@ -33,19 +34,11 @@ target_link_libraries(amarok_collection-mysqlservercollection
>     ${KDE4_KDECORE_LIBS}
>     ${QT_QTCORE_LIBRARY}
>     ${QT_QTGUI_LIBRARY}
> -    ${OPENSSL_LIBRARIES}
>     ${MYSQL_LIBRARIES}
>     ${CMAKE_DL_LIBS}
>     ${ZLIB_LIBRARIES}
>  )
>
> -if(NOT WIN32)
> -    target_link_libraries(amarok_collection-mysqlservercollection crypto ssl)
> -    if(NOT APPLE)
> -        target_link_libraries(amarok_collection-mysqlservercollection crypt pthread)
> -    endif(NOT APPLE)
> -endif(NOT WIN32)
> -
>  if(APPLE)
>        SET_TARGET_PROPERTIES(amarok_collection-mysqlservercollection PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
>  endif(APPLE)
> diff --git a/tests/core-impl/collections/sqlcollection/CMakeLists.txt b/tests/core-impl/collections/sqlcollection/CMakeLists.txt
> index c9d7f1c..8249d22 100644
> --- a/tests/core-impl/collections/sqlcollection/CMakeLists.txt
> +++ b/tests/core-impl/collections/sqlcollection/CMakeLists.txt
> @@ -17,7 +17,6 @@ macro(link_database_test test_target)
>         ${KDE4_KDEUI_LIBS}
>         ${QT_QTTEST_LIBRARY}
>         ${QT_QTCORE_LIBRARY}
> -        ${OPENSSL_LIBRARIES}
>         ${MYSQL_EMBEDDED_LIBRARIES}
>         ${CMAKE_DL_LIBS}
>         ${ZLIB_LIBRARIES})
> @@ -31,6 +30,7 @@ macro(link_database_test test_target)
>
>  endmacro(link_database_test)
>
> +ADD_DEFINITIONS(${MYSQL_CFLAGS})
>
>  include_directories(
>   ${AMAROK_TEST_TREE}
> @@ -43,7 +43,6 @@ include_directories(
>   ${AMAROK_COLLECTION_SUPPORT_DIR}
>   ${KDE4_INCLUDE_DIR}
>   ${QT_INCLUDES}
> -  ${OPENSSL_INCLUDE_DIR}
>   ${MYSQL_INCLUDE_DIR}
>   )
>
> @@ -254,12 +253,7 @@ target_link_libraries( testsqlcollectionlocation
>         ${QT_QTTEST_LIBRARY}
>         ${QT_QTCORE_LIBRARY}
>         ${MYSQL_EMBEDDED_LIBRARIES}
> -        ${OPENSSL_LIBRARIES}
>         ${CMAKE_DL_LIBS}
>         ${ZLIB_LIBRARIES}
>         ${GOOGLEMOCK_LIBRARIES})
>
> -if(NOT WIN32 AND NOT APPLE)
> -    target_link_libraries( testsqlcollectionlocation crypt )
> -endif(NOT WIN32 AND NOT APPLE)
> -
>



-- 
Protect your freedom and join the Fellowship of FSFE:
http://www.fsfe.org
Please don't send me proprietary file formats,
use ISO standard ODF instead (ISO/IEC 26300)


More information about the Amarok-devel mailing list