diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 44ea0682..d9e923ca 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -265,15 +265,16 @@ endif( WITH_MP4V2 ) if( WITH_MYSQL ) -#### check for MySql or Mariadb + #### check for MySql or Mariadb -message( STATUS "Check for MariaDB or MySQL" ) -find_program( MYSQL_CONFIG NAMES mariadb_config mysql_config ) -if( NOT MYSQL_CONFIG ) + message( STATUS "Check for MariaDB or MySQL" ) + find_program( MYSQL_CONFIG NAMES mariadb_config mysql_config ) + + if( NOT MYSQL_CONFIG ) tde_message_fatal( "MySql support is requested but neither MySql or Mariadb have been found on your system" ) else() -macro( _mysql_config __type __var ) + macro( _mysql_config __type __var ) execute_process( COMMAND ${MYSQL_CONFIG} --${__type} OUTPUT_VARIABLE ${__var} @@ -282,62 +283,61 @@ macro( _mysql_config __type __var ) if( _result ) tde_message_fatal( "Unable to run ${MYSQL_CONFIG}!" ) endif() -endmacro() + endmacro() -_mysql_config( include MYSQL_INCLUDE_DIRS ) -_mysql_config( libs MYSQL_LIBRARIES ) + _mysql_config( include MYSQL_INCLUDE_DIRS ) + _mysql_config( libs MYSQL_LIBRARIES ) -if( MYSQL_INCLUDE_DIRS ) + if( MYSQL_INCLUDE_DIRS ) string( REGEX REPLACE "(^| +)-I" ";" MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" ) -endif() + endif() -if( MYSQL_LIBRARIES ) + if( MYSQL_LIBRARIES ) string( REGEX REPLACE "(^| +)-l" ";" MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" ) -endif( ) - -set( MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE ) -set( MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" CACHE INTERNAL "" FORCE ) - -message( STATUS " includes ${MYSQL_INCLUDE_DIRS} ") -message( STATUS " libraries ${MYSQL_LIBRARIES} ") -set( USE_MYSQL 1 ) + endif( ) -tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIRS} ) + set( MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE ) + set( MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" CACHE INTERNAL "" FORCE ) -check_cxx_source_compiles(" -#include -typedef struct st_mysql MYSQL; + message( STATUS " includes ${MYSQL_INCLUDE_DIRS} ") + message( STATUS " libraries ${MYSQL_LIBRARIES} ") + set( USE_MYSQL 1 ) -int main(int, char**) -{ - return 1; -}" -HAVE_STRUCT_ST_MYSQL ) - -if( HAVE_STRUCT_ST_MYSQL ) - set( MYSQL_STRUCT "st_mysql" ) -else() + tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIRS} ) check_cxx_source_compiles(" -#include -typedef struct MYSQL MYSQL; - -int main() -{ - return 1; -}" - HAVE_STRUCT_MYSQL ) - - if( HAVE_STRUCT_MYSQL ) - set( MYSQL_STRUCT "MYSQL" ) + #include + typedef struct st_mysql MYSQL; + int main(int, char**) + { + return 1; + }" + HAVE_STRUCT_ST_MYSQL ) + + if( HAVE_STRUCT_ST_MYSQL ) + set( MYSQL_STRUCT "st_mysql" ) else() - tde_message_fatal( "MySQL is requested, but it is not possible to determine the type of MySQL structure" ) + check_cxx_source_compiles(" + #include + typedef struct MYSQL MYSQL; + + int main() + { + return 1; + }" + HAVE_STRUCT_MYSQL ) + + if( HAVE_STRUCT_MYSQL ) + set( MYSQL_STRUCT "MYSQL" ) + else() + tde_message_fatal( "MySQL is requested, but it is not possible to determine the type of MySQL structure" ) + endif() endif() -endif() -tde_restore( CMAKE_REQUIRED_INCLUDES ) + tde_restore( CMAKE_REQUIRED_INCLUDES ) + + endif( NOT MYSQL_CONFIG ) -endif( NOT MYSQL_CONFIG ) endif( WITH_MYSQL )