diff --git a/CMakeLists.txt b/CMakeLists.txt index 914a737713398..672c9cf8d9335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.21) project(CataclysmDDA) -set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} +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) @@ -126,10 +129,10 @@ endif () if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Windows|MSYS)") if (NOT DATA_PREFIX) - set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}) + set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/data) endif () if (NOT LOCALE_DIR) - set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}) + set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/lang) endif () if (NOT BIN_PREFIX) set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -265,7 +268,7 @@ if (TILES) # Find SDL, SDL_ttf & SDL_image for graphical install message(STATUS "Searching for SDL2 library --") find_package(SDL2) - if (NOT SDL2_FOUND) + if (NOT (SDL2_FOUND OR TARGET SDL2::SDL2)) message(FATAL_ERROR "This project requires SDL2 to be installed to compile in graphical mode. \ Please install the SDL2 development libraries, \ @@ -285,7 +288,7 @@ if (TILES) message(STATUS "Searching for SDL2_TTF library --") find_package(SDL2_ttf) - if (NOT SDL2_TTF_FOUND) + if (NOT (SDL2_TTF_FOUND OR TARGET SDL2_ttf::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) message(FATAL_ERROR "This project requires SDL2_ttf to be installed to compile in graphical mode. \ Please install the SDL2_ttf development libraries, \ @@ -294,8 +297,12 @@ if (TILES) endif () message(STATUS "Searching for SDL2_image library --") - find_package(SDL2_image) - if (NOT SDL2_IMAGE_FOUND) + if(VCPKG_MANIFEST_MODE) + find_package(sdl2-image) + else() + find_package(SDL2_image) + endif() + if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image)) message(FATAL_ERROR "This project requires SDL2_image to be installed to compile in graphical mode. \ Please install the SDL2_image development libraries, \ @@ -335,12 +342,21 @@ if (SOUND) # Sound requires SDL_mixer library message(STATUS "Searching for SDL2_mixer library --") 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. \ - See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") - endif () + if(VCPKG_MANIFEST_MODE) + if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static + message(FATAL_ERROR + "You need the SDL2_mixer development library \ + to be able to compile with sound enabled. \ + See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") + endif() + else() + if (NOT SDL2_MIXER_FOUND) + message(FATAL_ERROR + "You need the SDL2_mixer development library \ + to be able to compile with sound enabled. \ + See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") + endif () + endif() endif () if (BACKTRACE) @@ -360,6 +376,14 @@ if (USE_HOME_DIR) add_definitions(-DUSE_HOME_DIR) endif () +find_program(CCACHE_FOUND ccache) +if (CCACHE_FOUND AND CATA_CCACHE) + set(CMAKE_C_COMPILER_LAUNCHER ccache) + set(CMAKE_CXX_COMPILER_LAUNCHER ccache) + set(CMAKE_C_LINKER_LAUNCHER ccache) + set(CMAKE_CXX_LINKER_LAUNCHER ccache) +endif () + add_subdirectory(src) add_subdirectory(data) if (NOT MSVC) @@ -382,9 +406,3 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -find_program(CCACHE_FOUND ccache) -if (CCACHE_FOUND AND CATA_CCACHE) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) -endif () - diff --git a/CMakeModules/FindIconv.cmake b/CMakeModules/Find/FindIconv.cmake similarity index 100% rename from CMakeModules/FindIconv.cmake rename to CMakeModules/Find/FindIconv.cmake diff --git a/CMakeModules/FindLibintl.cmake b/CMakeModules/Find/FindLibintl.cmake similarity index 100% rename from CMakeModules/FindLibintl.cmake rename to CMakeModules/Find/FindLibintl.cmake diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/Find/FindSDL2.cmake similarity index 100% rename from CMakeModules/FindSDL2.cmake rename to CMakeModules/Find/FindSDL2.cmake diff --git a/CMakeModules/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake similarity index 100% rename from CMakeModules/FindSDL2_image.cmake rename to CMakeModules/Find/FindSDL2_image.cmake diff --git a/CMakeModules/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake similarity index 100% rename from CMakeModules/FindSDL2_mixer.cmake rename to CMakeModules/Find/FindSDL2_mixer.cmake diff --git a/CMakeModules/FindSDL2_ttf.cmake b/CMakeModules/Find/FindSDL2_ttf.cmake similarity index 100% rename from CMakeModules/FindSDL2_ttf.cmake rename to CMakeModules/Find/FindSDL2_ttf.cmake diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index fcfd8d57e2f9d..07e3e8dba73c6 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -18,19 +18,21 @@ if (SOUND) ${CMAKE_SOURCE_DIR}/data/sound) endif () -if (TILES) - set(CATACLYSM_DATA_DIRS - ${CATACLYSM_DATA_DIRS} - ${CMAKE_SOURCE_DIR}/gfx) -endif () - 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/fontdata.json) if (RELEASE) install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) + install(FILES + ${CMAKE_SOURCE_DIR}/README.md + ${CMAKE_SOURCE_DIR}/LICENSE.txt + ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt + DESTINATION ${CMAKE_INSTALL_PREFIX}) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc DESTINATION ${CMAKE_INSTALL_PREFIX}) + if (TILES) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif() endif () diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index d27056140c996..0a3cdcbba3e49 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -77,13 +77,16 @@ else () DEPENDS translations_prepare) endif () +set(DIRS "${LANGUAGES}") +list(TRANSFORM DIRS REPLACE "\(.+\)" lang/mo/\\1/LC_MESSAGES) +add_custom_command( + TARGET translations_prepare + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E + make_directory ${DIRS} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + 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 @@ -92,7 +95,7 @@ foreach (LANG ${LANGUAGES}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) if (RELEASE) if ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") - #install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${DATA_PREFIX}) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${LOCALE_DIR}/mo) else () install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${LOCALE_DIR}) endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02af0cc502378..f9a6479cf4076 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.21) add_subdirectory(${CMAKE_SOURCE_DIR}/src/third-party) @@ -44,7 +44,7 @@ if (TILES) ${CATACLYSM_DDA_HEADERS}) target_include_directories(cataclysm-tiles-common INTERFACE ${CMAKE_SOURCE_DIR}/src) - target_link_libraries(cataclysm-tiles-common third-party) + target_link_libraries(cataclysm-tiles-common PUBLIC third-party) if (WIN32) add_definitions(-DUSE_WINMAIN) @@ -81,7 +81,7 @@ if (TILES) endif () if (CMAKE_THREAD_LIBS_INIT) - target_link_libraries(cataclysm-tiles-common ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(cataclysm-tiles-common PUBLIC ${CMAKE_THREAD_LIBS_INIT}) endif () if (NOT DYNAMIC_LINKING) @@ -91,44 +91,60 @@ if (TILES) ${PNG_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR} ${BZIP2_INCLUDE_DIR}) - target_link_libraries(cataclysm-tiles-common + target_link_libraries(cataclysm-tiles-common PUBLIC ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${BZIP2_LIBRARIES}) + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2-static) endif () target_include_directories(cataclysm-tiles-common PUBLIC ${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) - target_link_libraries(cataclysm-tiles-common + target_link_libraries(cataclysm-tiles-common PUBLIC ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${ZLIB_LIBRARIES}) - + if(TARGET SDL2::SDL2) + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2 + SDL2::SDL2main + SDL2::SDL2_image + $,SDL2_ttf::SDL2_ttf,SDL2_ttf::SDL2_ttf-static>) + endif() if (SOUND) + if (VCPKG_MANIFEST_MODE) + find_package(Ogg REQUIRED) + find_package(Vorbis REQUIRED) + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static + Ogg::ogg + Vorbis::vorbis) + endif() target_compile_definitions(cataclysm-tiles-common PUBLIC SDL_SOUND ) target_include_directories(cataclysm-tiles-common PUBLIC ${OGGVORBIS_INCLUDE_DIR}) - target_link_libraries(cataclysm-tiles-common ${OGG_LIBRARY}) - target_link_libraries(cataclysm-tiles-common ${VORBIS_LIBRARY}) - target_link_libraries(cataclysm-tiles-common ${VORBISFILE_LIBRARY}) + target_link_libraries(cataclysm-tiles-common PUBLIC ${OGG_LIBRARY}) + target_link_libraries(cataclysm-tiles-common PUBLIC ${VORBIS_LIBRARY}) + target_link_libraries(cataclysm-tiles-common PUBLIC ${VORBISFILE_LIBRARY}) target_include_directories(cataclysm-tiles-common PUBLIC ${SDL2_MIXER_INCLUDE_DIRS}) - target_link_libraries(cataclysm-tiles-common ${SDL2_MIXER_LIBRARIES}) + target_link_libraries(cataclysm-tiles-common PUBLIC ${SDL2_MIXER_LIBRARIES}) endif () if (WIN32) # Global settings for Windows targets (at end) - target_link_libraries(cataclysm-tiles-common gdi32.lib) - target_link_libraries(cataclysm-tiles-common winmm.lib) - target_link_libraries(cataclysm-tiles-common imm32.lib) - target_link_libraries(cataclysm-tiles-common ole32.lib) - target_link_libraries(cataclysm-tiles-common oleaut32.lib) - target_link_libraries(cataclysm-tiles-common version.lib) - target_link_libraries(cataclysm-tiles-common setupapi.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC gdi32.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC winmm.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC imm32.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC ole32.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC oleaut32.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC version.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC setupapi.lib) if (BACKTRACE) - target_link_libraries(cataclysm-tiles-common dbghelp.lib) + target_link_libraries(cataclysm-tiles-common PUBLIC dbghelp.lib) + if (LIBBACKTRACE) + target_link_libraries(cataclysm-tiles-common PUBLIC backtrace) + endif () endif () endif ()