mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #831 from heinrich5991/pr_ddnet_cmake_prefer_bundled
Add CMake config option `PREFER_BUNDLED_LIBS`
This commit is contained in:
commit
1e1ee7a76b
|
@ -3,22 +3,6 @@ project(DDNet)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
option(WEBSOCKETS "Enable websockets support" OFF)
|
|
||||||
option(MYSQL "Enable mysql support" OFF)
|
|
||||||
option(CLIENT "Compile client" ON)
|
|
||||||
|
|
||||||
# Set the default build type to Release
|
|
||||||
if(NOT(CMAKE_BUILD_TYPE))
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(SERVER_EXECUTABLE DDNet-Server CACHE STRING "Name of the built server executable")
|
|
||||||
set(CLIENT_EXECUTABLE DDNet CACHE STRING "Name of the build client executable")
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# DEPENDENCIES
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
set(TARGET_BITS "64")
|
set(TARGET_BITS "64")
|
||||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
@ -33,11 +17,44 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
set(TARGET_OS "mac")
|
set(TARGET_OS "mac")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(set_extra_dirs VARIABLE NAME)
|
set(PREFER_BUNDLED_LIBS_DEFAULT OFF)
|
||||||
if(TARGET_BITS AND TARGET_OS)
|
if(TARGET_OS STREQUAL "windows")
|
||||||
set("EXTRA_${VARIABLE}_LIBDIR" "ddnet-libs/${NAME}/${TARGET_OS}/lib${TARGET_BITS}" PARENT_SCOPE)
|
set(PREFER_BUNDLED_LIBS_DEFAULT ON)
|
||||||
endif()
|
endif()
|
||||||
set("EXTRA_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
|
||||||
|
option(WEBSOCKETS "Enable websockets support" OFF)
|
||||||
|
option(MYSQL "Enable mysql support" OFF)
|
||||||
|
option(CLIENT "Compile client" ON)
|
||||||
|
option(PREFER_BUNDLED_LIBS "Prefer bundled libraries over system libraries" ${PREFER_BUNDLED_LIBS_DEFAULT})
|
||||||
|
|
||||||
|
# Set the default build type to Release
|
||||||
|
if(NOT(CMAKE_BUILD_TYPE))
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SERVER_EXECUTABLE DDNet-Server CACHE STRING "Name of the built server executable")
|
||||||
|
set(CLIENT_EXECUTABLE DDNet CACHE STRING "Name of the build client executable")
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# DEPENDENCIES
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
function(set_extra_dirs VARIABLE NAME)
|
||||||
|
set("PATHS_${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)
|
||||||
|
set(TYPE HINTS)
|
||||||
|
else()
|
||||||
|
set(TYPE PATHS)
|
||||||
|
endif()
|
||||||
|
if(TARGET_BITS AND TARGET_OS)
|
||||||
|
set(DIR "ddnet-libs/${NAME}/${TARGET_OS}/lib${TARGET_BITS}")
|
||||||
|
set("${TYPE}_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
|
||||||
|
set("EXTRA_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
set("${TYPE}_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
||||||
endfunction()
|
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
|
||||||
|
@ -56,7 +73,11 @@ find_package(Opusfile)
|
||||||
find_package(PythonInterp)
|
find_package(PythonInterp)
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
if(NOT PREFER_BUNDLED_LIBS)
|
||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
|
else()
|
||||||
|
set(ZLIB_FOUND NO)
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "******** DDNet ********")
|
message(STATUS "******** DDNet ********")
|
||||||
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit")
|
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit")
|
||||||
|
|
|
@ -3,13 +3,13 @@ pkg_check_modules(PC_CURL libcurl)
|
||||||
set_extra_dirs(CURL curl)
|
set_extra_dirs(CURL curl)
|
||||||
|
|
||||||
find_path(CURL_INCLUDEDIR curl/curl.h
|
find_path(CURL_INCLUDEDIR curl/curl.h
|
||||||
HINTS ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_CURL_INCLUDEDIR}
|
PATHS ${PATHS_CURL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(CURL_LIBRARY
|
find_library(CURL_LIBRARY
|
||||||
NAMES curl
|
NAMES curl
|
||||||
HINTS ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_CURL_LIBDIR}
|
PATHS ${PATHS_CURL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -5,13 +5,13 @@ set_extra_dirs(FREETYPE freetype)
|
||||||
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 ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
HINTS ${HINTS_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_FREETYPE_INCLUDEDIR}
|
PATHS ${PATHS_FREETYPE_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(FREETYPE_LIBRARY
|
find_library(FREETYPE_LIBRARY
|
||||||
NAMES freetype
|
NAMES freetype
|
||||||
HINTS ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
HINTS ${HINTS_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_FREETYPE_LIBDIR}
|
PATHS ${PATHS_FREETYPE_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -38,26 +38,26 @@ set_extra_dirs(MYSQL mysql)
|
||||||
|
|
||||||
find_path(MYSQL_INCLUDEDIR
|
find_path(MYSQL_INCLUDEDIR
|
||||||
NAMES "mysql.h"
|
NAMES "mysql.h"
|
||||||
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(MYSQL_LIBRARY
|
find_library(MYSQL_LIBRARY
|
||||||
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
||||||
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
PATHS ${EXTRA_MYSQL_LIBDIR}
|
PATHS ${PATHS_MYSQL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
||||||
NAMES "mysql_connection.h"
|
NAMES "mysql_connection.h"
|
||||||
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||||
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(MYSQL_CPPCONN_LIBRARY
|
find_library(MYSQL_CPPCONN_LIBRARY
|
||||||
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
||||||
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||||
PATHS ${EXTRA_MYSQL_LIBDIR}
|
PATHS ${PATHS_MYSQL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -5,13 +5,13 @@ set_extra_dirs(OGG opus)
|
||||||
|
|
||||||
find_path(OGG_INCLUDEDIR ogg.h
|
find_path(OGG_INCLUDEDIR ogg.h
|
||||||
PATH_SUFFIXES ogg
|
PATH_SUFFIXES ogg
|
||||||
HINTS ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
HINTS ${HINTS_OGG_INCLUDEDIR} ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_OGG_INCLUDEDIR}
|
PATHS ${PATHS_OGG_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(OGG_LIBRARY
|
find_library(OGG_LIBRARY
|
||||||
NAMES ogg
|
NAMES ogg
|
||||||
HINTS ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
HINTS ${HINTS_OGG_LIBDIR} ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_OGG_LIBDIR}
|
PATHS ${PATHS_OGG_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -4,13 +4,13 @@ set_extra_dirs(OPUS opus)
|
||||||
|
|
||||||
find_path(OPUS_INCLUDEDIR opus.h
|
find_path(OPUS_INCLUDEDIR opus.h
|
||||||
PATH_SUFFIXES opus
|
PATH_SUFFIXES opus
|
||||||
HINTS ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
HINTS ${HINTS_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_OPUS_INCLUDEDIR}
|
PATHS ${PATHS_OPUS_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(OPUS_LIBRARY
|
find_library(OPUS_LIBRARY
|
||||||
NAMES opus
|
NAMES opus
|
||||||
HINTS ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
HINTS ${HINTS_OPUS_LIBDIR} ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_OPUS_LIBDIR}
|
PATHS ${PATHS_OPUS_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -4,13 +4,13 @@ set_extra_dirs(OPUSFILE opus)
|
||||||
|
|
||||||
find_path(OPUSFILE_INCLUDEDIR opusfile.h
|
find_path(OPUSFILE_INCLUDEDIR opusfile.h
|
||||||
PATH_SUFFIXES opus
|
PATH_SUFFIXES opus
|
||||||
HINTS ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
HINTS ${HINTS_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_OPUSFILE_INCLUDEDIR}
|
PATHS ${PATHS_OPUSFILE_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(OPUSFILE_LIBRARY
|
find_library(OPUSFILE_LIBRARY
|
||||||
NAMES opusfile
|
NAMES opusfile
|
||||||
HINTS ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
HINTS ${HINTS_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_OPUSFILE_LIBDIR}
|
PATHS ${PATHS_OPUSFILE_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
|
@ -7,13 +7,13 @@ set_extra_dirs(SDL2 sdl)
|
||||||
# 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
|
||||||
PATH_SUFFIXES SDL2
|
PATH_SUFFIXES SDL2
|
||||||
HINTS ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
HINTS ${HINTS_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
||||||
PATHS ${EXTRA_SDL2_INCLUDEDIR}
|
PATHS ${PATHS_SDL2_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
find_library(SDL2_LIBRARY
|
find_library(SDL2_LIBRARY
|
||||||
NAMES SDL2
|
NAMES SDL2
|
||||||
HINTS ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
HINTS ${HINTS_SDL2_LIBDIR} ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
||||||
PATHS ${EXTRA_SDL2_LIBDIR}
|
PATHS ${PATHS_SDL2_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
Loading…
Reference in a new issue