mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix mysql cmake build
This commit is contained in:
parent
34c8b047ea
commit
46f30a2fc1
|
@ -81,7 +81,7 @@ endfunction()
|
||||||
show_dependency_status("Curl" ${CURL_FOUND} "${CURL_LIBRARY}")
|
show_dependency_status("Curl" ${CURL_FOUND} "${CURL_LIBRARY}")
|
||||||
show_dependency_status("Freetype" ${FREETYPE_FOUND} "${FREETYPE_LIBRARY}")
|
show_dependency_status("Freetype" ${FREETYPE_FOUND} "${FREETYPE_LIBRARY}")
|
||||||
if(MYSQL)
|
if(MYSQL)
|
||||||
show_dependency_status("MySQL" ${MYSQL_FOUND} "")
|
show_dependency_status("MySQL" ${MYSQL_FOUND} "${MYSQL_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
show_dependency_status("Ogg" ${OGG_FOUND} "${OGG_INCLUDEDIR}")
|
show_dependency_status("Ogg" ${OGG_FOUND} "${OGG_INCLUDEDIR}")
|
||||||
show_dependency_status("Opus" ${OPUS_FOUND} "${OPUS_INCLUDEDIR}")
|
show_dependency_status("Opus" ${OPUS_FOUND} "${OPUS_INCLUDEDIR}")
|
||||||
|
|
|
@ -1,24 +1,69 @@
|
||||||
|
find_program(MYSQL_CONFIG
|
||||||
|
NAMES mysql_config
|
||||||
|
)
|
||||||
|
|
||||||
find_path(MYSQL_INCLUDE_DIR
|
if(MYSQL_CONFIG)
|
||||||
|
exec_program(${MYSQL_CONFIG}
|
||||||
|
ARGS --include
|
||||||
|
OUTPUT_VARIABLE MY_TMP
|
||||||
|
)
|
||||||
|
|
||||||
|
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
|
||||||
|
|
||||||
|
set(MYSQL_CONFIG_INCLUDE_DIR ${MY_TMP} CACHE FILEPATH INTERNAL)
|
||||||
|
|
||||||
|
exec_program(${MYSQL_CONFIG}
|
||||||
|
ARGS --libs_r
|
||||||
|
OUTPUT_VARIABLE MY_TMP
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MYSQL_CONFIG_LIBRARIES "")
|
||||||
|
|
||||||
|
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(LIB ${MYSQL_LIBS})
|
||||||
|
|
||||||
|
set(MYSQL_CONFIG_LIBRARY_PATH "")
|
||||||
|
|
||||||
|
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(LIB ${MYSQL_LIBS})
|
||||||
|
endif(MYSQL_CONFIG)
|
||||||
|
|
||||||
|
set_extra_dirs(MYSQL mysql)
|
||||||
|
|
||||||
|
find_path(MYSQL_INCLUDEDIR
|
||||||
NAMES "mysql.h"
|
NAMES "mysql.h"
|
||||||
PATHS
|
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
"/usr/include/mysql"
|
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
||||||
"/usr/local/include/mysql"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(MYSQL_LIBRARY
|
find_library(MYSQL_LIBRARY
|
||||||
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
||||||
PATHS
|
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
"/usr/lib/mysql"
|
PATHS ${EXTRA_MYSQL_LIBDIR}
|
||||||
"/usr/lib64/mysql"
|
)
|
||||||
"/usr/local/lib/mysql"
|
|
||||||
"/usr/local/lib64/mysql"
|
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
||||||
|
NAMES "mysql_connection.h"
|
||||||
|
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
|
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(MYSQL_CPPCONN_LIBRARY
|
||||||
|
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
||||||
|
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
|
PATHS ${EXTRA_MYSQL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(MySQL DEFAULT_MSG MYSQL_LIBRARY MYSQL_INCLUDE_DIR)
|
find_package_handle_standard_args(MySQL DEFAULT_MSG MYSQL_LIBRARY MYSQL_INCLUDEDIR)
|
||||||
|
|
||||||
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIR})
|
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY} ${MYSQL_CPPCONN_LIBRARY})
|
||||||
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
|
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDEDIR} ${MYSQL_CPPCONN_INCLUDEDIR})
|
||||||
|
|
||||||
mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARY)
|
mark_as_advanced(MYSQL_INCLUDEDIR MYSQL_LIBRARY)
|
||||||
|
|
Loading…
Reference in a new issue