mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #925 from heinrich5991/pr_ddnet_cmake_fix_bundle_libs
Only use bundled includes only if also using bundled libs
This commit is contained in:
commit
19a8054df6
|
@ -72,11 +72,9 @@ set(CLIENT_EXECUTABLE DDNet CACHE STRING "Name of the build client executable")
|
||||||
# DEPENDENCIES
|
# DEPENDENCIES
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
function(set_extra_dirs VARIABLE NAME)
|
function(set_extra_dirs_lib VARIABLE NAME)
|
||||||
set("PATHS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
set("PATHS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
||||||
set("HINTS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
set("HINTS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
||||||
set("PATHS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
|
||||||
set("HINTS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
|
||||||
if(PREFER_BUNDLED_LIBS)
|
if(PREFER_BUNDLED_LIBS)
|
||||||
set(TYPE HINTS)
|
set(TYPE HINTS)
|
||||||
else()
|
else()
|
||||||
|
@ -90,6 +88,17 @@ function(set_extra_dirs VARIABLE NAME)
|
||||||
set("${TYPE}_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
set("${TYPE}_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(set_extra_dirs_include VARIABLE NAME LIBRARY)
|
||||||
|
set("PATHS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
||||||
|
set("HINTS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
||||||
|
if(LIBRARY)
|
||||||
|
string(FIND "${LIBRARY}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
|
||||||
|
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_BITS AND TARGET_OS)
|
||||||
|
set("HINTS_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Check for PkgConfig once so all the other `find_package` calls can do it
|
# Check for PkgConfig once so all the other `find_package` calls can do it
|
||||||
# quietly.
|
# quietly.
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_CURL libcurl)
|
pkg_check_modules(PC_CURL libcurl)
|
||||||
set_extra_dirs(CURL curl)
|
|
||||||
|
|
||||||
find_path(CURL_INCLUDEDIR curl/curl.h
|
set_extra_dirs_lib(CURL curl)
|
||||||
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
|
||||||
PATHS ${PATHS_CURL_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
find_library(CURL_LIBRARY
|
find_library(CURL_LIBRARY
|
||||||
NAMES curl
|
NAMES curl
|
||||||
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
||||||
PATHS ${PATHS_CURL_LIBDIR}
|
PATHS ${PATHS_CURL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
set_extra_dirs_include(CURL curl "${CURL_LIBRARY}")
|
||||||
|
find_path(CURL_INCLUDEDIR curl/curl.h
|
||||||
|
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
||||||
|
PATHS ${PATHS_CURL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Curl DEFAULT_MSG CURL_LIBRARY CURL_INCLUDEDIR)
|
find_package_handle_standard_args(Curl DEFAULT_MSG CURL_LIBRARY CURL_INCLUDEDIR)
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_FREETYPE freetype2)
|
pkg_check_modules(PC_FREETYPE freetype2)
|
||||||
set_extra_dirs(FREETYPE freetype)
|
|
||||||
|
|
||||||
|
set_extra_dirs_lib(FREETYPE freetype)
|
||||||
|
find_library(FREETYPE_LIBRARY
|
||||||
|
NAMES freetype
|
||||||
|
HINTS ${HINTS_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
||||||
|
PATHS ${PATHS_FREETYPE_LIBDIR}
|
||||||
|
)
|
||||||
|
set_extra_dirs_include(FREETYPE freetype "${FREETYPE_LIBRARY}")
|
||||||
find_path(FREETYPE_INCLUDEDIR
|
find_path(FREETYPE_INCLUDEDIR
|
||||||
NAMES config/ftheader.h freetype/config/ftheader.h
|
NAMES config/ftheader.h freetype/config/ftheader.h
|
||||||
PATH_SUFFIXES freetype2
|
PATH_SUFFIXES freetype2
|
||||||
HINTS ${HINTS_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
HINTS ${HINTS_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
||||||
PATHS ${PATHS_FREETYPE_INCLUDEDIR}
|
PATHS ${PATHS_FREETYPE_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(FREETYPE_LIBRARY
|
|
||||||
NAMES freetype
|
|
||||||
HINTS ${HINTS_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
|
||||||
PATHS ${PATHS_FREETYPE_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDEDIR)
|
find_package_handle_standard_args(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDEDIR)
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_GLEW libglew)
|
pkg_check_modules(PC_GLEW libglew)
|
||||||
set_extra_dirs(GLEW glew)
|
|
||||||
|
|
||||||
find_path(GLEW_INCLUDEDIR GL
|
set_extra_dirs_lib(GLEW glew)
|
||||||
HINTS ${HINTS_GLEW_INCLUDEDIR} ${PC_GLEW_INCLUDEDIR} ${PC_GLEW_INCLUDE_DIRS}
|
|
||||||
PATHS ${PATHS_GLEW_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
find_library(GLEW_LIBRARY
|
find_library(GLEW_LIBRARY
|
||||||
NAMES GLEW glew32
|
NAMES GLEW glew32
|
||||||
HINTS ${HINTS_GLEW_LIBDIR} ${PC_GLEW_LIBDIR} ${PC_GLEW_LIBRARY_DIRS}
|
HINTS ${HINTS_GLEW_LIBDIR} ${PC_GLEW_LIBDIR} ${PC_GLEW_LIBRARY_DIRS}
|
||||||
PATHS ${PATHS_GLEW_LIBDIR}
|
PATHS ${PATHS_GLEW_LIBDIR}
|
||||||
)
|
)
|
||||||
|
set_extra_dirs_include(GLEW glew "${GLEW_LIBRARY}")
|
||||||
|
find_path(GLEW_INCLUDEDIR GL
|
||||||
|
HINTS ${HINTS_GLEW_INCLUDEDIR} ${PC_GLEW_INCLUDEDIR} ${PC_GLEW_INCLUDE_DIRS}
|
||||||
|
PATHS ${PATHS_GLEW_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDEDIR)
|
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDEDIR)
|
||||||
|
|
|
@ -34,30 +34,30 @@ if(MYSQL_CONFIG)
|
||||||
endforeach(LIB ${MYSQL_LIBS})
|
endforeach(LIB ${MYSQL_LIBS})
|
||||||
endif(MYSQL_CONFIG)
|
endif(MYSQL_CONFIG)
|
||||||
|
|
||||||
set_extra_dirs(MYSQL mysql)
|
set_extra_dirs_lib(MYSQL mysql)
|
||||||
|
find_library(MYSQL_LIBRARY
|
||||||
|
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
||||||
|
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
|
PATHS ${PATHS_MYSQL_LIBDIR}
|
||||||
|
)
|
||||||
|
set_extra_dirs_include(MYSQL mysql "${MYSQL_LIBRARY}")
|
||||||
find_path(MYSQL_INCLUDEDIR
|
find_path(MYSQL_INCLUDEDIR
|
||||||
NAMES "mysql.h"
|
NAMES "mysql.h"
|
||||||
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(MYSQL_LIBRARY
|
set_extra_dirs_lib(MYSQL_CPPCONN mysql)
|
||||||
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
|
||||||
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
|
||||||
PATHS ${PATHS_MYSQL_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
|
||||||
NAMES "mysql_connection.h"
|
|
||||||
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
|
||||||
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(MYSQL_CPPCONN_LIBRARY
|
find_library(MYSQL_CPPCONN_LIBRARY
|
||||||
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
||||||
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
HINTS ${HINTS_MYSQL_CPPCONN_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
PATHS ${PATHS_MYSQL_LIBDIR}
|
PATHS ${PATHS_MYSQL_CPPCONN_LIBDIR}
|
||||||
|
)
|
||||||
|
set_extra_dirs_include(MYSQL_CPPCONN mysql "${MYSQL_CPPCONN_LIBRARY}")
|
||||||
|
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
||||||
|
NAMES "mysql_connection.h"
|
||||||
|
HINTS ${HINTS_MYSQL_CPPCONN_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
|
PATHS ${PATHS_MYSQL_CPPCONN_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_OGG ogg)
|
pkg_check_modules(PC_OGG ogg)
|
||||||
|
|
||||||
set_extra_dirs(OGG opus)
|
set_extra_dirs_lib(OGG opus)
|
||||||
|
|
||||||
find_path(OGG_INCLUDEDIR ogg.h
|
|
||||||
PATH_SUFFIXES ogg
|
|
||||||
HINTS ${HINTS_OGG_INCLUDEDIR} ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
|
||||||
PATHS ${PATHS_OGG_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
find_library(OGG_LIBRARY
|
find_library(OGG_LIBRARY
|
||||||
NAMES ogg
|
NAMES ogg
|
||||||
HINTS ${HINTS_OGG_LIBDIR} ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
HINTS ${HINTS_OGG_LIBDIR} ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
||||||
PATHS ${PATHS_OGG_LIBDIR}
|
PATHS ${PATHS_OGG_LIBDIR}
|
||||||
)
|
)
|
||||||
|
set_extra_dirs_include(OGG opus "${OGG_LIBRARY}")
|
||||||
|
find_path(OGG_INCLUDEDIR ogg.h
|
||||||
|
PATH_SUFFIXES ogg
|
||||||
|
HINTS ${HINTS_OGG_INCLUDEDIR} ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
||||||
|
PATHS ${PATHS_OGG_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDEDIR)
|
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDEDIR)
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_OPUS opus)
|
pkg_check_modules(PC_OPUS opus)
|
||||||
set_extra_dirs(OPUS opus)
|
|
||||||
|
|
||||||
find_path(OPUS_INCLUDEDIR opus.h
|
set_extra_dirs_lib(OPUS opus)
|
||||||
PATH_SUFFIXES opus
|
|
||||||
HINTS ${HINTS_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
|
||||||
PATHS ${PATHS_OPUS_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
find_library(OPUS_LIBRARY
|
find_library(OPUS_LIBRARY
|
||||||
NAMES opus
|
NAMES opus
|
||||||
HINTS ${HINTS_OPUS_LIBDIR} ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
HINTS ${HINTS_OPUS_LIBDIR} ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
||||||
PATHS ${PATHS_OPUS_LIBDIR}
|
PATHS ${PATHS_OPUS_LIBDIR}
|
||||||
)
|
)
|
||||||
|
set_extra_dirs_include(OPUS opus "${OPUS_LIBRARY}")
|
||||||
|
find_path(OPUS_INCLUDEDIR opus.h
|
||||||
|
PATH_SUFFIXES opus
|
||||||
|
HINTS ${HINTS_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
||||||
|
PATHS ${PATHS_OPUS_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Opus DEFAULT_MSG OPUS_INCLUDEDIR)
|
find_package_handle_standard_args(Opus DEFAULT_MSG OPUS_INCLUDEDIR)
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_OPUSFILE opusfile)
|
pkg_check_modules(PC_OPUSFILE opusfile)
|
||||||
set_extra_dirs(OPUSFILE opus)
|
|
||||||
|
|
||||||
find_path(OPUSFILE_INCLUDEDIR opusfile.h
|
set_extra_dirs_lib(OPUSFILE opus)
|
||||||
PATH_SUFFIXES opus
|
|
||||||
HINTS ${HINTS_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
|
||||||
PATHS ${PATHS_OPUSFILE_INCLUDEDIR}
|
|
||||||
)
|
|
||||||
find_library(OPUSFILE_LIBRARY
|
find_library(OPUSFILE_LIBRARY
|
||||||
NAMES opusfile
|
NAMES opusfile
|
||||||
HINTS ${HINTS_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
HINTS ${HINTS_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
||||||
PATHS ${PATHS_OPUSFILE_LIBDIR}
|
PATHS ${PATHS_OPUSFILE_LIBDIR}
|
||||||
)
|
)
|
||||||
|
set_extra_dirs_include(OPUSFILE opus "${OPUSFILE_LIBRARY}")
|
||||||
|
find_path(OPUSFILE_INCLUDEDIR opusfile.h
|
||||||
|
PATH_SUFFIXES opus
|
||||||
|
HINTS ${HINTS_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
||||||
|
PATHS ${PATHS_OPUSFILE_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Opusfile DEFAULT_MSG OPUSFILE_LIBRARY OPUSFILE_INCLUDEDIR)
|
find_package_handle_standard_args(Opusfile DEFAULT_MSG OPUSFILE_LIBRARY OPUSFILE_INCLUDEDIR)
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
pkg_check_modules(PC_SDL2 sdl2)
|
pkg_check_modules(PC_SDL2 sdl2)
|
||||||
|
|
||||||
set_extra_dirs(SDL2 sdl)
|
set_extra_dirs_lib(SDL2 sdl)
|
||||||
|
find_library(SDL2_LIBRARY
|
||||||
|
NAMES SDL2
|
||||||
|
HINTS ${HINTS_SDL2_LIBDIR} ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
||||||
|
PATHS ${PATHS_SDL2_LIBDIR}
|
||||||
|
)
|
||||||
|
set_extra_dirs_include(SDL2 sdl "${SDL2_LIBRARY}")
|
||||||
# Looking for 'SDL.h' directly might accidently find a SDL instead of SDL 2
|
# Looking for 'SDL.h' directly might accidently find a SDL instead of SDL 2
|
||||||
# installation. Look for a header file only present in SDL 2 instead.
|
# installation. Look for a header file only present in SDL 2 instead.
|
||||||
find_path(SDL2_INCLUDEDIR SDL_assert.h
|
find_path(SDL2_INCLUDEDIR SDL_assert.h
|
||||||
|
@ -10,11 +15,6 @@ find_path(SDL2_INCLUDEDIR SDL_assert.h
|
||||||
HINTS ${HINTS_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
HINTS ${HINTS_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
||||||
PATHS ${PATHS_SDL2_INCLUDEDIR}
|
PATHS ${PATHS_SDL2_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(SDL2_LIBRARY
|
|
||||||
NAMES SDL2
|
|
||||||
HINTS ${HINTS_SDL2_LIBDIR} ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
|
||||||
PATHS ${PATHS_SDL2_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDEDIR)
|
find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDEDIR)
|
||||||
|
|
Loading…
Reference in a new issue