e2454fec33
- drop -fuse-ld from CXXFLAGS - add -Wno-pass-failed for clang in Makefile and CMake
494 lines
18 KiB
CMake
494 lines
18 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
option(TILES "Build graphical tileset version." "OFF")
|
|
# SDL2 support was removed; SDL3 is the only tiles backend. The option is kept
|
|
# so an old -DUSE_SDL3=OFF command line fails loudly instead of silently
|
|
# building something else.
|
|
option(USE_SDL3 "Removed; SDL3 is the only tiles backend." "ON")
|
|
if (TILES AND NOT USE_SDL3)
|
|
message(FATAL_ERROR
|
|
"USE_SDL3=OFF is no longer supported: SDL2 support was removed and \
|
|
SDL3 is the only tiles backend. Drop the option, or build without \
|
|
-DTILES=ON for a text-only compilation.")
|
|
endif()
|
|
project(CataclysmDDA)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
${CMAKE_SOURCE_DIR}/CMakeModules)
|
|
if (NOT VCPKG_MANIFEST_MODE)
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
${CMAKE_SOURCE_DIR}/CMakeModules/Find)
|
|
endif()
|
|
|
|
set(CMAKE_TLS_VERIFY ON)
|
|
|
|
# Build options
|
|
include(CMakeDependentOption)
|
|
option(CURSES "Build curses version." "ON")
|
|
option(SOUND "Support for in-game sounds & music." "OFF")
|
|
option(BACKTRACE "Support for printing stack backtraces on crash" "ON")
|
|
option(LIBBACKTRACE "Print backtrace with libbacktrace." "OFF")
|
|
option(USE_XDG_DIR "Use XDG directories for save and config files." "OFF")
|
|
option(USE_HOME_DIR "Use user's home directory for save and config files." "ON")
|
|
cmake_dependent_option(USE_PREFIX_DATA_DIR
|
|
"Use UNIX system directories for game data in release build." ON
|
|
"UNIX" OFF
|
|
)
|
|
option(LOCALIZE "Support for language localizations. Also enable UTF support." "ON")
|
|
option(LANGUAGES "Compile localization files for specified languages." "")
|
|
option(DYNAMIC_LINKING
|
|
"Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
|
|
option(JSON_FORMAT "Build JSON formatter" "OFF")
|
|
option(CATA_CCACHE "Try to find and build with ccache" "ON")
|
|
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy checks as a plugin" "OFF")
|
|
option(CATA_CLANG_TIDY_EXECUTABLE "Build Cata's custom clang-tidy checks as an executable" "OFF")
|
|
option(WARN_STALE_DATA "Warn if file integrity check fails" "OFF")
|
|
option(TESTS "Compile Cata's tests" "ON")
|
|
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING
|
|
"Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
|
|
set(CATA_CHECK_CLANG_TIDY "" CACHE STRING "Path to check_clang_tidy.py for plugin tests")
|
|
set(GIT_BINARY "" CACHE STRING "Git binary name or path.")
|
|
set(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.")
|
|
|
|
if (TESTS)
|
|
include(CTest)
|
|
endif()
|
|
|
|
message(STATUS "${PROJECT_NAME} build environment --")
|
|
message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
|
|
|
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL
|
|
PROPERTY GENERATOR_IS_MULTI_CONFIG
|
|
)
|
|
if (NOT CMAKE_BUILD_TYPE AND NOT GENERATOR_IS_MULTI_CONFIG)
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
endif ()
|
|
|
|
add_definitions(-DCMAKE)
|
|
|
|
# Retrieve version from git into GIT_VERSION and creates VERSION.txt
|
|
execute_process(COMMAND ${CMAKE_COMMAND}
|
|
-DGIT_BINARY=${GIT_BINARY}
|
|
-P ${CMAKE_SOURCE_DIR}/src/version.cmake
|
|
ERROR_VARIABLE GIT_VERSION
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|
|
|
|
if (GIT_VERSION)
|
|
message(STATUS "${PROJECT_NAME} build version is: ${GIT_VERSION}")
|
|
add_definitions(-DGIT_VERSION)
|
|
else()
|
|
message(WARNING "Git binary not found. Build version will be set to NULL. Install Git package
|
|
or use -DGIT_BINARY to set path to git binary.")
|
|
set(VERSION "NULL")
|
|
endif ()
|
|
|
|
#OS Check Placeholders. Will be used for BINDIST
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
|
set(_OS_LINUX_ 1)
|
|
endif ()
|
|
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD"
|
|
OR "${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD"
|
|
OR "${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
|
|
set(_OS_BSD_ 1)
|
|
endif ()
|
|
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
|
set(_OS_DARWIN_ 1)
|
|
add_definitions(-DMACOSX)
|
|
endif ()
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
if(DEFINED ENV{MSYSTEM})
|
|
set(MSYS2 True)
|
|
add_definitions(-DMSYS2)
|
|
endif()
|
|
#FIXME: Add dest build choice: m32 for 32 bit or m64 for 64 bit version
|
|
#add_definitions("-m32")
|
|
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
|
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
|
#SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32")
|
|
#SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")
|
|
|
|
if (NOT MSVC)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcx16")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16")
|
|
endif()
|
|
|
|
include(ListImportedTargets)
|
|
|
|
find_package(PkgConfig)
|
|
if (NOT DYNAMIC_LINKING)
|
|
if(NOT MSVC)
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a")
|
|
endif()
|
|
set(BUILD_SHARED_LIBRARIES OFF)
|
|
check_cxx_compiler_flag (-static HAVE_STATIC_FLAG)
|
|
if (HAVE_STATIC_FLAG)
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
endif ()
|
|
# Workaround for cmake link library guesser
|
|
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
|
|
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
|
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
|
|
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
|
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
|
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
|
else ()
|
|
if (MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
# Avoid depending on MinGW runtime DLLs
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
endif ()
|
|
endif ()
|
|
|
|
message(STATUS "${PROJECT_NAME} build options --")
|
|
|
|
# Preset variables
|
|
if (NOT LANGUAGES)
|
|
set(LANGUAGES "")
|
|
endif ()
|
|
|
|
if (GIT_BINARY)
|
|
set(GIT_EXECUTABLE ${GIT_BINARY})
|
|
else ()
|
|
find_package(Git)
|
|
if (NOT GIT_FOUND)
|
|
message(WARNING
|
|
"Git binary not found. Build version will be set to NULL. \
|
|
Install Git package or use -DGIT_BINARY to set path to git binary.")
|
|
endif ()
|
|
endif ()
|
|
|
|
# Can't compile curses and tiles build's at same time
|
|
if (TILES)
|
|
set(CURSES OFF)
|
|
endif ()
|
|
|
|
# Can't use both home and xdg directories
|
|
if (USE_XDG_DIR)
|
|
set(USE_HOME_DIR OFF)
|
|
endif ()
|
|
|
|
# Set build types and display info
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
|
set(RELEASE 0)
|
|
message(STATUS "Build ${PROJECT_NAME} in development mode --")
|
|
message(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
# Since CataclysmDDA does not respect PREFIX for development builds
|
|
# and has funny path handlers, we should create resulting Binaries
|
|
# in the source directory
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} CACHE PATH
|
|
"Single Directory for all Executables.")
|
|
set(CMAKE_INSTALL_BINDIR .)
|
|
else ()
|
|
set(RELEASE 1)
|
|
add_definitions(-DRELEASE)
|
|
# Use CMAKE_INSTALL_PREFIX as storage of data,gfx, etc.. Useful only on *nix OS.
|
|
if(USE_PREFIX_DATA_DIR)
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Linux|FreeBSD|Darwin)")
|
|
set(CMAKE_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda")
|
|
add_definitions(-DPREFIX=${CMAKE_INSTALL_PREFIX})
|
|
configure_file(
|
|
"${CMAKE_SOURCE_DIR}/src/prefix.h.in"
|
|
"${CMAKE_SOURCE_DIR}/src/prefix.h"
|
|
@ONLY)
|
|
add_definitions(-DDATA_DIR_PREFIX)
|
|
endif ()
|
|
else()
|
|
set(CMAKE_INSTALL_DATADIR data)
|
|
set(CMAKE_INSTALL_DOCDIR . )
|
|
set(CMAKE_INSTALL_LOCALEDIR lang)
|
|
set(CMAKE_INSTALL_BINDIR . )
|
|
endif ()
|
|
message(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
|
|
message(STATUS "CMAKE_INSTALL_BINDIR : ${CMAKE_INSTALL_BINDIR}")
|
|
if (LOCALIZE)
|
|
message(STATUS "CMAKE_INSTALL_LOCALEDIR : ${CMAKE_INSTALL_LOCALEDIR}")
|
|
endif ()
|
|
message(STATUS "DESKTOP_ENTRY_PATH : ${DESKTOP_ENTRY_PATH}")
|
|
message(STATUS "PIXMAPS_ENTRY_PATH : ${PIXMAPS_ENTRY_PATH}")
|
|
message(STATUS "PIXMAPS_UNITY_ENTRY_PATH : ${PIXMAPS_UNITY_ENTRY_PATH}")
|
|
message(STATUS "MANPAGE_ENTRY_PATH : ${MANPAGE_ENTRY_PATH}")
|
|
endif ()
|
|
|
|
message(STATUS "GIT_BINARY : ${GIT_EXECUTABLE}")
|
|
message(STATUS "DYNAMIC_LINKING : ${DYNAMIC_LINKING}")
|
|
message(STATUS "TILES : ${TILES}")
|
|
message(STATUS "CURSES : ${CURSES}")
|
|
message(STATUS "SOUND : ${SOUND}")
|
|
message(STATUS "BACKTRACE : ${BACKTRACE}")
|
|
message(STATUS "LOCALIZE : ${LOCALIZE}")
|
|
message(STATUS "USE_XDG_DIR : ${USE_XDG_DIR}")
|
|
message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}")
|
|
message(STATUS "LANGUAGES : ${LANGUAGES}")
|
|
message(STATUS "See doc/c++/COMPILING-CMAKE.md for details and more info --")
|
|
|
|
if (NOT MSVC)
|
|
set(CATA_WARNINGS
|
|
"-Werror -Wall -Wextra \
|
|
-Wformat-signedness \
|
|
-Wlogical-op \
|
|
-Wmissing-declarations \
|
|
-Wmissing-noreturn \
|
|
-Wnon-virtual-dtor \
|
|
-Wold-style-cast \
|
|
-Woverloaded-virtual \
|
|
-Wpedantic \
|
|
-Wsuggest-override \
|
|
-Wunused-macros \
|
|
-Wzero-as-null-pointer-constant")
|
|
check_cxx_compiler_flag(-Wdangling-reference HAVE_DANGLING_REFERENCE)
|
|
if (HAVE_DANGLING_REFERENCE)
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-dangling-reference")
|
|
endif ()
|
|
check_cxx_compiler_flag(-Wc++20-compat HAVE_CXX20_COMPAT)
|
|
if (HAVE_CXX20_COMPAT)
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-c++20-compat")
|
|
endif ()
|
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option")
|
|
# libstdc++ marks loops with "#pragma GCC unroll", which clang cannot always honor.
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-pass-failed")
|
|
endif()
|
|
# GCC 16 -Wsfinae-incomplete: SFINAE on incomplete forward-declared types
|
|
# (e.g. std::reference_wrapper<vehicle>) is link-compatible across TUs.
|
|
check_cxx_compiler_flag(-Wsfinae-incomplete HAVE_SFINAE_INCOMPLETE)
|
|
if (HAVE_SFINAE_INCOMPLETE)
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-error=sfinae-incomplete")
|
|
endif ()
|
|
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
|
set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
|
|
endif ()
|
|
set(CATA_OTHER_FLAGS "${CATA_OTHER_FLAGS} -fsigned-char -g1")
|
|
# Compact the whitespace in the warning string
|
|
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS} ${CATA_OTHER_FLAGS}")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g2")
|
|
endif ()
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
# Force out-of-source build
|
|
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
message(FATAL_ERROR
|
|
"This project requires an out of source build. \
|
|
Remove the file 'CMakeCache.txt' found in this directory before continuing; \
|
|
create a separate build directory and run 'cmake [options] <srcs>' from there. \
|
|
See doc/c++/COMPILING-CMAKE.md for details and more info.")
|
|
endif ()
|
|
|
|
#set(THREADS_USE_PTHREADS_WIN32 True)
|
|
set(CMAKE_THREAD_PREFER_PTHREAD True)
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
# Check for build types and libraries
|
|
if (TILES)
|
|
message(STATUS "Searching for SDL3 library --")
|
|
# SDL_SetGPURenderState and SDL_GetGPURendererDevice were added in SDL 3.4.0;
|
|
# the GPU shader path requires that floor.
|
|
find_package(SDL3 3.4.0 CONFIG)
|
|
if (NOT (SDL3_FOUND OR TARGET SDL3::SDL3 OR TARGET SDL3::SDL3-static))
|
|
message(FATAL_ERROR
|
|
"The tiles build requires SDL3 >= 3.4.0 to be installed. \
|
|
Install or build a newer SDL3 development library, \
|
|
or build without -DTILES=ON for a text-only compilation.")
|
|
endif ()
|
|
|
|
message(STATUS "Searching for SDL3_ttf library --")
|
|
find_package(SDL3_ttf CONFIG)
|
|
if (NOT (SDL3_TTF_FOUND OR TARGET SDL3_ttf::SDL3_ttf OR TARGET SDL3_ttf::SDL3_ttf-static))
|
|
message(FATAL_ERROR
|
|
"The tiles build requires SDL3_ttf to be installed.")
|
|
endif ()
|
|
|
|
message(STATUS "Searching for SDL3_image library --")
|
|
find_package(SDL3_image CONFIG)
|
|
if (NOT (SDL3_IMAGE_FOUND OR TARGET SDL3_image::SDL3_image
|
|
OR TARGET SDL3_image::SDL3_image-static))
|
|
message(FATAL_ERROR
|
|
"The tiles build requires SDL3_image to be installed.")
|
|
endif ()
|
|
add_definitions(-DTILES)
|
|
endif ()
|
|
|
|
if (CURSES)
|
|
# Find the ncurses library for a text based compile
|
|
message(STATUS "Searching for Curses library --")
|
|
set(CURSES_NEED_NCURSES TRUE)
|
|
set(CURSES_NEED_WIDE TRUE)
|
|
if (WIN32 AND VCPKG_MANIFEST_MODE)
|
|
find_package(unofficial-pdcurses CONFIG)
|
|
if(TARGET unofficial::pdcurses::pdcurses)
|
|
get_target_property(_IMPORTED_CONFIGURATIONS unofficial::pdcurses::pdcurses
|
|
IMPORTED_CONFIGURATIONS
|
|
)
|
|
if (RELEASE AND "Release" IN_LIST _IMPORTED_CONFIGURATIONS)
|
|
get_target_property(_IMPORTED_LOCATION unofficial::pdcurses::pdcurses
|
|
IMPORTED_IMPLIB_RELEASE)
|
|
elseif("Debug" IN_LIST _IMPORTED_CONFIGURATIONS)
|
|
get_target_property(_IMPORTED_LOCATION unofficial::pdcurses::pdcurses
|
|
IMPORTED_IMPLIB_DEBUG)
|
|
endif()
|
|
set_target_properties(unofficial::pdcurses::pdcurses PROPERTIES
|
|
IMPORTED_LOCATION ${_IMPORTED_LOCATION})
|
|
set(USE_PDCURSES TRUE)
|
|
endif()
|
|
elseif(MSYS2)
|
|
if(True) # GNU NCURSES: mingw-w64-ucrt-x86_64-ncurses
|
|
add_library(pdcurses STATIC IMPORTED)
|
|
set_target_properties(pdcurses PROPERTIES
|
|
IMPORTED_LOCATION $ENV{MSYSTEM_PREFIX}/lib/libncursesw.a
|
|
INTERFACE_INCLUDE_DIRECTORIES $ENV{MSYSTEM_PREFIX}/include/ncursesw
|
|
)
|
|
set(USE_PDCURSES FALSE)
|
|
else() # PDCursesMOD: mingw-w64-ucrt-x86_64-pdcurses
|
|
add_library(pdcurses STATIC IMPORTED)
|
|
set_target_properties(pdcurses PROPERTIES
|
|
IMPORTED_LOCATION $ENV{MSYSTEM_PREFIX}/lib/libpdcurses_wingui.a
|
|
INTERFACE_INCLUDE_DIRECTORIES $ENV{MSYSTEM_PREFIX}/include/pdcurses
|
|
INTERFACE_COMPILE_DEFINITIONS
|
|
"PDC_WIDE;PDC_FORCE_UTF8;PDC_NCMOUSE;PDC_RGB;CHTYPE_32"
|
|
)
|
|
set(USE_PDCURSES TRUE)
|
|
endif()
|
|
set(CURSES_FOUND True)
|
|
else ()
|
|
find_package(Curses)
|
|
endif ()
|
|
if (NOT (CURSES_FOUND OR TARGET unofficial::pdcurses::pdcurses))
|
|
message(FATAL_ERROR
|
|
"This project requires ncurses to be installed to be compiled in text-only mode. \
|
|
Please install the ncurses development libraries, \
|
|
or try compiling with -DTILES=1 for a graphical compilation. \
|
|
See doc/c++/COMPILING-CMAKE.md for details and more info")
|
|
endif ()
|
|
if (NOT DYNAMIC_LINKING)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNCURSES_STATIC")
|
|
endif ()
|
|
endif ()
|
|
|
|
if (SOUND)
|
|
message(STATUS "Searching for SDL3_mixer library --")
|
|
find_package(SDL3_mixer CONFIG)
|
|
if (NOT (SDL3_MIXER_FOUND OR TARGET SDL3_mixer::SDL3_mixer
|
|
OR TARGET SDL3_mixer::SDL3_mixer-static))
|
|
message(FATAL_ERROR
|
|
"SOUND requires SDL3_mixer to be installed. \
|
|
See doc/c++/COMPILING-CMAKE.md for details and more info.")
|
|
endif()
|
|
endif ()
|
|
|
|
if (BACKTRACE)
|
|
add_definitions(-DBACKTRACE)
|
|
if (LIBBACKTRACE)
|
|
add_definitions(-DLIBBACKTRACE)
|
|
endif ()
|
|
if (_OS_BSD_)
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lexecinfo")
|
|
endif ()
|
|
endif ()
|
|
|
|
if ((LOCALIZE OR BUILD_TESTING) AND "${GETTEXT_MSGFMT_BINARY}" STREQUAL "")
|
|
if(MSVC)
|
|
list(APPEND Gettext_ROOT C:\\msys64\\usr)
|
|
list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\usr)
|
|
endif(MSVC)
|
|
find_package(Gettext)
|
|
endif ()
|
|
if (NOT GETTEXT_MSGFMT_EXECUTABLE )
|
|
set(GETTEXT_MSGFMT_EXECUTABLE "${GETTEXT_MSGFMT_BINARY}")
|
|
endif()
|
|
|
|
# Ok. Now create build and install recipes
|
|
if (LOCALIZE)
|
|
add_subdirectory(lang)
|
|
add_definitions(-DLOCALIZE)
|
|
endif ()
|
|
|
|
if (USE_HOME_DIR)
|
|
add_definitions(-DUSE_HOME_DIR)
|
|
endif ()
|
|
|
|
if (USE_XDG_DIR)
|
|
add_definitions(-DUSE_XDG_DIR)
|
|
endif ()
|
|
|
|
find_program(CCACHE_FOUND ccache HINTS ${CMAKE_CURRENT_SOURCE_DIR}/ccache)
|
|
if (CCACHE_FOUND AND CATA_CCACHE)
|
|
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_FOUND})
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND})
|
|
set(CMAKE_C_LINKER_LAUNCHER ${CCACHE_FOUND})
|
|
set(CMAKE_CXX_LINKER_LAUNCHER ${CCACHE_FOUND})
|
|
if (MSVC)
|
|
string(REPLACE /Zi /Z7 CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
|
string(REPLACE /Zi /Z7 CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
|
string(REPLACE /Zi /Z7 CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
string(REPLACE /Zi /Z7 CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
|
cmake_path(GET CCACHE_FOUND PARENT_PATH ClToolPath)
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Directory.Build.props "
|
|
<Project>
|
|
<PropertyGroup>
|
|
<ClToolPath>${ClToolPath}</ClToolPath>
|
|
<TrackFileAccess>false</TrackFileAccess>
|
|
<UseMultiToolTask>true</UseMultiToolTask>
|
|
</PropertyGroup>
|
|
</Project>
|
|
")
|
|
endif ()
|
|
endif ()
|
|
|
|
add_subdirectory(src)
|
|
add_subdirectory(data)
|
|
if (NOT MSVC)
|
|
add_subdirectory(src/chkjson)
|
|
endif()
|
|
|
|
if(TESTS)
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/tests/catch/contrib)
|
|
include(Catch)
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
if (JSON_FORMAT)
|
|
add_subdirectory(tools/format)
|
|
endif()
|
|
if (CATA_CLANG_TIDY_PLUGIN OR CATA_CLANG_TIDY_EXECUTABLE)
|
|
add_subdirectory(tools/clang-tidy-plugin)
|
|
endif()
|
|
|
|
install(DIRECTORY doc TYPE DOC)
|
|
|
|
if (RELEASE)
|
|
install(FILES
|
|
${CMAKE_SOURCE_DIR}/README.md
|
|
${CMAKE_SOURCE_DIR}/LICENSE.txt
|
|
${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt
|
|
${CMAKE_SOURCE_DIR}/VERSION.txt
|
|
TYPE DOC)
|
|
if (TILES)
|
|
if (USE_PREFIX_DATA_DIR)
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx
|
|
TYPE DATA)
|
|
else()
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx
|
|
DESTINATION .)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
IMMEDIATE @ONLY)
|
|
|
|
add_custom_target(uninstall
|
|
"${CMAKE_COMMAND}"
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|