From 75b8190c21709c200429696f81a0ec14e75ed2a3 Mon Sep 17 00:00:00 2001 From: Alexander Epaneshnikov Date: Sun, 29 Dec 2019 00:30:11 +0300 Subject: [PATCH] Cmake cosmetic fixes (#36504) * fix typos even in code comments * make cmake_minimum_required(VERSION" consistent across project * kill tabs --- CMakeLists.txt | 377 ++++++++++++++++---------------- data/CMakeLists.txt | 46 ++-- lang/CMakeLists.txt | 116 +++++----- src/CMakeLists.txt | 515 ++++++++++++++++++++++---------------------- 4 files changed, 526 insertions(+), 528 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 435e421c9e24e..30cd27aa63a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,14 +11,14 @@ SET(CMAKE_MODULE_PATH SET(CMAKE_TLS_VERIFY ON) # Build options -option(TILES "Build graphical tileset version." "OFF") -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(USE_HOME_DIR "Use user's home directory for save files." "ON" ) -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(TILES "Build graphical tileset version." "OFF") +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(USE_HOME_DIR "Use user's home directory for save files." "ON") +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(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF") 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") @@ -45,7 +45,7 @@ MESSAGE(STATUS "${PROJECT} build environment -- \n") MESSAGE(STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}") IF(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug) + set(CMAKE_BUILD_TYPE Debug) ENDIF(NOT CMAKE_BUILD_TYPE) if (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND) @@ -59,17 +59,17 @@ ENDIF(NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND) #OS Check Placeholders. Will be used for BINDIST IF (${CMAKE_SYSTEM_NAME} MATCHES Linux) - SET(_OS_LINUX_ 1) + SET(_OS_LINUX_ 1) ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux) IF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD) - SET(_OS_FREEBSD_ 1) + SET(_OS_FREEBSD_ 1) ENDIF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD) IF(${CMAKE_SYSTEM_NAME} MATCHES Darwin) - SET(_OS_DARWIN_ 1) - SET(LOCALIZE OFF) - MESSAGE(STATUS "Disable internationalization on Darwin as it is not supported") + SET(_OS_DARWIN_ 1) + SET(LOCALIZE OFF) + MESSAGE(STATUS "Disable internationalization on Darwin as it is not supported") ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Darwin) include(CheckCXXCompilerFlag) @@ -82,60 +82,60 @@ include(CheckCXXCompilerFlag) #SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32") IF (NOT DYNAMIC_LINKING) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a") - 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(HAVE_STATIC_FLAG) - # 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) + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a") + 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(HAVE_STATIC_FLAG) + # 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 (NOT DYNAMIC_LINKING) - 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(MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") + 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(MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") ENDIF (NOT DYNAMIC_LINKING) -#Sysem specific actions +# System specific actions IF (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD) IF(NOT DATA_PREFIX) - SET( DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda) + SET( DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda) ENDIF(NOT DATA_PREFIX) IF(NOT LOCALE_DIR) - SET( LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale) + SET( LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale) ENDIF(NOT LOCALE_DIR) IF(NOT BIN_PREFIX) - SET( BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin) + SET( BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin) ENDIF(NOT BIN_PREFIX) IF(NOT DESKTOP_ENTRY_PATH) - SET( DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications) + SET( DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications) ENDIF(NOT DESKTOP_ENTRY_PATH) IF(NOT PIXMAPS_ENTRY_PATH) - SET( PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) + SET( PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) ENDIF(NOT PIXMAPS_ENTRY_PATH) IF(NOT PIXMAPS_UNITY_ENTRY_PATH) - SET( PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark) + SET( PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark) ENDIF(NOT PIXMAPS_UNITY_ENTRY_PATH) IF(NOT MANPAGE_ENTRY_PATH) - SET( MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man) + SET( MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man) ENDIF(NOT MANPAGE_ENTRY_PATH) ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD) IF (${CMAKE_SYSTEM_NAME} MATCHES Windows) IF(NOT DATA_PREFIX) - SET(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}) + SET(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}) ENDIF(NOT DATA_PREFIX) IF(NOT LOCALE_DIR) - SET(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}) + SET(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}) ENDIF(NOT LOCALE_DIR) IF(NOT BIN_PREFIX) - SET(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) + SET(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) ENDIF(NOT BIN_PREFIX) ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Windows) @@ -144,20 +144,20 @@ MESSAGE(STATUS "${PROJECT_NAME} build options --\n") # Preset variables IF(NOT LANGUAGES) - SET (LANGUAGES de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW) + SET (LANGUAGES de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW) ENDIF(NOT LANGUAGES) IF (GIT_BINARY) - SET(GIT_EXECUTABLE ${GIT_BINARY}) + SET(GIT_EXECUTABLE ${GIT_BINARY}) ELSE (GIT_BINARY) - 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 (NOT GIT_FOUND) + 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 (NOT GIT_FOUND) ENDIF (GIT_BINARY) IF (PREFIX) - ADD_DEFINITIONS(-DPREFIX=${PREFIX}) + ADD_DEFINITIONS(-DPREFIX=${PREFIX}) ENDIF (PREFIX) # Can't compile curses and tiles build's at same time @@ -167,78 +167,79 @@ ENDIF(TILES) # Set build types and display info IF(CMAKE_BUILD_TYPE STREQUAL Debug) - MESSAGE("\n") - MESSAGE(STATUS "Build ${PROJECT} in development mode --\n") - MESSAGE(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR}) - SET(CMAKE_VERBOSE_MAKEFILE ON) - # Since CataclusmDDA does not respect PREFIX for development builds - # and has funny path handlers, we should create resulting Binaries - # in the source redectory - SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${CMAKE_SOURCE_DIR} - CACHE PATH "Single Directory for all Executables." - ) - SET(BIN_PREFIX ${CMAKE_SOURCE_DIR}) + MESSAGE("\n") + MESSAGE(STATUS "Build ${PROJECT} in development mode --\n") + 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(BIN_PREFIX ${CMAKE_SOURCE_DIR}) ELSE (CMAKE_BUILD_TYPE STREQUAL Debug) - MESSAGE(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}") - MESSAGE(STATUS "BIN_PREFIX : ${BIN_PREFIX}") - MESSAGE(STATUS "DATA_PREFIX : ${DATA_PREFIX}") + MESSAGE(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}") + MESSAGE(STATUS "BIN_PREFIX : ${BIN_PREFIX}") + MESSAGE(STATUS "DATA_PREFIX : ${DATA_PREFIX}") IF(LOCALIZE) - MESSAGE(STATUS "LOCALE_PATH : ${LOCALE_DIR}") + MESSAGE(STATUS "LOCALE_PATH : ${LOCALE_DIR}") ENDIF(LOCALIZE) - 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}\n") - ADD_DEFINITIONS(-DRELEASE) + 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}\n") + ADD_DEFINITIONS(-DRELEASE) # Use PREFIX as storage of data,gfx, etc.. Usefull only on *nix OS. IF (PREFIX AND NOT WIN32) - ADD_DEFINITIONS(-DDATA_DIR_PREFIX) + ADD_DEFINITIONS(-DDATA_DIR_PREFIX) ENDIF (PREFIX AND NOT WIN32) ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug) - 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_HOME_DIR : ${USE_HOME_DIR}\n") + 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_HOME_DIR : ${USE_HOME_DIR}\n") - MESSAGE(STATUS "LANGUAGES : ${LANGUAGES}\n") + MESSAGE(STATUS "LANGUAGES : ${LANGUAGES}\n") - MESSAGE(STATUS "See INSTALL file for details and more info --\n") + MESSAGE(STATUS "See INSTALL file for details and more info --\n") IF(MSVC) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - add_definitions(-D_AMD64_) - else() - add_definitions(-D_X86_) - endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + add_definitions(-D_AMD64_) + else() + add_definitions(-D_X86_) + endif() ELSE() - SET(CATA_WARNINGS - "-Werror -Wall -Wextra \ - -Wmissing-declarations \ - -Wold-style-cast \ - -Woverloaded-virtual \ - -Wpedantic") + SET(CATA_WARNINGS + "-Werror -Wall -Wextra \ + -Wmissing-declarations \ + -Wold-style-cast \ + -Woverloaded-virtual \ + -Wpedantic") IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") - SET(CATA_WARNINGS "${CATA_WARNINGS} -Wsuggest-override") + SET(CATA_WARNINGS "${CATA_WARNINGS} -Wsuggest-override") ENDIF(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Compact the whitespace in the warning string - string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g") + # Compact the whitespace in the warning string + string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g") ENDIF() SET(CMAKE_CXX_STANDARD 14) # 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] ' from there.\nSee INSTALL file for details and more info\n" - ) + 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] ' from there.\nSee INSTALL file for details and more info\n" + ) ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) #SET(THREADS_USE_PTHREADS_WIN32 True) @@ -247,123 +248,125 @@ FIND_PACKAGE(Threads REQUIRED) # Check for build types and libraries IF(TILES) - # Find SDL, SDL_ttf & SDL_image for graphical install - MESSAGE(STATUS "Searching for SDL2 library --") - FIND_PACKAGE(SDL2) - IF(NOT SDL2_FOUND) - MESSAGE(FATAL_ERROR - "This project requires SDL2 to be installed to be compiled in graphical mode. Please install the SDL2 development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT SDL2_FOUND) - - IF (NOT DYNAMIC_LINKING) - # SDL, SDL_Image, SDL_ttf deps are required for static build - MESSAGE(STATUS "Searching for SDL deps libraries --") - FIND_PACKAGE(Freetype REQUIRED) - FIND_PACKAGE(PNG REQUIRED) - FIND_PACKAGE(JPEG REQUIRED) - FIND_PACKAGE(ZLIB REQUIRED) - FIND_PACKAGE(BZip2 REQUIRED) - ENDIF (NOT DYNAMIC_LINKING) - - MESSAGE(STATUS "Searching for SDL2_image library --") - - MESSAGE(STATUS "Searching for SDL2_TTF library --") - FIND_PACKAGE(SDL2_ttf) - IF(NOT SDL2_TTF_FOUND) - MESSAGE(FATAL_ERROR - "This project requires SDL2_ttf to be installed to be compiled in graphical mode. Please install the SDL2_ttf development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and moreinfo\n" - ) - ENDIF(NOT SDL2_TTF_FOUND) - - MESSAGE(STATUS "Searching for SDL2_image library --\n") - FIND_PACKAGE(SDL2_image) - IF(NOT SDL2_IMAGE_FOUND) - MESSAGE(FATAL_ERROR - "This project requires SDL2_image to be installed to be compiled in graphical mode. Please install the SDL2_image development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT SDL2_IMAGE_FOUND) - ADD_DEFINITIONS(-DTILES) + # Find SDL, SDL_ttf & SDL_image for graphical install + MESSAGE(STATUS "Searching for SDL2 library --") + FIND_PACKAGE(SDL2) + IF(NOT SDL2_FOUND) + MESSAGE(FATAL_ERROR + "This project requires SDL2 to be installed to be compiled in graphical mode. Please install the SDL2 development libraries, or try compiling + without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT SDL2_FOUND) + + IF (NOT DYNAMIC_LINKING) + # SDL, SDL_Image, SDL_ttf deps are required for static build + MESSAGE(STATUS "Searching for SDL deps libraries --") + FIND_PACKAGE(Freetype REQUIRED) + FIND_PACKAGE(PNG REQUIRED) + FIND_PACKAGE(JPEG REQUIRED) + FIND_PACKAGE(ZLIB REQUIRED) + FIND_PACKAGE(BZip2 REQUIRED) + ENDIF (NOT DYNAMIC_LINKING) + + MESSAGE(STATUS "Searching for SDL2_TTF library --") + FIND_PACKAGE(SDL2_ttf) + IF(NOT SDL2_TTF_FOUND) + MESSAGE(FATAL_ERROR + "This project requires SDL2_ttf to be installed to be compiled in graphical mode. Please install the SDL2_ttf development libraries, or try + compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and moreinfo\n" + ) + ENDIF(NOT SDL2_TTF_FOUND) + + MESSAGE(STATUS "Searching for SDL2_image library --\n") + FIND_PACKAGE(SDL2_image) + IF(NOT SDL2_IMAGE_FOUND) + MESSAGE(FATAL_ERROR + "This project requires SDL2_image to be installed to be compiled in graphical mode. Please install the SDL2_image development libraries, or try + compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT SDL2_IMAGE_FOUND) + ADD_DEFINITIONS(-DTILES) ENDIF(TILES) IF(CURSES) - # Find the ncurses library for a text based compile - MESSAGE(STATUS "Searching for Curses library --\n") - SET(CURSES_NEED_NCURSES TRUE) - SET(CURSES_NEED_WIDE TRUE) - FIND_PACKAGE(Curses) - IF(NOT CURSES_FOUND) - 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 the -DTILES=1 for a graphical compilation.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT CURSES_FOUND) + # Find the ncurses library for a text based compile + MESSAGE(STATUS "Searching for Curses library --\n") + SET(CURSES_NEED_NCURSES TRUE) + SET(CURSES_NEED_WIDE TRUE) + FIND_PACKAGE(Curses) + IF(NOT CURSES_FOUND) + 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 the -DTILES=1 for a graphical compilation.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT CURSES_FOUND) ENDIF(CURSES) IF(SOUND) - # You need TILES to be able to use SOUND - IF(NOT TILES) - MESSAGE(FATAL_ERROR - "You must enable graphical support with -DTILES=1 to be able to enable sound support.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT TILES) - - # Sound requires SDL_mixer library - MESSAGE(STATUS "Searching for SDL2_mixer library --\n") - FIND_PACKAGE(SDL2_mixer) - IF(NOT SDL2_MIXER_FOUND) - MESSAGE(FATAL_ERROR - "You need the SDL2_mixer development library to be able to compile with sound enabled.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT SDL2_MIXER_FOUND) + # You need TILES to be able to use SOUND + IF(NOT TILES) + MESSAGE(FATAL_ERROR + "You must enable graphical support with -DTILES=1 to be able to enable sound support.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT TILES) + + # Sound requires SDL_mixer library + MESSAGE(STATUS "Searching for SDL2_mixer library --\n") + FIND_PACKAGE(SDL2_mixer) + IF(NOT SDL2_MIXER_FOUND) + MESSAGE(FATAL_ERROR + "You need the SDL2_mixer development library to be able to compile with sound enabled.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT SDL2_MIXER_FOUND) ENDIF(SOUND) IF(BACKTRACE) - ADD_DEFINITIONS(-DBACKTRACE) + ADD_DEFINITIONS(-DBACKTRACE) ENDIF(BACKTRACE) # Ok. Now create build and install recipes IF(LOCALIZE) - IF(WIN32) - FIND_PACKAGE(Libintl) - IF(NOT LIBINTL_FOUND) - MESSAGE(FATAL_ERROR - "You need the libintl development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT LIBINTL_FOUND) - FIND_PACKAGE(Iconv) - IF(NOT ICONV_FOUND) - MESSAGE(FATAL_ERROR - "You need the iconv development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n" - ) - ENDIF(NOT ICONV_FOUND) - ENDIF(WIN32) - add_subdirectory(lang) - ADD_DEFINITIONS(-DLOCALIZE) + IF(WIN32) + FIND_PACKAGE(Libintl) + IF(NOT LIBINTL_FOUND) + MESSAGE(FATAL_ERROR + "You need the libintl development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT LIBINTL_FOUND) + FIND_PACKAGE(Iconv) + IF(NOT ICONV_FOUND) + MESSAGE(FATAL_ERROr + "You need the iconv development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n" + ) + ENDIF(NOT ICONV_FOUND) + ENDIF(WIN32) + add_subdirectory(lang) + ADD_DEFINITIONS(-DLOCALIZE) ENDIF(LOCALIZE) IF(USE_HOME_DIR) - ADD_DEFINITIONS(-DUSE_HOME_DIR) + ADD_DEFINITIONS(-DUSE_HOME_DIR) ENDIF(USE_HOME_DIR) add_subdirectory(src) add_subdirectory(data) if (NOT MSVC) - add_subdirectory(src/chkjson) + add_subdirectory(src/chkjson) endif() add_subdirectory(tests) if (CATA_CLANG_TIDY_PLUGIN) - add_subdirectory(tools/clang-tidy-plugin) + add_subdirectory(tools/clang-tidy-plugin) endif() CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY + "${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" + "${CMAKE_COMMAND}" + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) find_program(CCACHE_FOUND ccache) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 9ef2bc3a24ac0..41fac38d3ec55 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,39 +1,39 @@ # Cataclysm data files -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.4) SET(CATACLYSM_DATA_DIRS - ${CMAKE_SOURCE_DIR}/data/font - ${CMAKE_SOURCE_DIR}/data/json - ${CMAKE_SOURCE_DIR}/data/mods - ${CMAKE_SOURCE_DIR}/data/names - ${CMAKE_SOURCE_DIR}/data/raw - ${CMAKE_SOURCE_DIR}/data/motd - ${CMAKE_SOURCE_DIR}/data/credits - ${CMAKE_SOURCE_DIR}/data/title + ${CMAKE_SOURCE_DIR}/data/font + ${CMAKE_SOURCE_DIR}/data/json + ${CMAKE_SOURCE_DIR}/data/mods + ${CMAKE_SOURCE_DIR}/data/names + ${CMAKE_SOURCE_DIR}/data/raw + ${CMAKE_SOURCE_DIR}/data/motd + ${CMAKE_SOURCE_DIR}/data/credits + ${CMAKE_SOURCE_DIR}/data/title ) IF(SOUND) - SET(CATACLYSM_DATA_DIRS - ${CATACLYSM_DATA_DIRS} - ${CMAKE_SOURCE_DIR}/data/sound - ) + SET(CATACLYSM_DATA_DIRS + ${CATACLYSM_DATA_DIRS} + ${CMAKE_SOURCE_DIR}/data/sound + ) ENDIF(SOUND) IF(TILES) - SET(CATACLYSM_DATA_DIRS - ${CATACLYSM_DATA_DIRS} - ${CMAKE_SOURCE_DIR}/gfx - ) + SET(CATACLYSM_DATA_DIRS + ${CATACLYSM_DATA_DIRS} + ${CMAKE_SOURCE_DIR}/gfx + ) ENDIF(TILES) SET(CATACLYSM_DATA_FILES - ${CMAKE_SOURCE_DIR}/data/changelog.txt - ${CMAKE_SOURCE_DIR}/data/cataicon.ico - ${CMAKE_SOURCE_DIR}/data/fontdata.json - ${CMAKE_SOURCE_DIR}/LICENSE.txt + ${CMAKE_SOURCE_DIR}/data/changelog.txt + ${CMAKE_SOURCE_DIR}/data/cataicon.ico + ${CMAKE_SOURCE_DIR}/data/fontdata.json + ${CMAKE_SOURCE_DIR}/LICENSE.txt ) IF(RELEASE) - install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) - install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) + install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) + install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) ENDIF(RELEASE) diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index d5dbaa1a2297e..2c7c51f6f2b6e 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -1,88 +1,88 @@ -MESSAGE(STATUS "Process LINGUAS variable --\n") +MESSAGE(STATUS "Process LANGUAGES variable --\n") FIND_PACKAGE(Gettext) IF (NOT GETTEXT_FOUND) - MESSAGE(FATAL_ERROR - "Gettext not found. Install gettext package or diable - localization with: -DLOCALIZE=OFF \nSee INSTALL file for details and more info\n" - ) + MESSAGE(FATAL_ERROR + "Gettext not found. Install gettext package or disable + localization with: -DLOCALIZE=OFF \nSee INSTALL file for details and more info\n" + ) ENDIF (NOT GETTEXT_FOUND) foreach (LANG ${LANGUAGES}) - MESSAGE(STATUS "Add translation for ${LANG}: ${LANG}.po") + MESSAGE(STATUS "Add translation for ${LANG}: ${LANG}.po") endforeach () MESSAGE("\n") # Extract json strings add_custom_target ( - extract_string - COMMAND python lang/extract_json_strings.py - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + extract_string + COMMAND python lang/extract_json_strings.py + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) # Generate cataclysm-dda.pot add_custom_target ( - translations - COMMAND xgettext --default-domain="cataclysm-dda" - --sort-by-file - --add-comments="~" - --output="${CMAKE_SOURCE_DIR}/lang/po/cataclysm-dda.pot" - --keyword="_" - --keyword="pgettext:1c,2" - --keyword="ngettext:1,2" - --from-code="UTF-8" - ${CMAKE_SOURCE_DIR}/src/*.cpp - ${CMAKE_SOURCE_DIR}/src/*.h - ${CMAKE_SOURCE_DIR}/lang/json/*.py - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS extract_string + translations + COMMAND xgettext --default-domain="cataclysm-dda" + --sort-by-file + --add-comments="~" + --output="${CMAKE_SOURCE_DIR}/lang/po/cataclysm-dda.pot" + --keyword="_" + --keyword="pgettext:1c,2" + --keyword="ngettext:1,2" + --from-code="UTF-8" + ${CMAKE_SOURCE_DIR}/src/*.cpp + ${CMAKE_SOURCE_DIR}/src/*.h + ${CMAKE_SOURCE_DIR}/lang/json/*.py + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS extract_string ) add_custom_target ( - translations_prepare - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + translations_prepare + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) # Auto-Compile translation on release builds only IF (RELEASE) - add_custom_target ( - translations_compile - ALL - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS translations_prepare - ) + add_custom_target ( + translations_compile + ALL + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS translations_prepare + ) ELSE (RELEASE) - add_custom_target ( - translations_compile - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS translations_prepare - ) + add_custom_target ( + translations_compile + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS translations_prepare + ) ENDIF (RELEASE) foreach (LANG ${LANGUAGES}) - add_custom_command ( - TARGET translations_prepare - PRE_BUILD - COMMAND ${CMAKE_COMMAND} - -E make_directory ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - add_custom_command ( - TARGET translations_compile - PRE_BUILD - COMMAND - ${GETTEXT_MSGFMT_EXECUTABLE} -f ${CMAKE_SOURCE_DIR}/lang/po/${LANG}.po - -o ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES/cataclysm-dda.mo - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - IF(RELEASE) - IF (${CMAKE_SYSTEM_NAME} MATCHES Windows) - #install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${DATA_PREFIX}) - ELSE (${CMAKE_SYSTEM_NAME} MATCHES Windows) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${LOCALE_DIR}) - ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Windows) - ENDIF(RELEASE) + add_custom_command ( + TARGET translations_prepare + PRE_BUILD + COMMAND ${CMAKE_COMMAND} + -E make_directory ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + add_custom_command ( + TARGET translations_compile + PRE_BUILD + COMMAND + ${GETTEXT_MSGFMT_EXECUTABLE} -f ${CMAKE_SOURCE_DIR}/lang/po/${LANG}.po + -o ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES/cataclysm-dda.mo + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + IF(RELEASE) + IF (${CMAKE_SYSTEM_NAME} MATCHES Windows) + #install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${DATA_PREFIX}) + ELSE (${CMAKE_SYSTEM_NAME} MATCHES Windows) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${LOCALE_DIR}) + ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Windows) + ENDIF(RELEASE) endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81c3622f0e3b5..9f738828d1ba8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,291 +1,286 @@ # Cataclysm DDA client -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.1.4) SET(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp) SET(RESOURCE_RC ${CMAKE_SOURCE_DIR}/src/resource.rc) FILE(GLOB CATACLYSM_DDA_SOURCES - ${CMAKE_SOURCE_DIR}/src/*.cpp) + ${CMAKE_SOURCE_DIR}/src/*.cpp +) LIST(REMOVE_ITEM CATACLYSM_DDA_SOURCES ${MAIN_CPP}) FILE(GLOB CATACLYSM_DDA_HEADERS - ${CMAKE_SOURCE_DIR}/src/*.h) + ${CMAKE_SOURCE_DIR}/src/*.h +) # Get GIT version strings ADD_CUSTOM_TARGET( - get_version - DEPENDS ${CMAKE_SOURCE_DIR}/src/version.h - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + get_version + DEPENDS ${CMAKE_SOURCE_DIR}/src/version.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) ADD_CUSTOM_COMMAND ( - OUTPUT ${CMAKE_SOURCE_DIR}/src/version.h - COMMAND ${CMAKE_COMMAND} - -D SRC=${CMAKE_SOURCE_DIR}/src/version.h.in - -D DST=${CMAKE_SOURCE_DIR}/src/version.h - -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -P ${CMAKE_SOURCE_DIR}/src/version.cmake - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT ${CMAKE_SOURCE_DIR}/src/version.h + COMMAND ${CMAKE_COMMAND} + -D SRC=${CMAKE_SOURCE_DIR}/src/version.h.in + -D DST=${CMAKE_SOURCE_DIR}/src/version.h + -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -P ${CMAKE_SOURCE_DIR}/src/version.cmake + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) # Build tiles version if requested IF(TILES) - add_library(libcataclysm-tiles STATIC - ${CATACLYSM_DDA_SOURCES} - ${CATACLYSM_DDA_HEADERS} - ) - - target_include_directories(libcataclysm-tiles INTERFACE ${CMAKE_SOURCE_DIR}/src) - - IF(WIN32) - ADD_DEFINITIONS(-DUSE_WINMAIN) - ADD_EXECUTABLE(cataclysm-tiles WIN32 - ${MAIN_CPP} - ${RESOURCE_RC} - ) - ELSE(WIN32) - ADD_EXECUTABLE(cataclysm-tiles - ${MAIN_CPP} - ) - ENDIF(WIN32) - - ADD_DEPENDENCIES(libcataclysm-tiles get_version) - - target_link_libraries(cataclysm-tiles libcataclysm-tiles) - target_compile_definitions(libcataclysm-tiles PUBLIC TILES ) - - IF (LOCALIZE) - target_include_directories(libcataclysm-tiles PUBLIC - ${LIBINTL_INCLUDE_DIR} - ${ICONV_INCLUDE_DIR} - ) - target_link_libraries(libcataclysm-tiles - ${LIBINTL_LIBRARIES} - ${ICONV_LIBRARIES} - ) - ENDIF (LOCALIZE) - - IF(CMAKE_USE_PTHREADS_INIT) - target_compile_options(libcataclysm-tiles PUBLIC "-pthread") - ENDIF(CMAKE_USE_PTHREADS_INIT) - - IF(CMAKE_THREAD_LIBS_INIT) - target_link_libraries(libcataclysm-tiles ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(CMAKE_THREAD_LIBS_INIT) - - IF (NOT DYNAMIC_LINKING) - # SDL, SDL_Image, SDL_ttf deps are required for static build - target_include_directories(libcataclysm-tiles PUBLIC - ${FREETYPE_INCLUDE_DIRS} - ${PNG_INCLUDE_DIRS} - ${JPEG_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIRS} - ${BZIP2_INCLUDE_DIR} - ) - target_link_libraries(libcataclysm-tiles - ${FREETYPE_LIBRARIES} - ${PNG_LIBRARIES} - ${JPEG_LIBRARIES} - ${ZLIB_LIBRARIES} - ${BZIP2_LIBRARIES} - ) - ENDIF (NOT DYNAMIC_LINKING) - - target_include_directories(libcataclysm-tiles PUBLIC - ${SDL2_INCLUDE_DIR} - ${SDL2_IMAGE_INCLUDE_DIRS} - ${SDL2_TTF_INCLUDE_DIRS} - ) - target_link_libraries(libcataclysm-tiles - ${SDL2_LIBRARY} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_TTF_LIBRARIES} - ) - - IF(SOUND) - target_compile_definitions(libcataclysm-tiles PUBLIC SDL_SOUND ) - - target_include_directories(libcataclysm-tiles PUBLIC ${OGGVORBIS_INCLUDE_DIR}) - target_link_libraries(libcataclysm-tiles ${OGG_LIBRARY}) - target_link_libraries(libcataclysm-tiles ${VORBIS_LIBRARY}) - target_link_libraries(libcataclysm-tiles ${VORBISFILE_LIBRARY}) - - target_include_directories(libcataclysm-tiles PUBLIC ${SDL2_MIXER_INCLUDE_DIRS}) - target_link_libraries(libcataclysm-tiles ${SDL2_MIXER_LIBRARIES}) - ENDIF(SOUND) - - IF(WIN32) - # Global settings for Windows targets (at end) - target_link_libraries(libcataclysm-tiles gdi32.lib) - target_link_libraries(libcataclysm-tiles winmm.lib) - target_link_libraries(libcataclysm-tiles imm32.lib) - target_link_libraries(libcataclysm-tiles ole32.lib) - target_link_libraries(libcataclysm-tiles oleaut32.lib) - target_link_libraries(libcataclysm-tiles version.lib) - IF (BACKTRACE) - target_link_libraries(libcataclysm-tiles dbghelp.lib) - ENDIF(BACKTRACE) - ENDIF(WIN32) - - IF(RELEASE) - install(TARGETS cataclysm-tiles DESTINATION ${BIN_PREFIX}) - ENDIF(RELEASE) + add_library(libcataclysm-tiles STATIC + ${CATACLYSM_DDA_SOURCES} + ${CATACLYSM_DDA_HEADERS} + ) + target_include_directories(libcataclysm-tiles INTERFACE ${CMAKE_SOURCE_DIR}/src) + + IF(WIN32) + ADD_DEFINITIONS(-DUSE_WINMAIN) + ADD_EXECUTABLE(cataclysm-tiles WIN32 + ${MAIN_CPP} + ${RESOURCE_RC} + ) + ELSE(WIN32) + ADD_EXECUTABLE(cataclysm-tiles + ${MAIN_CPP} + ) + ENDIF(WIN32) + + ADD_DEPENDENCIES(libcataclysm-tiles get_version) + + target_link_libraries(cataclysm-tiles libcataclysm-tiles) + target_compile_definitions(libcataclysm-tiles PUBLIC TILES ) + + IF (LOCALIZE) + target_include_directories(libcataclysm-tiles PUBLIC + ${LIBINTL_INCLUDE_DIR} + ${ICONV_INCLUDE_DIR} + ) + target_link_libraries(libcataclysm-tiles + ${LIBINTL_LIBRARIES} + ${ICONV_LIBRARIES} + ) + ENDIF (LOCALIZE) + + IF(CMAKE_USE_PTHREADS_INIT) + target_compile_options(libcataclysm-tiles PUBLIC "-pthread") + ENDIF(CMAKE_USE_PTHREADS_INIT) + + IF(CMAKE_THREAD_LIBS_INIT) + target_link_libraries(libcataclysm-tiles ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(CMAKE_THREAD_LIBS_INIT) + + IF (NOT DYNAMIC_LINKING) + # SDL, SDL_Image, SDL_ttf deps are required for static build + target_include_directories(libcataclysm-tiles PUBLIC + ${FREETYPE_INCLUDE_DIRS} + ${PNG_INCLUDE_DIRS} + ${JPEG_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIRS} + ${BZIP2_INCLUDE_DIR} + ) + target_link_libraries(libcataclysm-tiles + ${FREETYPE_LIBRARIES} + ${PNG_LIBRARIES} + ${JPEG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${BZIP2_LIBRARIES} + ) + ENDIF (NOT DYNAMIC_LINKING) + target_include_directories(libcataclysm-tiles PUBLIC + ${SDL2_INCLUDE_DIR} + ${SDL2_IMAGE_INCLUDE_DIRS} + ${SDL2_TTF_INCLUDE_DIRS} + ) + target_link_libraries(libcataclysm-tiles + ${SDL2_LIBRARY} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_TTF_LIBRARIES} + ) + + IF(SOUND) + target_compile_definitions(libcataclysm-tiles PUBLIC SDL_SOUND ) + target_include_directories(libcataclysm-tiles PUBLIC ${OGGVORBIS_INCLUDE_DIR}) + target_link_libraries(libcataclysm-tiles ${OGG_LIBRARY}) + target_link_libraries(libcataclysm-tiles ${VORBIS_LIBRARY}) + target_link_libraries(libcataclysm-tiles ${VORBISFILE_LIBRARY}) + target_include_directories(libcataclysm-tiles PUBLIC ${SDL2_MIXER_INCLUDE_DIRS}) + target_link_libraries(libcataclysm-tiles ${SDL2_MIXER_LIBRARIES}) + ENDIF(SOUND) + + IF(WIN32) + # Global settings for Windows targets (at end) + target_link_libraries(libcataclysm-tiles gdi32.lib) + target_link_libraries(libcataclysm-tiles winmm.lib) + target_link_libraries(libcataclysm-tiles imm32.lib) + target_link_libraries(libcataclysm-tiles ole32.lib) + target_link_libraries(libcataclysm-tiles oleaut32.lib) + target_link_libraries(libcataclysm-tiles version.lib) + IF (BACKTRACE) + target_link_libraries(libcataclysm-tiles dbghelp.lib) + ENDIF(BACKTRACE) + ENDIF(WIN32) + + IF(RELEASE) + install(TARGETS cataclysm-tiles DESTINATION ${BIN_PREFIX}) + ENDIF(RELEASE) ENDIF(TILES) # Build curses version if requested IF(CURSES) - add_library(libcataclysm STATIC - ${CATACLYSM_DDA_SOURCES} - ${CATACLYSM_DDA_HEADERS} - ) - - target_include_directories(libcataclysm INTERFACE ${CMAKE_SOURCE_DIR}/src) - - IF(WIN32) - ADD_EXECUTABLE(cataclysm - ${MAIN_CPP} - ${RESOURCE_RC} - ) - ELSE(WIN32) - ADD_EXECUTABLE(cataclysm - ${MAIN_CPP} - ) - ENDIF(WIN32) - - ADD_DEPENDENCIES(libcataclysm get_version) - - target_link_libraries(cataclysm libcataclysm) - - IF (LOCALIZE) - target_include_directories(libcataclysm PUBLIC - ${LIBINTL_INCLUDE_DIR} - ${ICONV_INCLUDE_DIR} - ) - target_link_libraries(libcataclysm - ${LIBINTL_LIBRARIES} - ${ICONV_LIBRARIES} - ) - ENDIF (LOCALIZE) - - target_include_directories(libcataclysm PUBLIC ${CURSES_INCLUDE_DIR}) - target_link_libraries(libcataclysm ${CURSES_LIBRARIES}) - - IF(CMAKE_USE_PTHREADS_INIT) - target_compile_options(libcataclysm PUBLIC "-pthread") - ENDIF(CMAKE_USE_PTHREADS_INIT) - - IF(CMAKE_THREAD_LIBS_INIT) - target_link_libraries(libcataclysm ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(CMAKE_THREAD_LIBS_INIT) - - IF(WIN32) - # Global settings for Windows targets (at end) - target_link_libraries(libcataclysm gdi32.lib) - target_link_libraries(libcataclysm winmm.lib) - target_link_libraries(libcataclysm imm32.lib) - target_link_libraries(libcataclysm ole32.lib) - target_link_libraries(libcataclysm oleaut32.lib) - target_link_libraries(libcataclysm version.lib) - IF (BACKTRACE) - target_link_libraries(libcataclysm dbghelp.lib) - ENDIF(BACKTRACE) - ENDIF(WIN32) - - IF(RELEASE) - install(TARGETS cataclysm DESTINATION ${BIN_PREFIX}) - ENDIF(RELEASE) + add_library(libcataclysm STATIC + ${CATACLYSM_DDA_SOURCES} + ${CATACLYSM_DDA_HEADERS} + ) + target_include_directories(libcataclysm INTERFACE ${CMAKE_SOURCE_DIR}/src) + + IF(WIN32) + ADD_EXECUTABLE(cataclysm + ${MAIN_CPP} + ${RESOURCE_RC} + ) + ELSE(WIN32) + ADD_EXECUTABLE(cataclysm + ${MAIN_CPP} + ) + ENDIF(WIN32) + + ADD_DEPENDENCIES(libcataclysm get_version) + target_link_libraries(cataclysm libcataclysm) + + IF (LOCALIZE) + target_include_directories(libcataclysm PUBLIC + ${LIBINTL_INCLUDE_DIR} + ${ICONV_INCLUDE_DIR} + ) + target_link_libraries(libcataclysm + ${LIBINTL_LIBRARIES} + ${ICONV_LIBRARIES} + ) + ENDIF (LOCALIZE) + + target_include_directories(libcataclysm PUBLIC ${CURSES_INCLUDE_DIR}) + target_link_libraries(libcataclysm ${CURSES_LIBRARIES}) + + IF(CMAKE_USE_PTHREADS_INIT) + target_compile_options(libcataclysm PUBLIC "-pthread") + ENDIF(CMAKE_USE_PTHREADS_INIT) + + IF(CMAKE_THREAD_LIBS_INIT) + target_link_libraries(libcataclysm ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(CMAKE_THREAD_LIBS_INIT) + + IF(WIN32) + # Global settings for Windows targets (at end) + target_link_libraries(libcataclysm gdi32.lib) + target_link_libraries(libcataclysm winmm.lib) + target_link_libraries(libcataclysm imm32.lib) + target_link_libraries(libcataclysm ole32.lib) + target_link_libraries(libcataclysm oleaut32.lib) + target_link_libraries(libcataclysm version.lib) + IF (BACKTRACE) + target_link_libraries(libcataclysm dbghelp.lib) + ENDIF(BACKTRACE) + ENDIF(WIN32) + + IF(RELEASE) + install(TARGETS cataclysm DESTINATION ${BIN_PREFIX}) + ENDIF(RELEASE) ENDIF(CURSES) IF(MINGW AND NOT RELEASE) - # Try to Install shared libraries for dev builds - # - # Note: It is specific to MSYS2 and uses hardcoded versions so - # probly it will fail if you run it :) - - # GCC-specific libraries - find_library(RuntimeLib_GCC_S_DW2_1 "gcc_s_dw2-1") - find_library(RuntimeLib_STDC_PP_6 "stdc++-6") - find_library(RuntimeLib_WINPTHREAD_1 "winpthread-1") - SET(RuntimeLib_GCC_ALL - ${RuntimeLib_GCC_S_DW2_1} - ${RuntimeLib_STDC_PP_6} - ${RuntimeLib_WINPTHREAD_1} - ) - IF (LOCALIZE) - find_library(RuntimeLib_iconv "libiconv-2") - find_library(RuntimeLib_intl "libintl-8") - SET(RuntimeLib_LOCALIZE - ${RuntimeLib_iconv} - ${RuntimeLib_intl} - ) - ENDIF (LOCALIZE) - IF (TILES) - # SDL2 can have a varoius deps. Here you are the MSYS2 ones... - find_library(RuntimeLib_SDL2 "SDL2") - find_library(RuntimeLib_SDL2_IMG "SDL2_image") - find_library(RuntimeLib_png "libpng16-16") - find_library(RuntimeLib_jpeg "libjpeg-8") - find_library(RuntimeLib_jbig "libjbig-0") - find_library(RuntimeLib_tiff "libtiff-5") - find_library(RuntimeLib_webp "libwebp-5") - find_library(RuntimeLib_lzma "liblzma-5") - find_library(RuntimeLib_bz2 "libbz2-1") - find_library(RuntimeLib_zlib "zlib1") - find_library(RuntimeLib_hb "libharfbuzz-0") - find_library(RuntimeLib_SDL2_TTF "SDL2_ttf") - find_library(RuntimeLib_ft "libfreetype-6") - find_library(RuntimeLib_glib "libglib-2.0-0") - SET(RuntimeLib_SDL - ${RuntimeLib_SDL2} - ${RuntimeLib_SDL2_IMG} - ${RuntimeLib_png} - ${RuntimeLib_jpeg} - ${RuntimeLib_jbig} - ${RuntimeLib_tiff} - ${RuntimeLib_webp} - ${RuntimeLib_lzma} - ${RuntimeLib_bz2} - ${RuntimeLib_zlib} - ${RuntimeLib_hb} - ${RuntimeLib_SDL2_TTF} - ${RuntimeLib_ft} - ${RuntimeLib_glib} - ) - IF(SOUND) - find_library(RuntimeLib_SDL_SND "SDL2_mixer") - find_library(RuntimeLib_flak "libFLAC-8") - find_library(RuntimeLib_ogg "libogg-0") - find_library(RuntimeLib_flu "libfluidsynth-1") - find_library(RuntimeLib_port "libportaudio-2") - find_library(RuntimeLib_snd "libsndfile-1") - find_library(RuntimeLib_vorb "libvorbis-0") - find_library(RuntimeLib_vorb_enc "libvorbisenc-2") - find_library(RuntimeLib_vorb_f "libvorbisfile-3") - find_library(RuntimeLib_mod "libmodplug-1") - find_library(RuntimeLib_mpeg "smpeg2") - SET(RuntimeLib_SDL_SOUND - ${RuntimeLib_SDL_SND} - ${RuntimeLib_flak} - ${RuntimeLib_ogg} - ${RuntimeLib_flu} - ${RuntimeLib_port} - ${RuntimeLib_snd} - ${RuntimeLib_vorb} - ${RuntimeLib_vorb_enc} - ${RuntimeLib_vorb_f} - ${RuntimeLib_mod} - ${RuntimeLib_mpeg} - ) - ENDIF(SOUND) - ENDIF (TILES) - install(FILES ${RuntimeLib_GCC_ALL} - ${RuntimeLib_LOCALIZE} - ${RuntimeLib_SDL} - ${RuntimeLib_SDL_SOUND} - DESTINATION ${BIN_PREFIX} - ) + # Try to Install shared libraries for dev builds + # Note: It is specific to MSYS2 and uses hardcoded versions so + # probably it will fail if you run it :) + + # GCC-specific libraries + find_library(RuntimeLib_GCC_S_DW2_1 "gcc_s_dw2-1") + find_library(RuntimeLib_STDC_PP_6 "stdc++-6") + find_library(RuntimeLib_WINPTHREAD_1 "winpthread-1") + SET(RuntimeLib_GCC_ALL + ${RuntimeLib_GCC_S_DW2_1} + ${RuntimeLib_STDC_PP_6} + ${RuntimeLib_WINPTHREAD_1} + ) + IF (LOCALIZE) + find_library(RuntimeLib_iconv "libiconv-2") + find_library(RuntimeLib_intl "libintl-8") + SET(RuntimeLib_LOCALIZE + ${RuntimeLib_iconv} + ${RuntimeLib_intl} + ) + ENDIF (LOCALIZE) + IF (TILES) + # SDL2 can have a varius deps. Here you are the MSYS2 ones... + find_library(RuntimeLib_SDL2 "SDL2") + find_library(RuntimeLib_SDL2_IMG "SDL2_image") + find_library(RuntimeLib_png "libpng16-16") + find_library(RuntimeLib_jpeg "libjpeg-8") + find_library(RuntimeLib_jbig "libjbig-0") + find_library(RuntimeLib_tiff "libtiff-5") + find_library(RuntimeLib_webp "libwebp-5") + find_library(RuntimeLib_lzma "liblzma-5") + find_library(RuntimeLib_bz2 "libbz2-1") + find_library(RuntimeLib_zlib "zlib1") + find_library(RuntimeLib_hb "libharfbuzz-0") + find_library(RuntimeLib_SDL2_TTF "SDL2_ttf") + find_library(RuntimeLib_ft "libfreetype-6") + find_library(RuntimeLib_glib "libglib-2.0-0") + SET(RuntimeLib_SDL + ${RuntimeLib_SDL2} + ${RuntimeLib_SDL2_IMG} + ${RuntimeLib_png} + ${RuntimeLib_jpeg} + ${RuntimeLib_jbig} + ${RuntimeLib_tiff} + ${RuntimeLib_webp} + ${RuntimeLib_lzma} + ${RuntimeLib_bz2} + ${RuntimeLib_zlib} + ${RuntimeLib_hb} + ${RuntimeLib_SDL2_TTF} + ${RuntimeLib_ft} + ${RuntimeLib_glib} + ) + IF(SOUND) + find_library(RuntimeLib_SDL_SND "SDL2_mixer") + find_library(RuntimeLib_flak "libFLAC-8") + find_library(RuntimeLib_ogg "libogg-0") + find_library(RuntimeLib_flu "libfluidsynth-1") + find_library(RuntimeLib_port "libportaudio-2") + find_library(RuntimeLib_snd "libsndfile-1") + find_library(RuntimeLib_vorb "libvorbis-0") + find_library(RuntimeLib_vorb_enc "libvorbisenc-2") + find_library(RuntimeLib_vorb_f "libvorbisfile-3") + find_library(RuntimeLib_mod "libmodplug-1") + find_library(RuntimeLib_mpeg "smpeg2") + SET(RuntimeLib_SDL_SOUND + ${RuntimeLib_SDL_SND} + ${RuntimeLib_flak} + ${RuntimeLib_ogg} + ${RuntimeLib_flu} + ${RuntimeLib_port} + ${RuntimeLib_snd} + ${RuntimeLib_vorb} + ${RuntimeLib_vorb_enc} + ${RuntimeLib_vorb_f} + ${RuntimeLib_mod} + ${RuntimeLib_mpeg} + ) + ENDIF(SOUND) + ENDIF (TILES) + install(FILES ${RuntimeLib_GCC_ALL} + ${RuntimeLib_LOCALIZE} + ${RuntimeLib_SDL} + ${RuntimeLib_SDL_SOUND} + DESTINATION ${BIN_PREFIX} + ) ENDIF(MINGW AND NOT RELEASE) # vim:noet