2017-02-23 13:41:53 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2017-08-01 19:55:49 +00:00
|
|
|
|
|
|
|
file(STRINGS src/game/version.h VERSION_LINE
|
|
|
|
LIMIT_COUNT 1
|
|
|
|
REGEX GAME_RELEASE_VERSION
|
|
|
|
)
|
|
|
|
|
|
|
|
if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"")
|
|
|
|
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
set(VERSION_PATCH ${CMAKE_MATCH_3})
|
2018-01-14 14:04:18 +00:00
|
|
|
elseif(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\"")
|
|
|
|
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
set(VERSION_PATCH "0")
|
2017-08-01 19:55:49 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't parse version from src/game/version.h")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(POLICY CMP0048)
|
|
|
|
cmake_policy(SET CMP0048 NEW)
|
2018-01-14 14:31:31 +00:00
|
|
|
if(VERSION_PATCH STREQUAL "0")
|
|
|
|
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
|
|
|
else()
|
|
|
|
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
|
|
|
endif()
|
2017-08-01 19:55:49 +00:00
|
|
|
else()
|
|
|
|
project(DDNet)
|
|
|
|
set(PROJECT_VERSION_MAJOR ${VERSION_MAJOR})
|
|
|
|
set(PROJECT_VERSION_MINOR ${VERSION_MINOR})
|
|
|
|
set(PROJECT_VERSION_PATCH ${VERSION_PATCH})
|
2018-01-14 14:31:31 +00:00
|
|
|
if(VERSION_PATCH STREQUAL "0")
|
|
|
|
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
|
|
|
else()
|
|
|
|
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
|
|
|
endif()
|
2017-08-01 19:55:49 +00:00
|
|
|
endif()
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
set(ORIGINAL_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
|
|
|
|
set(ORIGINAL_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
|
|
|
|
set(ORIGINAL_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
|
|
|
set(OWN_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
|
|
|
set(CMAKE_MODULE_PATH ${OWN_CMAKE_MODULE_PATH})
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-07-31 16:30:24 +00:00
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(TARGET_BITS "64")
|
|
|
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
|
|
set(TARGET_BITS "32")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
set(TARGET_OS "windows")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
set(TARGET_OS "linux")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
set(TARGET_OS "mac")
|
|
|
|
endif()
|
|
|
|
|
2018-01-22 18:10:57 +00:00
|
|
|
include(CheckCCompilerFlag)
|
2018-01-22 18:32:30 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
2018-01-22 18:10:57 +00:00
|
|
|
include(CheckSymbolExists)
|
|
|
|
|
|
|
|
check_symbol_exists(__i386 "" TARGET_ARCH_X86_i386)
|
|
|
|
if(TARGET_ARCH_X86_i386)
|
|
|
|
set(TARGET_ARCH x86)
|
|
|
|
else()
|
|
|
|
set(TARGET_ARCH)
|
|
|
|
endif()
|
|
|
|
|
2017-10-15 08:25:26 +00:00
|
|
|
set(AUTO_DEPENDENCIES_DEFAULT OFF)
|
2017-07-31 16:30:24 +00:00
|
|
|
if(TARGET_OS STREQUAL "windows")
|
2017-10-15 08:25:26 +00:00
|
|
|
set(AUTO_DEPENDENCIES_DEFAULT ON)
|
2017-07-31 16:30:24 +00:00
|
|
|
endif()
|
|
|
|
|
2017-02-23 15:29:13 +00:00
|
|
|
option(WEBSOCKETS "Enable websockets support" OFF)
|
2017-03-01 12:40:11 +00:00
|
|
|
option(MYSQL "Enable mysql support" OFF)
|
2017-02-23 14:41:42 +00:00
|
|
|
option(CLIENT "Compile client" ON)
|
2017-10-15 08:25:26 +00:00
|
|
|
option(DOWNLOAD_GTEST "Download and compile GTest" ${AUTO_DEPENDENCIES_DEFAULT})
|
|
|
|
option(PREFER_BUNDLED_LIBS "Prefer bundled libraries over system libraries" ${AUTO_DEPENDENCIES_DEFAULT})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
|
|
|
# Set the default build type to Release
|
|
|
|
if(NOT(CMAKE_BUILD_TYPE))
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2017-11-23 02:10:25 +00:00
|
|
|
set(DBG $<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>)
|
2017-09-21 13:11:09 +00:00
|
|
|
|
2017-10-15 07:57:21 +00:00
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
|
|
|
|
src/game/version.h
|
|
|
|
)
|
|
|
|
|
2017-03-01 12:40:11 +00:00
|
|
|
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")
|
|
|
|
|
2018-01-22 18:10:57 +00:00
|
|
|
########################################################################
|
|
|
|
# Compiler flags
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
function(add_c_compiler_flag_if_supported VARIABLE FLAG)
|
|
|
|
if(ARGC GREATER 2)
|
|
|
|
set(CHECKED_FLAG "${ARGV2}")
|
|
|
|
else()
|
|
|
|
set(CHECKED_FLAG "${FLAG}")
|
|
|
|
endif()
|
|
|
|
string(REGEX REPLACE "[^A-Za-z0-9]" "_" CONFIG_VARIABLE "FLAG_SUPPORTED${CHECKED_FLAG}")
|
|
|
|
check_c_compiler_flag("${CHECKED_FLAG}" ${CONFIG_VARIABLE})
|
|
|
|
if(${CONFIG_VARIABLE})
|
|
|
|
if(${VARIABLE})
|
|
|
|
set("${VARIABLE}" "${${VARIABLE}};${FLAG}" PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set("${VARIABLE}" "${FLAG}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(NOT MSVC)
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac")
|
2018-01-22 18:48:17 +00:00
|
|
|
check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11)
|
|
|
|
if(FLAG_SUPPORTED_std_gnu__11)
|
|
|
|
if(CMAKE_CXX_FLAGS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS -std=gnu++11)
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-01-22 18:10:57 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Protect the stack pointer.
|
|
|
|
# -fstack-protector-all doesn't work on MinGW.
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS -fstack-protector-all)
|
|
|
|
|
|
|
|
# Inaccurate floating point numbers cause problems on mingw-w64-gcc when
|
|
|
|
# compiling for x86, might cause problems elsewhere. So don't store floats
|
|
|
|
# in registers but keep them at higher accuracy.
|
|
|
|
|
|
|
|
if(TARGET_ARCH STREQUAL "x86")
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS -ffloat-store)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET_OS STREQUAL "mac")
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS -stdlib=libc++)
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS -mmacosx-version-min=10.7)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wall)
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER 3.3 OR CMAKE_VERSION VERSION_EQUAL 3.3)
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN
|
|
|
|
$<$<COMPILE_LANGUAGE:C>:-Wdeclaration-after-statement>
|
|
|
|
-Wdeclaration-after-statement
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wextra)
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-unused-parameter)
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wno-missing-field-initializers)
|
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wformat=2) # Warn about format strings.
|
2018-02-12 20:29:43 +00:00
|
|
|
add_c_compiler_flag_if_supported(OUR_FLAGS_DEP -Wno-implicit-function-declaration)
|
2018-01-22 18:10:57 +00:00
|
|
|
endif()
|
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
if(NOT MSVC)
|
|
|
|
check_c_compiler_flag("-O2;-Wp,-Werror;-D_FORTIFY_SOURCE=2" DEFINE_FORTIFY_SOURCE) # Some distributions define _FORTIFY_SOURCE by themselves.
|
|
|
|
endif()
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# COMMON FUNCTIONS
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
function(set_glob VAR GLOBBING DIRECTORY) # ...
|
|
|
|
file(${GLOBBING} GLOB_RESULT "${DIRECTORY}/*.c" "${DIRECTORY}/*.cpp" "${DIRECTORY}/*.h")
|
|
|
|
list(SORT GLOB_RESULT)
|
|
|
|
set(FILES)
|
|
|
|
foreach(file ${ARGN})
|
|
|
|
list(APPEND FILES "${PROJECT_SOURCE_DIR}/${DIRECTORY}/${file}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(NOT FILES STREQUAL GLOB_RESULT)
|
|
|
|
message(AUTHOR_WARNING "${VAR} does not contain every file from directory ${DIRECTORY}")
|
|
|
|
set(LIST_BUT_NOT_GLOB)
|
|
|
|
if(POLICY CMP0057)
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
|
|
|
foreach(file ${FILES})
|
|
|
|
if(NOT file IN_LIST GLOB_RESULT)
|
|
|
|
list(APPEND LIST_BUT_NOT_GLOB ${file})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(LIST_BUT_NOT_GLOB)
|
|
|
|
message(AUTHOR_WARNING "Entries only present in ${VAR}: ${LIST_BUT_NOT_GLOB}")
|
|
|
|
endif()
|
|
|
|
set(GLOB_BUT_NOT_LIST)
|
|
|
|
foreach(file ${GLOB_RESULT})
|
|
|
|
if(NOT file IN_LIST FILES)
|
|
|
|
list(APPEND GLOB_BUT_NOT_LIST ${file})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(GLOB_BUT_NOT_LIST)
|
|
|
|
message(AUTHOR_WARNING "Entries only present in ${DIRECTORY}: ${GLOB_BUT_NOT_LIST}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${VAR} ${FILES} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# INITALIZE TARGET LISTS
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
set(TARGETS_OWN)
|
|
|
|
set(TARGETS_DEP)
|
|
|
|
|
|
|
|
set(TARGETS_LINK) # Targets with a linking stage.
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
########################################################################
|
|
|
|
# DEPENDENCIES
|
|
|
|
########################################################################
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-10-24 10:10:46 +00:00
|
|
|
function(set_extra_dirs_lib VARIABLE NAME)
|
2017-07-31 16:30:24 +00:00
|
|
|
set("PATHS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
|
|
|
set("HINTS_${VARIABLE}_LIBDIR" PARENT_SCOPE)
|
|
|
|
if(PREFER_BUNDLED_LIBS)
|
|
|
|
set(TYPE HINTS)
|
|
|
|
else()
|
|
|
|
set(TYPE PATHS)
|
|
|
|
endif()
|
2017-02-28 23:51:22 +00:00
|
|
|
if(TARGET_BITS AND TARGET_OS)
|
2017-07-31 16:30:24 +00:00
|
|
|
set(DIR "ddnet-libs/${NAME}/${TARGET_OS}/lib${TARGET_BITS}")
|
|
|
|
set("${TYPE}_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
|
|
|
|
set("EXTRA_${VARIABLE}_LIBDIR" "${DIR}" PARENT_SCOPE)
|
2017-02-28 23:51:22 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2017-10-24 10:10:46 +00:00
|
|
|
function(set_extra_dirs_include VARIABLE NAME LIBRARY)
|
|
|
|
set("PATHS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
|
|
|
set("HINTS_${VARIABLE}_INCLUDEDIR" PARENT_SCOPE)
|
2017-10-24 13:29:53 +00:00
|
|
|
is_bundled(IS_BUNDLED "${LIBRARY}")
|
|
|
|
if(IS_BUNDLED)
|
2017-10-25 14:57:25 +00:00
|
|
|
set("HINTS_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" "ddnet-libs/${NAME}/include/${TARGET_OS}" PARENT_SCOPE)
|
2017-10-24 13:29:53 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
if(CMAKE_CROSSCOMPILING)
|
|
|
|
set(CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PATH)
|
|
|
|
else()
|
|
|
|
set(CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH)
|
|
|
|
endif()
|
|
|
|
|
2017-10-24 13:29:53 +00:00
|
|
|
function(is_bundled VARIABLE PATH)
|
|
|
|
if(PATH)
|
|
|
|
string(FIND "${PATH}" "${PROJECT_SOURCE_DIR}" LOCAL_PATH_POS)
|
|
|
|
if(LOCAL_PATH_POS EQUAL 0 AND TARGET_BITS AND TARGET_OS)
|
|
|
|
set("${VARIABLE}" ON PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set("${VARIABLE}" OFF PARENT_SCOPE)
|
2017-10-24 10:10:46 +00:00
|
|
|
endif()
|
2017-10-24 13:29:53 +00:00
|
|
|
else()
|
|
|
|
set("${VARIABLE}" OFF PARENT_SCOPE)
|
2017-10-24 10:10:46 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2017-10-25 14:57:25 +00:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
# Check for PkgConfig once so all the other `find_package` calls can do it
|
|
|
|
# quietly.
|
|
|
|
find_package(PkgConfig)
|
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
find_package(ZLIB)
|
2017-02-23 13:16:32 +00:00
|
|
|
find_package(Curl)
|
|
|
|
find_package(Freetype)
|
2017-11-27 01:14:05 +00:00
|
|
|
if(DOWNLOAD_GTEST)
|
|
|
|
find_package(Git)
|
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
find_package(GLEW)
|
2017-08-30 19:57:55 +00:00
|
|
|
find_package(GTest)
|
2017-02-23 14:41:42 +00:00
|
|
|
if(MYSQL)
|
|
|
|
find_package(MySQL)
|
2017-03-02 10:46:00 +00:00
|
|
|
else()
|
|
|
|
set(MYSQL_LIBRARIES)
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
2017-02-28 23:51:22 +00:00
|
|
|
find_package(Ogg)
|
|
|
|
find_package(Opus)
|
2017-02-23 13:16:32 +00:00
|
|
|
find_package(Opusfile)
|
2018-02-12 22:14:14 +00:00
|
|
|
find_package(Pnglite)
|
2017-02-23 13:16:32 +00:00
|
|
|
find_package(PythonInterp)
|
|
|
|
find_package(SDL2)
|
|
|
|
find_package(Threads)
|
2018-02-12 22:14:14 +00:00
|
|
|
find_package(Wavpack)
|
2018-02-14 11:55:04 +00:00
|
|
|
if(WEBSOCKETS)
|
|
|
|
find_package(Websockets)
|
|
|
|
else()
|
|
|
|
set(WEBSOCKETS_LIBRARIES)
|
|
|
|
set(WEBSOCKETS_INCLUDE_DIRS)
|
|
|
|
endif()
|
|
|
|
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-11-08 23:16:52 +00:00
|
|
|
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
|
|
|
|
find_program(DMG dmg)
|
|
|
|
find_program(HFSPLUS hfsplus)
|
|
|
|
find_program(NEWFS_HFS newfs_hfs)
|
|
|
|
if(DMG AND HFSPLUS AND NEWFS_HFS)
|
|
|
|
set(DMGTOOLS_FOUND ON)
|
|
|
|
else()
|
|
|
|
set(DMGTOOLS_FOUND OFF)
|
|
|
|
endif()
|
2017-11-09 12:35:59 +00:00
|
|
|
|
|
|
|
find_program(HDIUTIL hdiutil)
|
2017-11-08 23:16:52 +00:00
|
|
|
endif()
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
message(STATUS "******** DDNet ********")
|
2017-07-26 02:30:56 +00:00
|
|
|
message(STATUS "Target OS: ${TARGET_OS} ${TARGET_BITS}bit")
|
2017-02-23 14:41:42 +00:00
|
|
|
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
|
2017-07-26 02:30:56 +00:00
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-02-28 23:51:22 +00:00
|
|
|
message(STATUS "Dependencies:")
|
2018-02-12 22:14:14 +00:00
|
|
|
function(show_dependency_status OUTPUT_NAME NAME)
|
|
|
|
if(${NAME}_FOUND)
|
|
|
|
if(${NAME}_BUNDLED)
|
|
|
|
message(STATUS " * ${OUTPUT_NAME} not found (using bundled version)")
|
2017-02-28 23:51:22 +00:00
|
|
|
else()
|
2018-02-12 22:14:14 +00:00
|
|
|
message(STATUS " * ${OUTPUT_NAME} found")
|
2017-02-28 23:51:22 +00:00
|
|
|
endif()
|
2017-02-23 14:41:42 +00:00
|
|
|
else()
|
2018-02-12 22:14:14 +00:00
|
|
|
message(STATUS " * ${OUTPUT_NAME} not found")
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Curl" CURL)
|
2017-11-08 23:16:52 +00:00
|
|
|
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Dmg tools" DMGTOOLS)
|
2017-11-08 23:16:52 +00:00
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Freetype" FREETYPE)
|
2017-11-27 01:14:05 +00:00
|
|
|
if(DOWNLOAD_GTEST)
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Git" GIT)
|
2017-11-27 01:14:05 +00:00
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Glew" GLEW)
|
|
|
|
show_dependency_status("GTest" GTEST)
|
2017-11-09 12:35:59 +00:00
|
|
|
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Hdiutil" HDIUTIL)
|
2017-11-09 12:35:59 +00:00
|
|
|
endif()
|
2017-02-23 14:41:42 +00:00
|
|
|
if(MYSQL)
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("MySQL" MYSQL)
|
2017-03-01 12:40:11 +00:00
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
show_dependency_status("Ogg" OGG)
|
|
|
|
show_dependency_status("Opus" OPUS)
|
|
|
|
show_dependency_status("Opusfile" OPUSFILE)
|
|
|
|
show_dependency_status("Pnglite" PNGLITE)
|
|
|
|
show_dependency_status("PythonInterp" PYTHONINTERP)
|
|
|
|
show_dependency_status("SDL2" SDL2)
|
|
|
|
show_dependency_status("Wavpack" WAVPACK)
|
|
|
|
show_dependency_status("Zlib" ZLIB)
|
2018-02-14 11:55:04 +00:00
|
|
|
if(WEBSOCKETS)
|
|
|
|
show_dependency_status("Websockets" WEBSOCKETS)
|
|
|
|
endif()
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-08-03 16:44:36 +00:00
|
|
|
if(NOT(PYTHONINTERP_FOUND))
|
|
|
|
message(SEND_ERROR "You must install Python to compile DDNet")
|
|
|
|
endif()
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
if(MYSQL AND NOT(MYSQL_FOUND))
|
2017-03-01 12:40:11 +00:00
|
|
|
message(SEND_ERROR "You must install MySQL to compile the DDNet server with MySQL support")
|
2017-02-23 14:02:23 +00:00
|
|
|
endif()
|
|
|
|
|
2018-02-14 11:55:04 +00:00
|
|
|
if(WEBSOCKETS AND NOT(WEBSOCKETS_FOUND))
|
|
|
|
message(SEND_ERROR "You must install libwebsockets to compile the DDNet server with websocket support")
|
|
|
|
endif()
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
if(CLIENT AND NOT(CURL_FOUND))
|
2017-02-28 23:51:22 +00:00
|
|
|
message(SEND_ERROR "You must install Curl to compile the DDNet client")
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
|
|
|
if(CLIENT AND NOT(FREETYPE_FOUND))
|
2017-02-28 23:51:22 +00:00
|
|
|
message(SEND_ERROR "You must install Freetype to compile the DDNet client")
|
|
|
|
endif()
|
|
|
|
if(CLIENT AND NOT(OGG_FOUND))
|
|
|
|
message(SEND_ERROR "You must install Ogg to compile the DDNet client")
|
|
|
|
endif()
|
|
|
|
if(CLIENT AND NOT(OPUS_FOUND))
|
|
|
|
message(SEND_ERROR "You must install Opus to compile the DDNet client")
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
|
|
|
if(CLIENT AND NOT(OPUSFILE_FOUND))
|
2017-02-28 23:51:22 +00:00
|
|
|
message(SEND_ERROR "You must install Opusfile to compile the DDNet client")
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
|
|
|
if(CLIENT AND NOT(SDL2_FOUND))
|
2017-02-28 23:51:22 +00:00
|
|
|
message(SEND_ERROR "You must install SDL2 to compile the DDNet client")
|
2017-02-23 14:41:42 +00:00
|
|
|
endif()
|
2017-08-30 19:57:55 +00:00
|
|
|
if(NOT(GTEST_FOUND))
|
2017-10-15 07:57:21 +00:00
|
|
|
if(DOWNLOAD_GTEST)
|
2017-11-27 01:14:05 +00:00
|
|
|
if(GIT_FOUND)
|
|
|
|
message(STATUS "Automatically downloading GTest to be able to run tests")
|
|
|
|
else()
|
|
|
|
set(DOWNLOAD_GTEST OFF)
|
|
|
|
message(WARNING "To automatically download GTest, you have to install Git")
|
|
|
|
endif()
|
2017-10-15 07:57:21 +00:00
|
|
|
else()
|
|
|
|
message(STATUS "To run the tests, you have to install GTest")
|
|
|
|
endif()
|
2017-08-30 19:57:55 +00:00
|
|
|
endif()
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
if(TARGET_OS STREQUAL "windows")
|
2017-07-26 02:30:56 +00:00
|
|
|
set(PLATFORM_CLIENT)
|
2017-03-03 14:04:13 +00:00
|
|
|
set(PLATFORM_CLIENT_LIBS opengl32 glu32 winmm)
|
|
|
|
set(PLATFORM_LIBS ws2_32) # Windows sockets
|
2017-07-26 02:30:56 +00:00
|
|
|
elseif(TARGET_OS STREQUAL "mac")
|
|
|
|
find_library(CARBON Carbon)
|
|
|
|
find_library(COCOA Cocoa)
|
|
|
|
find_library(OPENGL OpenGL)
|
2017-09-16 09:39:09 +00:00
|
|
|
find_library(SECURITY Security)
|
2017-07-26 02:30:56 +00:00
|
|
|
set(PLATFORM_CLIENT
|
|
|
|
src/osx/notification.h
|
|
|
|
src/osx/notification.mm
|
|
|
|
src/osxlaunch/client.h
|
|
|
|
src/osxlaunch/client.m
|
|
|
|
)
|
2017-09-16 09:39:09 +00:00
|
|
|
set(PLATFORM_CLIENT_LIBS ${COCOA} ${OPENGL} ${SECURITY})
|
2017-07-26 02:30:56 +00:00
|
|
|
set(PLATFORM_LIBS ${CARBON})
|
2017-03-03 14:04:13 +00:00
|
|
|
else()
|
2017-07-26 02:30:56 +00:00
|
|
|
set(PLATFORM_CLIENT)
|
2017-03-03 14:04:13 +00:00
|
|
|
set(PLATFORM_CLIENT_LIBS GL GLU X11)
|
2017-03-18 00:20:55 +00:00
|
|
|
if(TARGET_OS STREQUAL "linux")
|
|
|
|
set(PLATFORM_LIBS rt) # clock_gettime for glibc < 2.17
|
|
|
|
else()
|
|
|
|
set(PLATFORM_LIBS)
|
|
|
|
endif()
|
2017-03-03 14:04:13 +00:00
|
|
|
endif()
|
|
|
|
|
2017-10-15 07:57:21 +00:00
|
|
|
########################################################################
|
|
|
|
# DOWNLOAD GTEST
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
if(NOT(GTEST_FOUND) AND DOWNLOAD_GTEST)
|
|
|
|
# Change to the 1.9.0 release tag once that works.
|
|
|
|
set(DDNET_GTEST_VERSION 7b6561c56e353100aca8458d7bc49c4e0119bae8)
|
|
|
|
configure_file(cmake/Download_GTest_CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
|
|
RESULT_VARIABLE result
|
2018-02-12 22:14:14 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
|
2017-10-15 07:57:21 +00:00
|
|
|
)
|
2017-11-27 01:14:05 +00:00
|
|
|
if(result)
|
|
|
|
message(WARNING "CMake step for googletest failed: ${result}")
|
|
|
|
set(DOWNLOAD_GTEST OFF)
|
|
|
|
else()
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
|
|
RESULT_VARIABLE result
|
2018-02-12 22:14:14 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/googletest-download
|
2017-11-27 01:14:05 +00:00
|
|
|
)
|
|
|
|
if(result)
|
|
|
|
message(WARNING "Build step for googletest failed: ${result}")
|
|
|
|
set(DOWNLOAD_GTEST OFF)
|
|
|
|
else()
|
|
|
|
# Prevent overriding the parent project's compiler/linker settings on Windows
|
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
|
|
|
|
|
|
# Add googletest directly to our build. This defines the gtest target.
|
|
|
|
add_subdirectory(
|
2018-02-12 22:14:14 +00:00
|
|
|
${PROJECT_BINARY_DIR}/googletest-src
|
|
|
|
${PROJECT_BINARY_DIR}/googletest-build
|
2017-11-27 01:14:05 +00:00
|
|
|
EXCLUDE_FROM_ALL
|
|
|
|
)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
foreach(target gtest)
|
2018-01-05 14:59:06 +00:00
|
|
|
# `/w` disables all warnings. This is needed because `gtest` enables
|
|
|
|
# `/WX` (equivalent of `-Werror`) for some reason, breaking builds
|
|
|
|
# when MSVS adds new warnings.
|
|
|
|
target_compile_options(${target} PRIVATE $<$<NOT:${DBG}>:/MT> $<${DBG}:/MTd> /w)
|
2017-11-27 01:14:05 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(GTEST_LIBRARIES gtest)
|
|
|
|
set(GTEST_INCLUDE_DIRS)
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 2.8.11)
|
|
|
|
set(GTEST_INCLUDE_DIRS "${gtest_SOURCE_DIR}/include")
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-10-15 07:57:21 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2017-03-07 15:47:27 +00:00
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
########################################################################
|
|
|
|
# DEPENDENCY COMPILATION
|
|
|
|
########################################################################
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
if(CLIENT)
|
|
|
|
# Static dependencies
|
2018-02-12 22:14:14 +00:00
|
|
|
set_glob(JSON_SRC GLOB src/engine/external/json-parser json.c json.h)
|
|
|
|
add_library(json EXCLUDE_FROM_ALL OBJECT ${JSON_SRC})
|
2017-03-03 14:04:13 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
list(APPEND TARGETS_DEP json)
|
|
|
|
set(JSON_DEP $<TARGET_OBJECTS:json>)
|
2017-03-02 11:31:20 +00:00
|
|
|
endif()
|
|
|
|
|
2017-03-07 14:24:08 +00:00
|
|
|
########################################################################
|
|
|
|
# COPY DATA AND DLLS
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
file(COPY data DESTINATION .)
|
2017-08-01 19:55:49 +00:00
|
|
|
set(COPY_FILES
|
|
|
|
${CURL_COPY_FILES}
|
|
|
|
${FREETYPE_COPY_FILES}
|
|
|
|
${OPUSFILE_COPY_FILES}
|
|
|
|
${SDL2_COPY_FILES}
|
|
|
|
)
|
|
|
|
file(COPY ${COPY_FILES} DESTINATION .)
|
2017-03-07 14:24:08 +00:00
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
########################################################################
|
|
|
|
# CODE GENERATION
|
|
|
|
########################################################################
|
|
|
|
|
2017-02-23 13:16:32 +00:00
|
|
|
function(generate_source output_file script_parameter)
|
2018-02-05 19:22:54 +00:00
|
|
|
add_custom_command(OUTPUT ${output_file}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} datasrc/compile.py ${script_parameter}
|
|
|
|
> "${PROJECT_BINARY_DIR}/${output_file}"
|
2017-02-23 13:16:32 +00:00
|
|
|
DEPENDS
|
|
|
|
datasrc/compile.py
|
|
|
|
datasrc/content.py
|
|
|
|
datasrc/datatypes.py
|
|
|
|
datasrc/network.py
|
2017-03-03 12:29:35 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
2017-02-23 13:16:32 +00:00
|
|
|
)
|
2017-10-25 14:57:25 +00:00
|
|
|
endfunction()
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/game/generated/")
|
2018-03-01 15:50:29 +00:00
|
|
|
execute_process(COMMAND git rev-parse --git-dir
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_VARIABLE PROJECT_GIT_DIR
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE PROJECT_GIT_DIR_ERROR
|
|
|
|
)
|
|
|
|
if(NOT PROJECT_GIT_DIR_ERROR)
|
|
|
|
set(GIT_REVISION_EXTRA_DEPS
|
|
|
|
${PROJECT_GIT_DIR}/index
|
|
|
|
${PROJECT_GIT_DIR}/logs/HEAD
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT src/game/generated/git_revision.cpp
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
|
|
${PROJECT_SOURCE_DIR}/scripts/git_revision.py
|
|
|
|
> src/game/generated/git_revision.cpp
|
|
|
|
DEPENDS
|
|
|
|
${GIT_REVISION_EXTRA_DEPS}
|
|
|
|
scripts/git_revision.py
|
2017-02-23 13:16:32 +00:00
|
|
|
)
|
2017-02-23 15:29:13 +00:00
|
|
|
generate_source("src/game/generated/client_data.cpp" "client_content_source")
|
|
|
|
generate_source("src/game/generated/client_data.h" "client_content_header")
|
2017-02-23 13:16:32 +00:00
|
|
|
generate_source("src/game/generated/protocol.cpp" "network_source")
|
|
|
|
generate_source("src/game/generated/protocol.h" "network_header")
|
|
|
|
generate_source("src/game/generated/server_data.cpp" "server_content_source")
|
|
|
|
generate_source("src/game/generated/server_data.h" "server_content_header")
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# SHARED
|
|
|
|
########################################################################
|
|
|
|
|
2017-03-01 12:40:11 +00:00
|
|
|
# Sources
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(BASE GLOB_RECURSE src/base
|
|
|
|
color.h
|
|
|
|
confusables.c
|
|
|
|
confusables_data.h
|
|
|
|
detect.h
|
|
|
|
math.h
|
|
|
|
system.c
|
|
|
|
system.h
|
|
|
|
tl/algorithm.h
|
|
|
|
tl/allocator.h
|
|
|
|
tl/array.h
|
|
|
|
tl/base.h
|
|
|
|
tl/range.h
|
|
|
|
tl/sorted_array.h
|
|
|
|
tl/string.h
|
|
|
|
tl/threading.h
|
|
|
|
vmath.h
|
|
|
|
)
|
2017-11-27 00:16:11 +00:00
|
|
|
set_glob(ENGINE_INTERFACE GLOB src/engine
|
|
|
|
client.h
|
|
|
|
config.h
|
|
|
|
console.h
|
|
|
|
demo.h
|
|
|
|
editor.h
|
|
|
|
engine.h
|
|
|
|
friends.h
|
|
|
|
ghost.h
|
|
|
|
graphics.h
|
|
|
|
input.h
|
|
|
|
kernel.h
|
|
|
|
keys.h
|
|
|
|
map.h
|
|
|
|
masterserver.h
|
|
|
|
message.h
|
|
|
|
server.h
|
|
|
|
serverbrowser.h
|
|
|
|
sound.h
|
|
|
|
storage.h
|
|
|
|
textrender.h
|
|
|
|
updater.h
|
|
|
|
uuid.h
|
|
|
|
)
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(ENGINE_SHARED GLOB src/engine/shared
|
|
|
|
compression.cpp
|
|
|
|
compression.h
|
|
|
|
config.cpp
|
|
|
|
config.h
|
|
|
|
config_variables.h
|
|
|
|
console.cpp
|
|
|
|
console.h
|
|
|
|
datafile.cpp
|
|
|
|
datafile.h
|
|
|
|
demo.cpp
|
|
|
|
demo.h
|
|
|
|
econ.cpp
|
|
|
|
econ.h
|
|
|
|
engine.cpp
|
|
|
|
fifo.cpp
|
|
|
|
fifo.h
|
|
|
|
filecollection.cpp
|
|
|
|
filecollection.h
|
2017-09-09 00:41:11 +00:00
|
|
|
ghost.cpp
|
|
|
|
ghost.h
|
2017-07-27 14:13:28 +00:00
|
|
|
global_uuid_manager.cpp
|
|
|
|
huffman.cpp
|
|
|
|
huffman.h
|
|
|
|
jobs.cpp
|
|
|
|
jobs.h
|
|
|
|
kernel.cpp
|
|
|
|
linereader.cpp
|
|
|
|
linereader.h
|
|
|
|
map.cpp
|
|
|
|
masterserver.cpp
|
|
|
|
memheap.cpp
|
|
|
|
memheap.h
|
|
|
|
message.h
|
|
|
|
netban.cpp
|
|
|
|
netban.h
|
|
|
|
network.cpp
|
|
|
|
network.h
|
|
|
|
network_client.cpp
|
|
|
|
network_conn.cpp
|
|
|
|
network_console.cpp
|
|
|
|
network_console_conn.cpp
|
|
|
|
network_server.cpp
|
|
|
|
packer.cpp
|
|
|
|
packer.h
|
|
|
|
protocol.h
|
|
|
|
protocol_ex.cpp
|
|
|
|
protocol_ex.h
|
|
|
|
protocol_ex_msgs.h
|
|
|
|
ringbuffer.cpp
|
|
|
|
ringbuffer.h
|
|
|
|
serverbrowser.cpp
|
|
|
|
snapshot.cpp
|
|
|
|
snapshot.h
|
|
|
|
storage.cpp
|
2018-01-11 15:01:13 +00:00
|
|
|
teehistorian_ex.cpp
|
|
|
|
teehistorian_ex.h
|
|
|
|
teehistorian_ex_chunks.h
|
2017-07-27 14:13:28 +00:00
|
|
|
uuid_manager.cpp
|
|
|
|
uuid_manager.h
|
|
|
|
websockets.cpp
|
|
|
|
websockets.h
|
|
|
|
)
|
|
|
|
set(ENGINE_GENERATED_SHARED src/game/generated/protocol.cpp src/game/generated/protocol.h)
|
|
|
|
set_glob(GAME_SHARED GLOB src/game
|
|
|
|
collision.cpp
|
|
|
|
collision.h
|
|
|
|
ddracecommands.h
|
|
|
|
extrainfo.cpp
|
|
|
|
extrainfo.h
|
|
|
|
gamecore.cpp
|
|
|
|
gamecore.h
|
|
|
|
layers.cpp
|
|
|
|
layers.h
|
|
|
|
localization.cpp
|
|
|
|
localization.h
|
|
|
|
mapitems.cpp
|
|
|
|
mapitems.h
|
|
|
|
teamscore.cpp
|
|
|
|
teamscore.h
|
|
|
|
tuning.h
|
|
|
|
variables.h
|
|
|
|
version.h
|
|
|
|
voting.h
|
|
|
|
)
|
2018-03-02 02:42:35 +00:00
|
|
|
set(GAME_GENERATED_SHARED
|
|
|
|
src/game/generated/git_revision.cpp
|
|
|
|
src/game/generated/protocol.h
|
|
|
|
)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
# Static dependencies
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(DEP_MD5_SRC GLOB src/engine/external/md5 md5.c md5.h)
|
2017-03-03 14:17:12 +00:00
|
|
|
add_library(md5 EXCLUDE_FROM_ALL OBJECT ${DEP_MD5_SRC})
|
2017-03-03 14:04:13 +00:00
|
|
|
set(DEP_MD5 $<TARGET_OBJECTS:md5>)
|
2017-03-12 15:19:23 +00:00
|
|
|
list(APPEND TARGETS_DEP md5)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2018-02-14 11:55:04 +00:00
|
|
|
set(DEPS ${DEP_MD5} ${ZLIB_DEP})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
|
|
|
# Libraries
|
2018-02-14 11:55:04 +00:00
|
|
|
set(LIBS ${CMAKE_THREAD_LIBS_INIT} ${WEBSOCKETS_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_LIBS})
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
# Targets
|
2017-11-27 00:16:11 +00:00
|
|
|
add_library(engine-shared EXCLUDE_FROM_ALL OBJECT ${ENGINE_INTERFACE} ${ENGINE_SHARED} ${ENGINE_GENERATED_SHARED} ${BASE})
|
2017-03-03 14:17:12 +00:00
|
|
|
add_library(game-shared EXCLUDE_FROM_ALL OBJECT ${GAME_SHARED} ${GAME_GENERATED_SHARED})
|
2017-03-03 14:04:13 +00:00
|
|
|
list(APPEND TARGETS_OWN engine-shared game-shared)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
########################################################################
|
|
|
|
# CLIENT
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
if(CLIENT)
|
|
|
|
# Sources
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(ENGINE_CLIENT GLOB src/engine/client
|
|
|
|
backend_sdl.cpp
|
|
|
|
backend_sdl.h
|
|
|
|
client.cpp
|
|
|
|
client.h
|
|
|
|
fetcher.cpp
|
|
|
|
fetcher.h
|
|
|
|
friends.cpp
|
|
|
|
friends.h
|
|
|
|
graphics_threaded.cpp
|
|
|
|
graphics_threaded.h
|
|
|
|
input.cpp
|
|
|
|
input.h
|
|
|
|
keynames.h
|
2017-09-16 16:58:24 +00:00
|
|
|
opengl_sl.cpp
|
|
|
|
opengl_sl.h
|
|
|
|
opengl_sl_program.cpp
|
|
|
|
opengl_sl_program.h
|
2017-07-27 14:13:28 +00:00
|
|
|
serverbrowser.cpp
|
|
|
|
serverbrowser.h
|
|
|
|
sound.cpp
|
|
|
|
sound.h
|
|
|
|
text.cpp
|
|
|
|
updater.cpp
|
|
|
|
updater.h
|
|
|
|
)
|
|
|
|
set_glob(GAME_CLIENT GLOB_RECURSE src/game/client
|
|
|
|
animstate.cpp
|
|
|
|
animstate.h
|
|
|
|
component.h
|
|
|
|
components/background.cpp
|
|
|
|
components/background.h
|
|
|
|
components/binds.cpp
|
|
|
|
components/binds.h
|
|
|
|
components/broadcast.cpp
|
|
|
|
components/broadcast.h
|
|
|
|
components/camera.cpp
|
|
|
|
components/camera.h
|
|
|
|
components/chat.cpp
|
|
|
|
components/chat.h
|
|
|
|
components/console.cpp
|
|
|
|
components/console.h
|
|
|
|
components/controls.cpp
|
|
|
|
components/controls.h
|
|
|
|
components/countryflags.cpp
|
|
|
|
components/countryflags.h
|
|
|
|
components/damageind.cpp
|
|
|
|
components/damageind.h
|
|
|
|
components/debughud.cpp
|
|
|
|
components/debughud.h
|
|
|
|
components/effects.cpp
|
|
|
|
components/effects.h
|
|
|
|
components/emoticon.cpp
|
|
|
|
components/emoticon.h
|
|
|
|
components/flow.cpp
|
|
|
|
components/flow.h
|
|
|
|
components/ghost.cpp
|
|
|
|
components/ghost.h
|
|
|
|
components/hud.cpp
|
|
|
|
components/hud.h
|
|
|
|
components/items.cpp
|
|
|
|
components/items.h
|
|
|
|
components/killmessages.cpp
|
|
|
|
components/killmessages.h
|
|
|
|
components/mapimages.cpp
|
|
|
|
components/mapimages.h
|
|
|
|
components/maplayers.cpp
|
|
|
|
components/maplayers.h
|
|
|
|
components/mapsounds.cpp
|
|
|
|
components/mapsounds.h
|
|
|
|
components/menus.cpp
|
|
|
|
components/menus.h
|
|
|
|
components/menus_browser.cpp
|
|
|
|
components/menus_demo.cpp
|
|
|
|
components/menus_ingame.cpp
|
|
|
|
components/menus_settings.cpp
|
|
|
|
components/motd.cpp
|
|
|
|
components/motd.h
|
|
|
|
components/nameplates.cpp
|
|
|
|
components/nameplates.h
|
|
|
|
components/particles.cpp
|
|
|
|
components/particles.h
|
|
|
|
components/players.cpp
|
|
|
|
components/players.h
|
|
|
|
components/race_demo.cpp
|
|
|
|
components/race_demo.h
|
|
|
|
components/scoreboard.cpp
|
|
|
|
components/scoreboard.h
|
|
|
|
components/skins.cpp
|
|
|
|
components/skins.h
|
|
|
|
components/sounds.cpp
|
|
|
|
components/sounds.h
|
|
|
|
components/spectator.cpp
|
|
|
|
components/spectator.h
|
|
|
|
components/statboard.cpp
|
|
|
|
components/statboard.h
|
|
|
|
components/voting.cpp
|
|
|
|
components/voting.h
|
|
|
|
gameclient.cpp
|
|
|
|
gameclient.h
|
|
|
|
lineinput.cpp
|
|
|
|
lineinput.h
|
2017-10-06 20:10:29 +00:00
|
|
|
race.cpp
|
|
|
|
race.h
|
2017-07-27 14:13:28 +00:00
|
|
|
render.cpp
|
|
|
|
render.h
|
|
|
|
render_map.cpp
|
|
|
|
ui.cpp
|
|
|
|
ui.h
|
|
|
|
)
|
|
|
|
set_glob(GAME_EDITOR GLOB src/game/editor
|
|
|
|
auto_map.cpp
|
|
|
|
auto_map.h
|
|
|
|
editor.cpp
|
|
|
|
editor.h
|
|
|
|
io.cpp
|
|
|
|
layer_game.cpp
|
|
|
|
layer_quads.cpp
|
|
|
|
layer_sounds.cpp
|
|
|
|
layer_tiles.cpp
|
|
|
|
popups.cpp
|
|
|
|
)
|
|
|
|
set(GAME_GENERATED_CLIENT
|
|
|
|
src/game/generated/client_data.cpp
|
|
|
|
src/game/generated/client_data.h
|
|
|
|
)
|
2017-07-26 02:30:56 +00:00
|
|
|
set(CLIENT_SRC ${ENGINE_CLIENT} ${PLATFORM_CLIENT} ${GAME_CLIENT} ${GAME_EDITOR} ${GAME_GENERATED_CLIENT})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
set(DEPS_CLIENT ${DEPS} ${GLEW_DEP} ${JSON_DEP} ${PNGLITE_DEP} ${WAVPACK_DEP})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
|
|
|
# Libraries
|
|
|
|
set(LIBS_CLIENT
|
2017-03-01 12:40:11 +00:00
|
|
|
${LIBS}
|
2017-02-23 14:41:42 +00:00
|
|
|
${CURL_LIBRARIES}
|
|
|
|
${FREETYPE_LIBRARIES}
|
2018-02-12 22:14:14 +00:00
|
|
|
${GLEW_LIBRARIES}
|
|
|
|
${PNGLITE_LIBRARIES}
|
2017-03-18 00:20:55 +00:00
|
|
|
${SDL2_LIBRARIES}
|
2018-02-12 22:14:14 +00:00
|
|
|
${WAVPACK_LIBRARIES}
|
2017-03-18 00:20:55 +00:00
|
|
|
|
|
|
|
# Order of these three is important.
|
2017-02-23 14:41:42 +00:00
|
|
|
${OPUSFILE_LIBRARIES}
|
2017-03-07 12:39:23 +00:00
|
|
|
${OPUS_LIBRARIES}
|
2017-03-18 00:20:55 +00:00
|
|
|
${OGG_LIBRARIES}
|
|
|
|
|
2017-03-02 11:31:20 +00:00
|
|
|
${PLATFORM_CLIENT_LIBS}
|
2017-02-23 14:41:42 +00:00
|
|
|
)
|
2017-02-23 13:16:32 +00:00
|
|
|
|
2017-03-18 00:45:50 +00:00
|
|
|
if(TARGET_OS STREQUAL "windows")
|
2017-08-01 19:43:56 +00:00
|
|
|
set(CLIENT_ICON "other/icons/DDNet.rc")
|
2017-10-23 11:58:44 +00:00
|
|
|
if(NOT MINGW)
|
|
|
|
set(CLIENT_MANIFEST "other/manifest/DDNet.manifest")
|
|
|
|
else()
|
|
|
|
set(CLIENT_MANIFEST "other/manifest/DDNet.rc")
|
2017-10-22 16:32:04 +00:00
|
|
|
endif()
|
2017-03-18 00:45:50 +00:00
|
|
|
else()
|
|
|
|
set(CLIENT_ICON)
|
2017-10-22 16:06:20 +00:00
|
|
|
set(CLIENT_MANIFEST)
|
2017-03-18 00:45:50 +00:00
|
|
|
endif()
|
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
# Target
|
2017-03-01 12:40:11 +00:00
|
|
|
set(TARGET_CLIENT ${CLIENT_EXECUTABLE})
|
|
|
|
add_executable(${TARGET_CLIENT}
|
|
|
|
${CLIENT_SRC}
|
2017-03-18 00:45:50 +00:00
|
|
|
${CLIENT_ICON}
|
2017-10-22 16:06:20 +00:00
|
|
|
${CLIENT_MANIFEST}
|
2017-03-01 12:40:11 +00:00
|
|
|
${DEPS_CLIENT}
|
|
|
|
$<TARGET_OBJECTS:engine-shared>
|
|
|
|
$<TARGET_OBJECTS:game-shared>
|
|
|
|
)
|
|
|
|
target_link_libraries(${TARGET_CLIENT} ${LIBS_CLIENT})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-02-28 23:51:22 +00:00
|
|
|
target_include_directories(${TARGET_CLIENT} PRIVATE
|
|
|
|
${CURL_INCLUDE_DIRS}
|
|
|
|
${FREETYPE_INCLUDE_DIRS}
|
2018-02-12 22:14:14 +00:00
|
|
|
${GLEW_INCLUDE_DIRS}
|
2017-02-28 23:51:22 +00:00
|
|
|
${OGG_INCLUDE_DIRS}
|
|
|
|
${OPUSFILE_INCLUDE_DIRS}
|
|
|
|
${OPUS_INCLUDE_DIRS}
|
2018-02-12 22:14:14 +00:00
|
|
|
${PNGLITE_INCLUDE_DIRS}
|
2017-02-28 23:51:22 +00:00
|
|
|
${SDL2_INCLUDE_DIRS}
|
2018-02-12 22:14:14 +00:00
|
|
|
${WAVPACK_INCLUDE_DIRS}
|
2017-02-28 23:51:22 +00:00
|
|
|
)
|
2018-02-12 22:14:14 +00:00
|
|
|
|
2018-02-20 16:10:52 +00:00
|
|
|
set(PARAMS "${WAVPACK_INCLUDE_DIRS};${WAVPACK_INCLUDE_DIRS}")
|
|
|
|
if(NOT(WAVPACK_OPEN_FILE_INPUT_EX_PARAMS STREQUAL PARAMS))
|
|
|
|
unset(WAVPACK_OPEN_FILE_INPUT_EX CACHE)
|
|
|
|
endif()
|
|
|
|
set(WAVPACK_OPEN_FILE_INPUT_EX_PARAMS "${PARAMS}" CACHE INTERNAL "")
|
|
|
|
|
2018-02-17 00:31:40 +00:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${ORIGINAL_CMAKE_REQUIRED_INCLUDES} ${WAVPACK_INCLUDE_DIRS})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${ORIGINAL_CMAKE_REQUIRED_LIBRARIES} ${WAVPACK_LIBRARIES})
|
2018-02-18 14:35:20 +00:00
|
|
|
check_symbol_exists(WavpackOpenFileInputEx wavpack.h WAVPACK_OPEN_FILE_INPUT_EX)
|
2018-02-17 00:31:40 +00:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${ORIGINAL_CMAKE_REQUIRED_INCLUDES})
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${ORIGINAL_CMAKE_REQUIRED_LIBRARIES})
|
|
|
|
|
2018-02-18 14:35:20 +00:00
|
|
|
if(WAVPACK_OPEN_FILE_INPUT_EX)
|
|
|
|
target_compile_definitions(${TARGET_CLIENT} PRIVATE CONF_WAVPACK_OPEN_FILE_INPUT_EX)
|
2018-02-12 22:14:14 +00:00
|
|
|
endif()
|
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
list(APPEND TARGETS_OWN ${TARGET_CLIENT})
|
2017-07-26 02:30:56 +00:00
|
|
|
list(APPEND TARGETS_LINK ${TARGET_CLIENT})
|
2017-02-23 13:16:32 +00:00
|
|
|
endif()
|
|
|
|
|
2017-03-07 14:32:11 +00:00
|
|
|
|
2017-02-23 14:41:42 +00:00
|
|
|
########################################################################
|
|
|
|
# SERVER
|
|
|
|
########################################################################
|
|
|
|
|
2017-03-01 12:40:11 +00:00
|
|
|
# Sources
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(ENGINE_SERVER GLOB src/engine/server
|
|
|
|
authmanager.cpp
|
|
|
|
authmanager.h
|
|
|
|
register.cpp
|
|
|
|
register.h
|
|
|
|
server.cpp
|
|
|
|
server.h
|
|
|
|
sql_connector.cpp
|
|
|
|
sql_connector.h
|
|
|
|
sql_server.cpp
|
|
|
|
sql_server.h
|
|
|
|
sql_string_helpers.cpp
|
|
|
|
sql_string_helpers.h
|
|
|
|
)
|
|
|
|
set_glob(GAME_SERVER GLOB_RECURSE src/game/server
|
|
|
|
ddracechat.cpp
|
|
|
|
ddracechat.h
|
|
|
|
ddracecommands.cpp
|
|
|
|
entities/character.cpp
|
|
|
|
entities/character.h
|
|
|
|
entities/door.cpp
|
|
|
|
entities/door.h
|
|
|
|
entities/dragger.cpp
|
|
|
|
entities/dragger.h
|
|
|
|
entities/flag.cpp
|
|
|
|
entities/flag.h
|
|
|
|
entities/gun.cpp
|
|
|
|
entities/gun.h
|
|
|
|
entities/laser.cpp
|
|
|
|
entities/laser.h
|
|
|
|
entities/light.cpp
|
|
|
|
entities/light.h
|
|
|
|
entities/pickup.cpp
|
|
|
|
entities/pickup.h
|
|
|
|
entities/plasma.cpp
|
|
|
|
entities/plasma.h
|
|
|
|
entities/projectile.cpp
|
|
|
|
entities/projectile.h
|
|
|
|
entity.cpp
|
|
|
|
entity.h
|
|
|
|
eventhandler.cpp
|
|
|
|
eventhandler.h
|
|
|
|
gamecontext.cpp
|
|
|
|
gamecontext.h
|
|
|
|
gamecontroller.cpp
|
|
|
|
gamecontroller.h
|
|
|
|
gamemodes/DDRace.cpp
|
|
|
|
gamemodes/DDRace.h
|
|
|
|
gamemodes/gamemode.h
|
|
|
|
gameworld.cpp
|
|
|
|
gameworld.h
|
|
|
|
player.cpp
|
|
|
|
player.h
|
|
|
|
save.cpp
|
|
|
|
save.h
|
|
|
|
score.h
|
|
|
|
score/file_score.cpp
|
|
|
|
score/file_score.h
|
|
|
|
score/sql_score.cpp
|
|
|
|
score/sql_score.h
|
|
|
|
teams.cpp
|
|
|
|
teams.h
|
2017-09-12 12:58:44 +00:00
|
|
|
teehistorian.cpp
|
|
|
|
teehistorian.h
|
2017-07-27 14:13:28 +00:00
|
|
|
)
|
|
|
|
set(GAME_GENERATED_SERVER
|
|
|
|
"src/game/generated/server_data.cpp"
|
|
|
|
"src/game/generated/server_data.h"
|
|
|
|
)
|
2017-03-01 12:40:11 +00:00
|
|
|
set(SERVER_SRC ${ENGINE_SERVER} ${GAME_SERVER} ${GAME_GENERATED_SERVER})
|
2017-03-18 00:45:50 +00:00
|
|
|
if(TARGET_OS STREQUAL "windows")
|
2017-08-01 19:43:56 +00:00
|
|
|
set(SERVER_ICON "other/icons/DDNet-Server.rc")
|
2017-03-18 00:45:50 +00:00
|
|
|
else()
|
|
|
|
set(SERVER_ICON)
|
|
|
|
endif()
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-03-01 12:40:11 +00:00
|
|
|
# Libraries
|
2017-06-09 17:34:01 +00:00
|
|
|
set(LIBS_SERVER ${LIBS} ${MYSQL_LIBRARIES})
|
2017-03-01 12:40:11 +00:00
|
|
|
|
|
|
|
# Target
|
|
|
|
set(TARGET_SERVER ${SERVER_EXECUTABLE})
|
|
|
|
add_executable(${TARGET_SERVER}
|
2017-03-03 14:04:13 +00:00
|
|
|
${DEPS}
|
2017-03-01 12:40:11 +00:00
|
|
|
${SERVER_SRC}
|
2017-03-18 00:45:50 +00:00
|
|
|
${SERVER_ICON}
|
2017-03-01 12:40:11 +00:00
|
|
|
$<TARGET_OBJECTS:engine-shared>
|
|
|
|
$<TARGET_OBJECTS:game-shared>
|
|
|
|
)
|
|
|
|
target_link_libraries(${TARGET_SERVER} ${LIBS_SERVER})
|
2017-03-03 14:04:13 +00:00
|
|
|
list(APPEND TARGETS_OWN ${TARGET_SERVER})
|
2017-07-26 02:30:56 +00:00
|
|
|
list(APPEND TARGETS_LINK ${TARGET_SERVER})
|
2017-02-23 14:41:42 +00:00
|
|
|
|
2017-11-17 13:37:29 +00:00
|
|
|
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
|
|
|
|
set(SERVER_LAUNCHER_SRC src/osxlaunch/server.mm)
|
|
|
|
set(TARGET_SERVER_LAUNCHER ${TARGET_SERVER}-Launcher)
|
|
|
|
add_executable(${TARGET_SERVER_LAUNCHER} ${SERVER_LAUNCHER_SRC})
|
|
|
|
target_link_libraries(${TARGET_SERVER_LAUNCHER} ${COCOA})
|
|
|
|
list(APPEND TARGETS_OWN ${TARGET_SERVER_LAUNCHER})
|
|
|
|
list(APPEND TARGETS_LINK ${TARGET_SERVER_LAUNCHER})
|
|
|
|
endif()
|
|
|
|
|
2017-03-01 12:40:11 +00:00
|
|
|
########################################################################
|
|
|
|
# VARIOUS TARGETS
|
|
|
|
########################################################################
|
|
|
|
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(MASTERSRV_SRC GLOB src/mastersrv mastersrv.cpp mastersrv.h)
|
|
|
|
set_glob(TWPING_SRC GLOB src/twping twping.cpp)
|
2017-03-01 12:40:11 +00:00
|
|
|
|
|
|
|
set(TARGET_MASTERSRV mastersrv)
|
|
|
|
set(TARGET_TWPING twping)
|
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
add_executable(${TARGET_MASTERSRV} EXCLUDE_FROM_ALL ${MASTERSRV_SRC} $<TARGET_OBJECTS:engine-shared> ${DEPS})
|
|
|
|
add_executable(${TARGET_TWPING} EXCLUDE_FROM_ALL ${TWPING_SRC} $<TARGET_OBJECTS:engine-shared> ${DEPS})
|
2017-03-01 12:40:11 +00:00
|
|
|
|
|
|
|
target_link_libraries(${TARGET_MASTERSRV} ${LIBS})
|
|
|
|
target_link_libraries(${TARGET_TWPING} ${LIBS})
|
|
|
|
|
2017-09-03 15:36:51 +00:00
|
|
|
list(APPEND TARGETS_OWN ${TARGET_MASTERSRV} ${TARGET_TWPING})
|
|
|
|
list(APPEND TARGETS_LINK ${TARGET_MASTERSRV} ${TARGET_TWPING})
|
2017-03-01 14:49:22 +00:00
|
|
|
|
2017-03-03 14:23:18 +00:00
|
|
|
set(TARGETS_TOOLS)
|
2017-07-27 14:13:28 +00:00
|
|
|
set_glob(TOOLS GLOB src/tools
|
|
|
|
config_common.h
|
|
|
|
config_retrieve.cpp
|
|
|
|
config_store.cpp
|
|
|
|
confusables.cpp
|
|
|
|
crapnet.cpp
|
|
|
|
dilate.cpp
|
|
|
|
dummy_map.cpp
|
|
|
|
fake_server.cpp
|
|
|
|
map_diff.cpp
|
|
|
|
map_extract.cpp
|
2017-08-28 16:06:19 +00:00
|
|
|
map_replace_image.cpp
|
2017-07-27 14:13:28 +00:00
|
|
|
map_resave.cpp
|
|
|
|
map_version.cpp
|
|
|
|
packetgen.cpp
|
|
|
|
tileset_borderadd.cpp
|
|
|
|
tileset_borderfix.cpp
|
|
|
|
tileset_borderrem.cpp
|
|
|
|
tileset_borderset.cpp
|
|
|
|
uuid.cpp
|
|
|
|
)
|
|
|
|
foreach(ABS_T ${TOOLS})
|
|
|
|
file(RELATIVE_PATH T "${PROJECT_SOURCE_DIR}/src/tools/" ${ABS_T})
|
|
|
|
if(T MATCHES "\\.cpp$")
|
|
|
|
string(REGEX REPLACE "\\.cpp$" "" TOOL "${T}")
|
2018-02-12 22:14:14 +00:00
|
|
|
set(TOOL_DEPS ${DEPS})
|
|
|
|
set(TOOL_LIBS ${LIBS})
|
2017-08-01 19:55:49 +00:00
|
|
|
set(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
|
2017-09-05 14:00:50 +00:00
|
|
|
if(TOOL MATCHES "^(tileset_.*|dilate|map_extract|map_replace_image)$")
|
2018-02-12 22:14:14 +00:00
|
|
|
list(APPEND TOOL_DEPS ${PNGLITE_DEP})
|
|
|
|
list(APPEND TOOL_LIBS ${PNGLITE_LIBRARIES})
|
|
|
|
list(APPEND TOOL_INCLUDE_DIRS ${PNGLITE_INCLUDE_DIRS})
|
2017-07-27 14:13:28 +00:00
|
|
|
endif()
|
|
|
|
if(TOOL MATCHES "^config_")
|
|
|
|
list(APPEND EXTRA_TOOL_SRC "src/tools/config_common.h")
|
|
|
|
endif()
|
2017-08-01 19:55:49 +00:00
|
|
|
if(TOOL MATCHES "^(config_retrieve|config_store|dilate|map_diff|map_extract)$")
|
|
|
|
set(EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
|
|
|
add_executable(${TOOL} ${EXCLUDE_FROM_ALL}
|
2018-02-12 22:14:14 +00:00
|
|
|
${TOOL_DEPS}
|
2017-07-27 14:13:28 +00:00
|
|
|
src/tools/${TOOL}.cpp
|
|
|
|
${EXTRA_TOOL_SRC}
|
|
|
|
$<TARGET_OBJECTS:engine-shared>
|
|
|
|
)
|
2018-02-12 22:14:14 +00:00
|
|
|
target_include_directories(${TOOL} PRIVATE ${TOOL_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(${TOOL} ${TOOL_LIBS})
|
2017-07-27 14:13:28 +00:00
|
|
|
list(APPEND TARGETS_TOOLS ${TOOL})
|
2017-03-18 00:45:50 +00:00
|
|
|
endif()
|
2017-03-01 14:49:22 +00:00
|
|
|
endforeach()
|
|
|
|
|
2017-03-03 14:23:18 +00:00
|
|
|
list(APPEND TARGETS_OWN ${TARGETS_TOOLS})
|
2017-07-26 02:30:56 +00:00
|
|
|
list(APPEND TARGETS_LINK ${TARGETS_TOOLS})
|
2017-03-03 14:23:18 +00:00
|
|
|
|
|
|
|
add_custom_target(tools DEPENDS ${TARGETS_TOOLS})
|
2017-03-03 14:04:13 +00:00
|
|
|
add_custom_target(everything DEPENDS ${TARGETS_OWN})
|
2017-03-03 12:29:35 +00:00
|
|
|
|
2017-08-30 19:57:55 +00:00
|
|
|
########################################################################
|
|
|
|
# TESTS
|
|
|
|
########################################################################
|
|
|
|
|
2017-10-15 07:57:21 +00:00
|
|
|
if(GTEST_FOUND OR DOWNLOAD_GTEST)
|
2017-08-30 19:57:55 +00:00
|
|
|
set_glob(TESTS GLOB src/test
|
2017-10-13 00:48:42 +00:00
|
|
|
aio.cpp
|
2017-10-22 22:13:53 +00:00
|
|
|
fs.cpp
|
2018-03-01 15:50:29 +00:00
|
|
|
git_revision.cpp
|
2017-11-24 09:33:42 +00:00
|
|
|
jobs.cpp
|
2017-08-30 19:57:55 +00:00
|
|
|
strip_path_and_extension.cpp
|
2017-09-28 00:03:30 +00:00
|
|
|
teehistorian.cpp
|
2017-10-22 22:13:53 +00:00
|
|
|
test.cpp
|
|
|
|
test.h
|
2017-10-09 22:08:24 +00:00
|
|
|
thread.cpp
|
2017-12-20 15:56:44 +00:00
|
|
|
unix.cpp
|
2017-09-28 00:03:30 +00:00
|
|
|
)
|
|
|
|
set(TESTS_EXTRA
|
|
|
|
src/game/server/teehistorian.cpp
|
|
|
|
src/game/server/teehistorian.h
|
2017-08-30 19:57:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(TARGET_TESTRUNNER testrunner)
|
|
|
|
add_executable(${TARGET_TESTRUNNER} EXCLUDE_FROM_ALL
|
|
|
|
${TESTS}
|
2017-09-28 00:03:30 +00:00
|
|
|
${TESTS_EXTRA}
|
2017-08-30 19:57:55 +00:00
|
|
|
$<TARGET_OBJECTS:engine-shared>
|
|
|
|
$<TARGET_OBJECTS:game-shared>
|
2017-10-15 07:57:21 +00:00
|
|
|
${DEPS}
|
2017-08-30 19:57:55 +00:00
|
|
|
)
|
2017-11-24 09:51:46 +00:00
|
|
|
target_link_libraries(${TARGET_TESTRUNNER} ${LIBS} ${GTEST_LIBRARIES})
|
2017-08-30 19:57:55 +00:00
|
|
|
target_include_directories(${TARGET_TESTRUNNER} PRIVATE ${GTEST_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
list(APPEND TARGETS_OWN ${TARGET_TESTRUNNER})
|
|
|
|
list(APPEND TARGETS_LINK ${TARGET_TESTRUNNER})
|
|
|
|
|
|
|
|
add_custom_target(run_tests
|
|
|
|
COMMAND $<TARGET_FILE:${TARGET_TESTRUNNER}>
|
|
|
|
COMMENT Running tests
|
|
|
|
DEPENDS ${TARGET_TESTRUNNER}
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-08-01 19:55:49 +00:00
|
|
|
########################################################################
|
|
|
|
# INSTALLATION
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
function(escape_regex VAR STRING)
|
|
|
|
string(REGEX REPLACE "([][^$.+*?|()\\\\])" "\\\\\\1" ESCAPED "${STRING}")
|
|
|
|
set(${VAR} ${ESCAPED} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2017-09-13 20:38:25 +00:00
|
|
|
function(escape_backslashes VAR STRING)
|
|
|
|
string(REGEX REPLACE "\\\\" "\\\\\\\\" ESCAPED "${STRING}")
|
|
|
|
set(${VAR} ${ESCAPED} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2017-08-01 19:55:49 +00:00
|
|
|
function(max_length VAR)
|
|
|
|
set(MAX_LENGTH 0)
|
|
|
|
foreach(str ${ARGN})
|
|
|
|
string(LENGTH ${str} LENGTH)
|
|
|
|
if(LENGTH GREATER MAX_LENGTH)
|
|
|
|
set(MAX_LENGTH ${LENGTH})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(${VAR} ${MAX_LENGTH} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Tries to generate a list of regex that matches everything except the given
|
|
|
|
# parameters.
|
|
|
|
function(regex_inverted VAR)
|
|
|
|
max_length(MAX_LENGTH ${ARGN})
|
|
|
|
math(EXPR UPPER_BOUND "${MAX_LENGTH}-1")
|
|
|
|
|
|
|
|
set(REMAINING ${ARGN})
|
|
|
|
set(RESULT)
|
|
|
|
|
|
|
|
foreach(i RANGE ${UPPER_BOUND})
|
|
|
|
set(TEMP ${REMAINING})
|
|
|
|
set(REMAINING)
|
|
|
|
foreach(str ${TEMP})
|
|
|
|
string(LENGTH ${str} LENGTH)
|
|
|
|
if(i LESS LENGTH)
|
|
|
|
list(APPEND REMAINING ${str})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(ADDITIONAL)
|
|
|
|
foreach(outer ${REMAINING})
|
|
|
|
string(SUBSTRING ${outer} 0 ${i} OUTER_PREFIX)
|
|
|
|
set(CHARS "")
|
|
|
|
foreach(inner ${REMAINING})
|
|
|
|
string(SUBSTRING ${inner} 0 ${i} INNER_PREFIX)
|
|
|
|
if(OUTER_PREFIX STREQUAL INNER_PREFIX)
|
|
|
|
string(SUBSTRING ${inner} ${i} 1 INNER_NEXT)
|
|
|
|
set(CHARS "${CHARS}${INNER_NEXT}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
escape_regex(OUTER_PREFIX_ESCAPED "${OUTER_PREFIX}")
|
|
|
|
|
|
|
|
list(APPEND ADDITIONAL "${OUTER_PREFIX_ESCAPED}([^${CHARS}]|$)")
|
|
|
|
endforeach()
|
|
|
|
list(REMOVE_DUPLICATES ADDITIONAL)
|
|
|
|
list(APPEND RESULT ${ADDITIONAL})
|
|
|
|
endforeach()
|
|
|
|
set(${VAR} ${RESULT} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
|
|
|
set(CPACK_GENERATOR TGZ TXZ)
|
|
|
|
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
2018-01-14 07:42:15 +00:00
|
|
|
set(CPACK_STRIP_FILES TRUE)
|
2017-08-01 19:55:49 +00:00
|
|
|
set(CPACK_COMPONENTS_ALL portable)
|
|
|
|
set(CPACK_SOURCE_GENERATOR ZIP TGZ TBZ2 TXZ)
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
2018-01-14 14:31:31 +00:00
|
|
|
if(VERSION_PATCH STREQUAL "0")
|
|
|
|
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
|
|
|
|
endif()
|
2017-08-01 19:55:49 +00:00
|
|
|
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
|
|
|
|
|
|
|
|
if(TARGET_OS AND TARGET_BITS)
|
|
|
|
if(TARGET_OS STREQUAL "windows")
|
|
|
|
set(CPACK_SYSTEM_NAME "win${TARGET_BITS}")
|
|
|
|
set(CPACK_GENERATOR ZIP)
|
|
|
|
elseif(TARGET_OS STREQUAL "linux")
|
|
|
|
# Assuming Intel here.
|
|
|
|
if(TARGET_BITS EQUAL 32)
|
|
|
|
set(CPACK_SYSTEM_NAME "linux_x86")
|
|
|
|
elseif(TARGET_BITS EQUAL 64)
|
|
|
|
set(CPACK_SYSTEM_NAME "linux_x86_64")
|
|
|
|
endif()
|
|
|
|
elseif(TARGET_OS STREQUAL "mac")
|
|
|
|
set(CPACK_SYSTEM_NAME "osx")
|
2017-10-25 14:57:25 +00:00
|
|
|
set(CPACK_GENERATOR DMG)
|
2017-08-01 19:55:49 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME})
|
2017-11-08 23:16:52 +00:00
|
|
|
set(CPACK_ARCHIVE_PORTABLE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
|
2017-08-01 19:55:49 +00:00
|
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-src)
|
|
|
|
set(CPACK_SOURCE_FILES
|
|
|
|
CMakeLists.txt
|
|
|
|
README.md
|
|
|
|
autoexec_server.cfg
|
|
|
|
cmake/
|
|
|
|
data/
|
|
|
|
datasrc/
|
|
|
|
ddnet-libs/
|
|
|
|
license.txt
|
|
|
|
other/
|
|
|
|
scripts/
|
|
|
|
src/
|
|
|
|
storage.cfg
|
|
|
|
)
|
|
|
|
set(CPACK_SOURCE_IGNORE_FILES
|
2017-09-13 20:38:25 +00:00
|
|
|
"\\\\.pyc$"
|
|
|
|
"/\\\\.git"
|
2017-08-01 19:55:49 +00:00
|
|
|
"/__pycache__/"
|
|
|
|
)
|
|
|
|
|
|
|
|
regex_inverted(CPACK_SOURCE_FILES_INVERTED ${CPACK_SOURCE_FILES})
|
|
|
|
escape_regex(PROJECT_SOURCE_DIR_ESCAPED ${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
|
|
foreach(str ${CPACK_SOURCE_FILES_INVERTED})
|
2017-09-13 20:38:25 +00:00
|
|
|
escape_backslashes(STR_ESCAPED "${PROJECT_SOURCE_DIR_ESCAPED}/${str}")
|
|
|
|
list(APPEND CPACK_SOURCE_IGNORE_FILES "${STR_ESCAPED}")
|
2017-08-01 19:55:49 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ${PROJECT_NAME})
|
|
|
|
install(TARGETS ${TARGET_CLIENT} ${TARGET_SERVER} DESTINATION bin)
|
|
|
|
|
2017-09-05 14:00:50 +00:00
|
|
|
set(CPACK_TARGETS
|
|
|
|
${TARGET_CLIENT}
|
|
|
|
${TARGET_SERVER}
|
|
|
|
config_retrieve
|
|
|
|
config_store
|
|
|
|
dilate
|
|
|
|
map_diff
|
|
|
|
map_extract
|
|
|
|
)
|
2017-11-08 21:19:47 +00:00
|
|
|
set(CPACK_DIRS data)
|
2017-09-05 14:00:50 +00:00
|
|
|
set(CPACK_FILES
|
|
|
|
license.txt
|
|
|
|
storage.cfg
|
|
|
|
autoexec_server.cfg
|
|
|
|
${COPY_FILES}
|
|
|
|
)
|
2017-08-01 19:55:49 +00:00
|
|
|
if(TARGET_OS STREQUAL "windows")
|
2017-09-05 14:00:50 +00:00
|
|
|
list(APPEND CPACK_FILES other/config_directory.bat)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER 3.6 OR CMAKE_VERSION VERSION_EQUAL 3.6)
|
2017-11-17 16:43:52 +00:00
|
|
|
set(EXTRA_ARGS DESTINATION ${CPACK_PACKAGE_FILE_NAME} COMPONENT portable EXCLUDE_FROM_ALL)
|
2017-09-05 14:00:50 +00:00
|
|
|
install(TARGETS ${CPACK_TARGETS} ${EXTRA_ARGS})
|
|
|
|
install(DIRECTORY ${CPACK_DIRS} ${EXTRA_ARGS})
|
|
|
|
install(FILES ${CPACK_FILES} ${EXTRA_ARGS})
|
|
|
|
else()
|
|
|
|
message(WARNING "Cannot create CPack targets, CMake version too old. Use CMake 3.6 or newer.")
|
2017-08-01 19:55:49 +00:00
|
|
|
endif()
|
|
|
|
|
2017-11-17 21:32:56 +00:00
|
|
|
set(PACKAGE_TARGETS)
|
|
|
|
|
2018-03-06 18:25:07 +00:00
|
|
|
if(CLIENT AND (DMGTOOLS_FOUND OR HDIUTIL))
|
2018-02-05 19:22:54 +00:00
|
|
|
file(MAKE_DIRECTORY bundle/client/)
|
|
|
|
file(MAKE_DIRECTORY bundle/server/)
|
2017-11-17 21:32:44 +00:00
|
|
|
configure_file(other/bundle/client/Info.plist.in bundle/client/Info.plist)
|
|
|
|
configure_file(other/bundle/server/Info.plist.in bundle/server/Info.plist)
|
|
|
|
|
2017-11-09 12:35:59 +00:00
|
|
|
if(HDIUTIL)
|
|
|
|
set(DMG_PARAMS --hdiutil ${HDIUTIL})
|
|
|
|
elseif(DMGTOOLS_FOUND)
|
|
|
|
set(DMG_PARAMS --dmgtools ${DMG} ${HFSPLUS} ${NEWFS_HFS})
|
|
|
|
endif()
|
|
|
|
set(DMG_TMPDIR pack_${CPACK_PACKAGE_FILE_NAME}_dmg)
|
2017-11-08 23:16:52 +00:00
|
|
|
set(DMG_MKDIRS
|
|
|
|
${TARGET_CLIENT}.app
|
|
|
|
${TARGET_CLIENT}.app/Contents
|
|
|
|
${TARGET_CLIENT}.app/Contents/Frameworks
|
|
|
|
${TARGET_CLIENT}.app/Contents/MacOS
|
|
|
|
${TARGET_CLIENT}.app/Contents/Resources
|
2017-11-16 09:28:55 +00:00
|
|
|
${TARGET_SERVER}.app
|
|
|
|
${TARGET_SERVER}.app/Contents
|
|
|
|
${TARGET_SERVER}.app/Contents/MacOS
|
|
|
|
${TARGET_SERVER}.app/Contents/Resources
|
|
|
|
${TARGET_SERVER}.app/Contents/Resources/data
|
|
|
|
${TARGET_SERVER}.app/Contents/Resources/data/mapres
|
2017-11-08 23:16:52 +00:00
|
|
|
)
|
|
|
|
set(DMG_MKDIR_COMMANDS)
|
|
|
|
foreach(dir ${DMG_MKDIRS})
|
2017-11-17 14:55:22 +00:00
|
|
|
list(APPEND DMG_MKDIR_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory ${DMG_TMPDIR}/${dir})
|
2017-11-08 23:16:52 +00:00
|
|
|
endforeach()
|
|
|
|
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.dmg
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${DMG_TMPDIR}
|
2017-11-08 23:16:52 +00:00
|
|
|
${DMG_MKDIR_COMMANDS}
|
2017-11-16 09:28:55 +00:00
|
|
|
|
|
|
|
# CLIENT
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/data ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Resources/data
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/other/icons/${TARGET_CLIENT}.icns ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Resources/
|
2017-11-17 21:32:44 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy bundle/client/Info.plist ${PROJECT_SOURCE_DIR}/other/bundle/client/PkgInfo ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGET_CLIENT}> ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/MacOS/
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ddnet-libs/sdl/mac/lib64/SDL2.framework ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/SDL2.framework
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/ddnet-libs/freetype/mac/lib64/libfreetype.6.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/Frameworks/
|
2017-11-08 23:16:52 +00:00
|
|
|
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/../Frameworks/SDL2.framework/SDL2 ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/MacOS/${TARGET_CLIENT}
|
|
|
|
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change /usr/local/lib/libfreetype.6.dylib @executable_path/../Frameworks/libfreetype.6.dylib ${DMG_TMPDIR}/${TARGET_CLIENT}.app/Contents/MacOS/${TARGET_CLIENT}
|
2017-11-16 09:28:55 +00:00
|
|
|
|
|
|
|
# SERVER
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/data/maps ${DMG_TMPDIR}/${TARGET_SERVER}.app/Contents/Resources/data/maps
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/other/icons/${TARGET_SERVER}.icns ${DMG_TMPDIR}/${TARGET_SERVER}.app/Contents/Resources/
|
2017-11-17 21:32:44 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy bundle/server/Info.plist ${PROJECT_SOURCE_DIR}/other/bundle/server/PkgInfo ${DMG_TMPDIR}/${TARGET_SERVER}.app/Contents/
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TARGET_SERVER}> $<TARGET_FILE:${TARGET_SERVER_LAUNCHER}> ${DMG_TMPDIR}/${TARGET_SERVER}.app/Contents/MacOS/
|
2017-11-16 09:28:55 +00:00
|
|
|
|
|
|
|
# DMG
|
2017-11-09 12:35:59 +00:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/dmg.py create ${DMG_PARAMS} ${CPACK_PACKAGE_FILE_NAME}.dmg ${CPACK_PACKAGE_FILE_NAME} ${DMG_TMPDIR}
|
2017-11-17 13:37:29 +00:00
|
|
|
|
2017-11-17 21:32:44 +00:00
|
|
|
DEPENDS
|
|
|
|
${TARGET_CLIENT}
|
|
|
|
${TARGET_SERVER_LAUNCHER}
|
|
|
|
${TARGET_SERVER}
|
2018-02-12 22:14:14 +00:00
|
|
|
${PROJECT_BINARY_DIR}/bundle/client/Info.plist
|
|
|
|
${PROJECT_BINARY_DIR}/bundle/server/Info.plist
|
2017-11-17 21:32:44 +00:00
|
|
|
data
|
|
|
|
other/bundle/client/PkgInfo
|
|
|
|
other/bundle/server/PkgInfo
|
|
|
|
other/icons/${TARGET_CLIENT}.icns
|
|
|
|
other/icons/${TARGET_SERVER}.icns
|
|
|
|
scripts/dmg.py
|
2017-11-08 23:16:52 +00:00
|
|
|
)
|
|
|
|
add_custom_target(package_dmg DEPENDS ${CPACK_PACKAGE_FILE_NAME}.dmg)
|
2017-11-17 21:32:56 +00:00
|
|
|
list(APPEND PACKAGE_TARGETS package_dmg)
|
2017-11-08 23:16:52 +00:00
|
|
|
endif()
|
2017-09-05 14:00:50 +00:00
|
|
|
|
|
|
|
foreach(ext zip tar.gz tar.xz)
|
|
|
|
set(TAR_MODE c)
|
2017-09-05 19:42:09 +00:00
|
|
|
set(TAR_EXTRA_ARGS)
|
2017-09-05 14:00:50 +00:00
|
|
|
string(REPLACE . _ EXT_SLUG ${ext})
|
2017-11-09 12:35:59 +00:00
|
|
|
|
|
|
|
set(TMPDIR pack_${CPACK_PACKAGE_FILE_NAME}_${EXT_SLUG}/${CPACK_PACKAGE_FILE_NAME})
|
|
|
|
|
|
|
|
set(COPY_FILE_COMMANDS)
|
|
|
|
set(COPY_DIR_COMMANDS)
|
|
|
|
set(COPY_TARGET_COMMANDS)
|
2018-01-14 14:57:02 +00:00
|
|
|
set(STRIP_TARGET_COMMANDS)
|
2017-11-09 12:35:59 +00:00
|
|
|
foreach(file ${CPACK_FILES})
|
2017-11-17 14:55:22 +00:00
|
|
|
list(APPEND COPY_FILE_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/${file} ${TMPDIR}/)
|
2017-11-09 12:35:59 +00:00
|
|
|
endforeach()
|
|
|
|
foreach(dir ${CPACK_DIRS})
|
2017-11-17 14:55:22 +00:00
|
|
|
list(APPEND COPY_DIR_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/${dir} ${TMPDIR}/${dir})
|
2017-11-09 12:35:59 +00:00
|
|
|
endforeach()
|
|
|
|
foreach(target ${CPACK_TARGETS})
|
2017-11-17 14:55:22 +00:00
|
|
|
list(APPEND COPY_TARGET_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${TMPDIR}/)
|
2018-01-14 15:11:09 +00:00
|
|
|
list(APPEND STRIP_TARGET_COMMANDS COMMAND strip -s ${TMPDIR}/$<TARGET_FILE_NAME:${target}>)
|
2017-11-09 12:35:59 +00:00
|
|
|
endforeach()
|
|
|
|
|
2017-09-05 14:00:50 +00:00
|
|
|
if(ext STREQUAL zip)
|
2017-09-05 19:42:09 +00:00
|
|
|
set(TAR_EXTRA_ARGS --format=zip)
|
2017-09-05 14:00:50 +00:00
|
|
|
elseif(ext STREQUAL tar.gz)
|
|
|
|
set(TAR_MODE cz)
|
|
|
|
elseif(ext STREQUAL tar.xz)
|
|
|
|
set(TAR_MODE cJ)
|
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.${ext}
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TMPDIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TMPDIR}
|
2017-09-05 19:42:09 +00:00
|
|
|
${COPY_FILE_COMMANDS}
|
|
|
|
${COPY_DIR_COMMANDS}
|
|
|
|
${COPY_TARGET_COMMANDS}
|
2018-01-14 14:57:02 +00:00
|
|
|
${STRIP_TARGET_COMMANDS}
|
2017-11-17 14:55:22 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E chdir pack_${CPACK_PACKAGE_FILE_NAME}_${EXT_SLUG} ${CMAKE_COMMAND} -E tar ${TAR_MODE} ../${CPACK_PACKAGE_FILE_NAME}.${ext} ${TAR_EXTRA_ARGS} -- ${CPACK_PACKAGE_FILE_NAME}/
|
2017-11-17 13:37:29 +00:00
|
|
|
DEPENDS ${CPACK_TARGETS}
|
2017-09-05 14:00:50 +00:00
|
|
|
)
|
|
|
|
add_custom_target(package_${EXT_SLUG} DEPENDS ${CPACK_PACKAGE_FILE_NAME}.${ext})
|
2017-11-17 21:32:56 +00:00
|
|
|
list(APPEND PACKAGE_TARGETS package_${EXT_SLUG})
|
2017-09-05 14:00:50 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(PACKAGE_DEFAULT tar_xz)
|
|
|
|
if(TARGET_OS STREQUAL "windows")
|
|
|
|
set(PACKAGE_DEFAULT zip)
|
2017-11-08 23:16:52 +00:00
|
|
|
elseif(TARGET_OS STREQUAL "mac")
|
|
|
|
set(PACKAGE_DEFAULT dmg)
|
2017-09-05 14:00:50 +00:00
|
|
|
endif()
|
|
|
|
add_custom_target(package_default DEPENDS package_${PACKAGE_DEFAULT})
|
|
|
|
|
2017-11-17 21:32:56 +00:00
|
|
|
add_custom_target(package_all DEPENDS ${PACKAGE_TARGETS})
|
2017-09-05 14:00:50 +00:00
|
|
|
|
|
|
|
# Unset these variables, they might do something in the future of CPack.
|
|
|
|
unset(CPACK_SOURCE_FILES)
|
|
|
|
unset(CPACK_SOURCE_FILES_INVERTED)
|
|
|
|
unset(CPACK_TARGETS)
|
|
|
|
unset(CPACK_DIRS)
|
|
|
|
unset(CPACK_FILES)
|
|
|
|
|
2017-08-01 19:55:49 +00:00
|
|
|
include(CPack)
|
|
|
|
|
2017-03-03 12:39:06 +00:00
|
|
|
########################################################################
|
2017-03-03 14:23:18 +00:00
|
|
|
# COMPILER-SPECIFICS
|
2017-03-03 12:39:06 +00:00
|
|
|
########################################################################
|
|
|
|
|
2017-03-03 12:29:35 +00:00
|
|
|
# In the future (CMake 3.8.0+), use source_group(TREE ...)
|
|
|
|
macro(source_group_tree dir)
|
|
|
|
file(GLOB ents RELATIVE ${PROJECT_SOURCE_DIR}/${dir} ${PROJECT_SOURCE_DIR}/${dir}/*)
|
|
|
|
foreach(ent ${ents})
|
|
|
|
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${dir}/${ent})
|
|
|
|
source_group_tree(${dir}/${ent})
|
|
|
|
else()
|
|
|
|
string(REPLACE "/" "\\" group ${dir})
|
|
|
|
source_group(${group} FILES ${PROJECT_SOURCE_DIR}/${dir}/${ent})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
source_group_tree(src)
|
2017-03-03 12:39:06 +00:00
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
set(TARGETS ${TARGETS_OWN} ${TARGETS_DEP})
|
|
|
|
|
|
|
|
foreach(target ${TARGETS})
|
|
|
|
if(MSVC)
|
2017-03-12 15:28:04 +00:00
|
|
|
target_compile_options(${target} PRIVATE $<$<NOT:${DBG}>:/MT> $<${DBG}:/MTd>) # Use static CRT
|
2017-03-12 15:27:34 +00:00
|
|
|
target_compile_options(${target} PRIVATE /MP) # Use multiple cores
|
2017-03-07 14:24:08 +00:00
|
|
|
target_compile_options(${target} PRIVATE /EHsc) # Only catch C++ exceptions with catch.
|
2017-03-03 14:04:13 +00:00
|
|
|
target_compile_options(${target} PRIVATE /GS) # Protect the stack pointer.
|
2017-03-03 14:10:21 +00:00
|
|
|
target_compile_options(${target} PRIVATE /wd4996) # Use of non-_s functions.
|
2017-03-03 14:04:13 +00:00
|
|
|
endif()
|
2018-01-22 18:10:57 +00:00
|
|
|
if(OUR_FLAGS)
|
|
|
|
target_compile_options(${target} PRIVATE ${OUR_FLAGS})
|
|
|
|
endif()
|
|
|
|
if(DEFINE_FORTIFY_SOURCE)
|
|
|
|
target_compile_definitions(${target} PRIVATE $<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>) # Detect some buffer overflows.
|
2017-07-26 02:30:56 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2017-07-31 23:21:34 +00:00
|
|
|
if(MSVC)
|
2017-07-26 02:30:56 +00:00
|
|
|
set_property(TARGET ${TARGET_CLIENT} APPEND PROPERTY LINK_FLAGS /SAFESEH:NO) # Disable SafeSEH because the shipped libraries don't support it.
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(target ${TARGETS_LINK})
|
|
|
|
if(TARGET_OS STREQUAL "mac")
|
|
|
|
target_link_libraries(${target} -stdlib=libc++)
|
|
|
|
target_link_libraries(${target} -mmacosx-version-min=10.7)
|
|
|
|
endif()
|
2017-07-31 23:21:34 +00:00
|
|
|
if(MINGW)
|
|
|
|
# Statically link the standard libraries with on MinGW so we don't have to
|
|
|
|
# ship them as DLLs.
|
|
|
|
target_link_libraries(${target} -static-libgcc)
|
|
|
|
target_link_libraries(${target} -static-libstdc++)
|
|
|
|
endif()
|
2017-03-03 14:04:13 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(target ${TARGETS_OWN})
|
2018-01-14 13:36:25 +00:00
|
|
|
if((CMAKE_VERSION VERSION_GREATER 3.1 OR CMAKE_VERSION VERSION_EQUAL 3.1) AND NOT TARGET_OS STREQUAL "mac")
|
2017-11-23 02:10:25 +00:00
|
|
|
set_property(TARGET ${target} PROPERTY CXX_STANDARD 11)
|
2018-01-14 13:36:25 +00:00
|
|
|
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
|
2017-11-23 02:10:25 +00:00
|
|
|
endif()
|
|
|
|
|
2017-03-03 14:04:13 +00:00
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(${target} PRIVATE /wd4244) # Possible loss of data (float -> int, int -> float, etc.).
|
2017-03-12 15:23:17 +00:00
|
|
|
target_compile_options(${target} PRIVATE /wd4267) # Possible loss of data (size_t - int on win64).
|
2017-03-03 14:04:13 +00:00
|
|
|
target_compile_options(${target} PRIVATE /wd4800) # Implicit conversion of int to bool.
|
2018-01-22 18:10:57 +00:00
|
|
|
endif()
|
|
|
|
if(OUR_FLAGS_OWN)
|
|
|
|
target_compile_options(${target} PRIVATE ${OUR_FLAGS_OWN})
|
2017-03-03 14:04:13 +00:00
|
|
|
endif()
|
2018-02-12 22:14:14 +00:00
|
|
|
target_include_directories(${target} PRIVATE ${PROJECT_BINARY_DIR}/src)
|
2018-02-20 16:11:18 +00:00
|
|
|
target_include_directories(${target} PRIVATE src)
|
2017-03-03 14:04:13 +00:00
|
|
|
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:CONF_DEBUG>)
|
2018-02-12 22:14:14 +00:00
|
|
|
target_include_directories(${target} PRIVATE ${ZLIB_INCLUDE_DIRS})
|
2017-10-20 09:52:18 +00:00
|
|
|
target_compile_definitions(${target} PRIVATE GLEW_STATIC)
|
2017-03-03 14:04:13 +00:00
|
|
|
if(WEBSOCKETS)
|
2017-03-07 12:03:37 +00:00
|
|
|
target_compile_definitions(${target} PRIVATE CONF_WEBSOCKETS)
|
2018-02-14 11:55:04 +00:00
|
|
|
target_include_directories(${target} PRIVATE ${WEBSOCKETS_INCLUDE_DIRS})
|
2017-03-03 14:04:13 +00:00
|
|
|
endif()
|
2017-07-22 23:36:36 +00:00
|
|
|
if(MYSQL)
|
|
|
|
target_compile_definitions(${target} PRIVATE CONF_SQL)
|
|
|
|
target_include_directories(${target} PRIVATE ${MYSQL_INCLUDE_DIRS})
|
|
|
|
endif()
|
2017-03-03 14:04:13 +00:00
|
|
|
endforeach()
|
|
|
|
|
2017-03-12 14:56:44 +00:00
|
|
|
foreach(target ${TARGETS_DEP})
|
2017-03-03 14:04:13 +00:00
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(${target} PRIVATE /W0)
|
|
|
|
endif()
|
2018-02-12 20:29:43 +00:00
|
|
|
if(OUR_FLAGS_DEP)
|
|
|
|
target_compile_options(${target} PRIVATE ${OUR_FLAGS_DEP})
|
|
|
|
endif()
|
2017-03-03 14:04:13 +00:00
|
|
|
endforeach()
|