2017-10-25 14:57:25 +00:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
find_program(MYSQL_CONFIG
|
2018-12-22 14:30:58 +00:00
|
|
|
NAMES mysql_config mariadb_config
|
2017-07-22 19:53:55 +00:00
|
|
|
)
|
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
if(MYSQL_CONFIG)
|
|
|
|
exec_program(${MYSQL_CONFIG}
|
|
|
|
ARGS --include
|
|
|
|
OUTPUT_VARIABLE MY_TMP
|
|
|
|
)
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
set(MYSQL_CONFIG_INCLUDE_DIR ${MY_TMP} CACHE FILEPATH INTERNAL)
|
|
|
|
|
|
|
|
exec_program(${MYSQL_CONFIG}
|
|
|
|
ARGS --libs_r
|
|
|
|
OUTPUT_VARIABLE MY_TMP
|
|
|
|
)
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
set(MYSQL_CONFIG_LIBRARIES "")
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
|
|
|
|
foreach(LIB ${MYSQL_LIB_LIST})
|
|
|
|
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
|
|
|
|
list(APPEND MYSQL_CONFIG_LIBRARIES "${LIB}")
|
|
|
|
endforeach()
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
set(MYSQL_CONFIG_LIBRARY_PATH "")
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
|
|
|
|
foreach(LIB ${MYSQL_LIBDIR_LIST})
|
|
|
|
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
|
|
|
|
list(APPEND MYSQL_CONFIG_LIBRARY_PATH "${LIB}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-07-22 19:53:55 +00:00
|
|
|
|
2024-11-09 18:06:46 +00:00
|
|
|
if(DEFINED ENV{MYSQL_LIBRARY_PATH})
|
|
|
|
list(APPEND MYSQL_CONFIG_LIBRARY_PATH $ENV{MYSQL_LIBRARY_PATH})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED ENV{MYSQL_INCLUDE_PATH})
|
|
|
|
set(MYSQL_CONFIG_INCLUDE_DIR $ENV{MYSQL_INCLUDE_PATH})
|
|
|
|
endif()
|
|
|
|
|
2017-02-23 13:16:32 +00:00
|
|
|
find_library(MYSQL_LIBRARY
|
2017-02-23 13:51:09 +00:00
|
|
|
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
2024-11-09 18:06:46 +00:00
|
|
|
HINTS
|
|
|
|
${MYSQL_CONFIG_LIBRARY_PATH}
|
|
|
|
$ENV{MYSQL_LIBRARY_PATH}
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/../mysql
|
|
|
|
/run/current-system/sw/lib
|
|
|
|
${NIX_STORE_DIR}
|
|
|
|
PATHS
|
|
|
|
/nix/store
|
|
|
|
PATH_SUFFIXES
|
|
|
|
mysql
|
|
|
|
mariadb
|
2017-10-25 14:57:25 +00:00
|
|
|
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
|
2017-07-22 19:53:55 +00:00
|
|
|
)
|
2024-11-09 18:06:46 +00:00
|
|
|
|
2017-10-24 10:10:46 +00:00
|
|
|
find_path(MYSQL_INCLUDEDIR
|
|
|
|
NAMES "mysql.h"
|
2024-11-09 18:06:46 +00:00
|
|
|
HINTS
|
|
|
|
${MYSQL_CONFIG_INCLUDE_DIR}
|
|
|
|
$ENV{MYSQL_INCLUDE_PATH}
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/../mysql
|
|
|
|
/run/current-system/sw/include
|
|
|
|
${NIX_STORE_DIR}
|
|
|
|
PATHS
|
|
|
|
/nix/store
|
|
|
|
PATH_SUFFIXES
|
|
|
|
mysql
|
|
|
|
mariadb
|
|
|
|
mysql/mysql
|
2017-10-25 14:57:25 +00:00
|
|
|
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
|
2017-02-23 13:16:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2017-07-22 19:53:55 +00:00
|
|
|
find_package_handle_standard_args(MySQL DEFAULT_MSG MYSQL_LIBRARY MYSQL_INCLUDEDIR)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
if(MYSQL_FOUND)
|
2021-01-26 20:22:32 +00:00
|
|
|
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
|
|
|
|
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDEDIR})
|
2024-11-09 18:06:46 +00:00
|
|
|
|
|
|
|
if(NOT TARGET MySQL::MySQL)
|
|
|
|
add_library(MySQL::MySQL UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(MySQL::MySQL PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${MYSQL_LIBRARY}"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_INCLUDE_DIRS}"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
mark_as_advanced(MYSQL_INCLUDEDIR MYSQL_LIBRARY)
|
|
|
|
endif()
|