mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add CMake config option PREFER_BUNDLED_LIBS
This makes CMake look at the provided libraries before considering system libraries. Enable this by default on Windows. Fixes #830.
This commit is contained in:
parent
ce39187ec3
commit
52e42c2f74
|
@ -3,22 +3,6 @@ project(DDNet)
|
|||
|
||||
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)
|
||||
set(TARGET_BITS "64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
|
@ -33,11 +17,44 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|||
set(TARGET_OS "mac")
|
||||
endif()
|
||||
|
||||
set(PREFER_BUNDLED_LIBS_DEFAULT OFF)
|
||||
if(TARGET_OS STREQUAL "windows")
|
||||
set(PREFER_BUNDLED_LIBS_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
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)
|
||||
if(TARGET_BITS AND TARGET_OS)
|
||||
set("EXTRA_${VARIABLE}_LIBDIR" "ddnet-libs/${NAME}/${TARGET_OS}/lib${TARGET_BITS}" PARENT_SCOPE)
|
||||
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()
|
||||
set("EXTRA_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" PARENT_SCOPE)
|
||||
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()
|
||||
|
||||
# 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(SDL2)
|
||||
find_package(Threads)
|
||||
find_package(ZLIB)
|
||||
if(NOT PREFER_BUNDLED_LIBS)
|
||||
find_package(ZLIB)
|
||||
else()
|
||||
set(ZLIB_FOUND NO)
|
||||
endif()
|
||||
|
||||
message(STATUS "******** DDNet ********")
|
||||
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit")
|
||||
|
|
|
@ -3,13 +3,13 @@ pkg_check_modules(PC_CURL libcurl)
|
|||
set_extra_dirs(CURL curl)
|
||||
|
||||
find_path(CURL_INCLUDEDIR curl/curl.h
|
||||
HINTS ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_CURL_INCLUDEDIR}
|
||||
HINTS ${HINTS_CURL_INCLUDEDIR} ${PC_CURL_INCLUDEDIR} ${PC_CURL_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_CURL_INCLUDEDIR}
|
||||
)
|
||||
find_library(CURL_LIBRARY
|
||||
NAMES curl
|
||||
HINTS ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_CURL_LIBDIR}
|
||||
HINTS ${HINTS_CURL_LIBDIR} ${PC_CURL_LIBDIR} ${PC_CURL_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_CURL_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -5,13 +5,13 @@ set_extra_dirs(FREETYPE freetype)
|
|||
find_path(FREETYPE_INCLUDEDIR
|
||||
NAMES config/ftheader.h freetype/config/ftheader.h
|
||||
PATH_SUFFIXES freetype2
|
||||
HINTS ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_FREETYPE_INCLUDEDIR}
|
||||
HINTS ${HINTS_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_FREETYPE_INCLUDEDIR}
|
||||
)
|
||||
find_library(FREETYPE_LIBRARY
|
||||
NAMES freetype
|
||||
HINTS ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_FREETYPE_LIBDIR}
|
||||
HINTS ${HINTS_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBDIR} ${PC_FREETYPE_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_FREETYPE_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -38,26 +38,26 @@ set_extra_dirs(MYSQL mysql)
|
|||
|
||||
find_path(MYSQL_INCLUDEDIR
|
||||
NAMES "mysql.h"
|
||||
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
||||
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES "mysqlclient" "mysqlclient_r" "mariadbclient"
|
||||
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||
PATHS ${EXTRA_MYSQL_LIBDIR}
|
||||
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||
PATHS ${PATHS_MYSQL_LIBDIR}
|
||||
)
|
||||
|
||||
find_path(MYSQL_CPPCONN_INCLUDEDIR
|
||||
NAMES "mysql_connection.h"
|
||||
HINTS ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||
PATHS ${EXTRA_MYSQL_INCLUDEDIR}
|
||||
HINTS ${HINTS_MYSQL_INCLUDEDIR} ${MYSQL_CONFIG_INCLUDE_DIR}
|
||||
PATHS ${PATHS_MYSQL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(MYSQL_CPPCONN_LIBRARY
|
||||
NAMES "mysqlcppconn" "mysqlcppconn-static"
|
||||
HINTS ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||
PATHS ${EXTRA_MYSQL_LIBDIR}
|
||||
HINTS ${HINTS_MYSQL_LIBDIR} ${MYSQL_CONFIG_LIBRARY_PATH}
|
||||
PATHS ${PATHS_MYSQL_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -5,13 +5,13 @@ set_extra_dirs(OGG opus)
|
|||
|
||||
find_path(OGG_INCLUDEDIR ogg.h
|
||||
PATH_SUFFIXES ogg
|
||||
HINTS ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_OGG_INCLUDEDIR}
|
||||
HINTS ${HINTS_OGG_INCLUDEDIR} ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_OGG_INCLUDEDIR}
|
||||
)
|
||||
find_library(OGG_LIBRARY
|
||||
NAMES ogg
|
||||
HINTS ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_OGG_LIBDIR}
|
||||
HINTS ${HINTS_OGG_LIBDIR} ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_OGG_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -4,13 +4,13 @@ set_extra_dirs(OPUS opus)
|
|||
|
||||
find_path(OPUS_INCLUDEDIR opus.h
|
||||
PATH_SUFFIXES opus
|
||||
HINTS ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_OPUS_INCLUDEDIR}
|
||||
HINTS ${HINTS_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDEDIR} ${PC_OPUS_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_OPUS_INCLUDEDIR}
|
||||
)
|
||||
find_library(OPUS_LIBRARY
|
||||
NAMES opus
|
||||
HINTS ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_OPUS_LIBDIR}
|
||||
HINTS ${HINTS_OPUS_LIBDIR} ${PC_OPUS_LIBDIR} ${PC_OPUS_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_OPUS_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -4,13 +4,13 @@ set_extra_dirs(OPUSFILE opus)
|
|||
|
||||
find_path(OPUSFILE_INCLUDEDIR opusfile.h
|
||||
PATH_SUFFIXES opus
|
||||
HINTS ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_OPUSFILE_INCLUDEDIR}
|
||||
HINTS ${HINTS_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDEDIR} ${PC_OPUSFILE_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_OPUSFILE_INCLUDEDIR}
|
||||
)
|
||||
find_library(OPUSFILE_LIBRARY
|
||||
NAMES opusfile
|
||||
HINTS ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_OPUSFILE_LIBDIR}
|
||||
HINTS ${HINTS_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBDIR} ${PC_OPUSFILE_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_OPUSFILE_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -7,13 +7,13 @@ set_extra_dirs(SDL2 sdl)
|
|||
# installation. Look for a header file only present in SDL 2 instead.
|
||||
find_path(SDL2_INCLUDEDIR SDL_assert.h
|
||||
PATH_SUFFIXES SDL2
|
||||
HINTS ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
||||
PATHS ${EXTRA_SDL2_INCLUDEDIR}
|
||||
HINTS ${HINTS_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDEDIR} ${PC_SDL2_INCLUDE_DIRS}
|
||||
PATHS ${PATHS_SDL2_INCLUDEDIR}
|
||||
)
|
||||
find_library(SDL2_LIBRARY
|
||||
NAMES SDL2
|
||||
HINTS ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
||||
PATHS ${EXTRA_SDL2_LIBDIR}
|
||||
HINTS ${HINTS_SDL2_LIBDIR} ${PC_SDL2_LIBDIR} ${PC_SDL2_LIBRARY_DIRS}
|
||||
PATHS ${PATHS_SDL2_LIBDIR}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
Loading…
Reference in a new issue