From 01c9ee69aeb8b9821da5eb3c073978f6f43801f3 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 16 Apr 2022 01:38:29 +0200 Subject: [PATCH 001/188] Add build options from Cataclysm-common.props --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 700800055b7a..3595a3db076e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,6 +246,25 @@ if (MSVC) else () add_definitions(-D_X86_) endif () + add_compile_options( + /utf-8 + /bigobj + /wd4068 # unknown pragma + /wd4146 # negate unsigned + /wd4819 # codepage? + /wd6237 # short-circuit eval + /wd6319 # a, b: unused a + /wd26444 # unnamed objects + /wd26451 # overflow + /wd26495 # uninitialized member + ) + add_compile_definitions( + _SCL_SECURE_NO_WARNINGS + _CTR_SECURE_NO_WARNINGS + WIN32_LEAN_AND_MEAN + LOCALIZE + USE_VCPKG + ) else () set(CATA_WARNINGS "-Werror -Wall -Wextra \ From 2937a62197b65817c3aa8f9291a61560d21de52c Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 16:51:59 +0200 Subject: [PATCH 002/188] Add more build options from msvc-full-features/ --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3595a3db076e..11191a70ccb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,6 +249,9 @@ if (MSVC) add_compile_options( /utf-8 /bigobj + /permissive- + /sdl- + /GS- /wd4068 # unknown pragma /wd4146 # negate unsigned /wd4819 # codepage? @@ -265,6 +268,9 @@ if (MSVC) LOCALIZE USE_VCPKG ) + add_link_options( + /LTCG:OFF + ) else () set(CATA_WARNINGS "-Werror -Wall -Wextra \ From 7c9448422b5f2fa76bcd761383932870a77fa9f5 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 16:52:34 +0200 Subject: [PATCH 003/188] Use main-pch instead of stdafx.h --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 843e9fef3317..bf50b733a0bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,7 @@ if (TILES) target_link_libraries(cataclysm-tiles cataclysm-tiles-common) target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) + target_precompile_headers(cataclysm-tiles-common PUBLIC ../pch/main-pch.hpp) if (NOT DYNAMIC_LINKING) # SDL, SDL_Image, SDL_ttf deps are required for static build target_include_directories( From 3af7c54bf89ac77bde164426804c0e1cb526f237 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 16:54:35 +0200 Subject: [PATCH 004/188] Copy msvc-full-features/vcpkg.json to source root --- vcpkg.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 vcpkg.json diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000000..c57973639350 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "cdda-vcpkg-dependencies", + "version-string": "0.F", + "dependencies": [ + "sdl2", + "sdl2-image", + { + "name": "sdl2-mixer", + "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] + }, + "sdl2-ttf" + ] +} From 0a599929dac1a6108979e8e7075ec3654a788471 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 16:56:38 +0200 Subject: [PATCH 005/188] Add gettext and its tools as dependency --- tests/CMakeLists.txt | 5 +++++ vcpkg.json | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3ec9fb3ac5b5..49d1b75892d9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,11 @@ if (BUILD_TESTING) # Enabling benchmarks add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) + # TODO: build MO files required for tests + if(MSVC) + find_package(Gettext REQUIRED) + endif() + if (TILES) add_executable(cata_test-tiles ${CATACLYSM_BN_TEST_SOURCES}) if (LUA) diff --git a/vcpkg.json b/vcpkg.json index c57973639350..f7f8f016cbc6 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -8,6 +8,10 @@ "name": "sdl2-mixer", "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] }, - "sdl2-ttf" + "sdl2-ttf", + { + "name": "gettext", + "features": [ "tools" ] + } ] } From e76b3b9a55d5fc03d7b4a39b88460495b63e5895 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 17:18:16 +0200 Subject: [PATCH 006/188] Move MSVC options to own toolchain file --- CMakeLists.txt | 26 +------------------------- build-scripts/MSVC.cmake | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 build-scripts/MSVC.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 11191a70ccb3..4a841d07d2df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,31 +246,7 @@ if (MSVC) else () add_definitions(-D_X86_) endif () - add_compile_options( - /utf-8 - /bigobj - /permissive- - /sdl- - /GS- - /wd4068 # unknown pragma - /wd4146 # negate unsigned - /wd4819 # codepage? - /wd6237 # short-circuit eval - /wd6319 # a, b: unused a - /wd26444 # unnamed objects - /wd26451 # overflow - /wd26495 # uninitialized member - ) - add_compile_definitions( - _SCL_SECURE_NO_WARNINGS - _CTR_SECURE_NO_WARNINGS - WIN32_LEAN_AND_MEAN - LOCALIZE - USE_VCPKG - ) - add_link_options( - /LTCG:OFF - ) + else () set(CATA_WARNINGS "-Werror -Wall -Wextra \ diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake new file mode 100644 index 000000000000..88cc413b1b5f --- /dev/null +++ b/build-scripts/MSVC.cmake @@ -0,0 +1,26 @@ +add_compile_options( + /MP # cl.exe build with multiple processes + /utf-8 + /bigobj + /permissive- + /sdl- + /GS- + /wd4068 # unknown pragma + /wd4146 # negate unsigned + /wd4819 # codepage? + /wd6237 # short-circuit eval + /wd6319 # a, b: unused a + /wd26444 # unnamed objects + /wd26451 # overflow + /wd26495 # uninitialized member +) +add_compile_definitions( + _SCL_SECURE_NO_WARNINGS + _CTR_SECURE_NO_WARNINGS + WIN32_LEAN_AND_MEAN + LOCALIZE + USE_VCPKG +) +add_link_options( + /LTCG:OFF +) From ed077c7c9d2dae4678e1f6af51f2d2e1f7d9b32e Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 17 Apr 2022 17:20:35 +0200 Subject: [PATCH 007/188] Add a CMake presets file created by Visual Studio * Uses vcpkg pointed by VCPKG_ROOT * Uses build-scripts/MSVC.cmake * TILES only for now --- CMakePresets.json | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000000..c793b6d554ac --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,67 @@ +{ + "version": 3, + "configurePresets": [ + { + "environment": { + "VCPKG_ROOT": "C:/vcpkg" + }, + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "name": "windows-base", + "description": "Target Windows with the Visual Studio development environment.", + "hidden": true, + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}", + "cacheVariables": { + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", + "DYNAMIC_LINKING": "True", + "CURSES": "False", + "LOCALIZE": "False", + "TILES": "True" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "x64-debug", + "displayName": "x64 Debug", + "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)", + "inherits": "windows-base", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "x64-release", + "displayName": "x64 Release", + "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", + "inherits": "x64-debug", + "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + }, + { + "name": "x86-debug", + "displayName": "x86 Debug", + "description": "Target Windows (32-bit) with the Visual Studio development environment. (Debug)", + "inherits": "windows-base", + "architecture": { + "value": "x86", + "strategy": "external" + }, + "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "x86-release", + "displayName": "x86 Release", + "description": "Target Windows (32-bit) with the Visual Studio development environment. (RelWithDebInfo)", + "inherits": "x86-debug", + "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + } + ] +} From 6d196004248922f553129b1ee640e5ecf248960a Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:25:19 +0200 Subject: [PATCH 008/188] Fix not finding .lib files --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a841d07d2df..71412632e214 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,9 @@ 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") + 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) @@ -246,7 +248,6 @@ if (MSVC) else () add_definitions(-D_X86_) endif () - else () set(CATA_WARNINGS "-Werror -Wall -Wextra \ From 44e5e780ecaf00c210f94a78286eeeba63fb774b Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:25:59 +0200 Subject: [PATCH 009/188] Do not autogenerate a manifest --- build-scripts/MSVC.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 88cc413b1b5f..a1340d25a4a4 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -23,4 +23,5 @@ add_compile_definitions( ) add_link_options( /LTCG:OFF + /MANIFEST:NO ) From cfd48857cf36f39f51163442a767763b222df867 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:26:27 +0200 Subject: [PATCH 010/188] Add gettext tools only duing Windows builds --- vcpkg.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index f7f8f016cbc6..2417a8f5281c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,8 +10,9 @@ }, "sdl2-ttf", { + "features": [ "tools" ], "name": "gettext", - "features": [ "tools" ] + "platform": "windows" } ] } From 066296e3ac3a29022e08b08c58a4d6d6625fc142 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:28:54 +0200 Subject: [PATCH 011/188] Comment CL flags --- build-scripts/MSVC.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index a1340d25a4a4..5758f94fda0b 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,10 +1,10 @@ add_compile_options( /MP # cl.exe build with multiple processes - /utf-8 - /bigobj - /permissive- - /sdl- - /GS- + /utf-8 # set source and execution character sets to UTF-8 + /bigobj # increase # of sections in object files + /permissive- # to allow alternative operators ("and", "or", "not") + /sdl- # disable additional security checks + /GS- # disable buffer security checks /wd4068 # unknown pragma /wd4146 # negate unsigned /wd4819 # codepage? From 231707c5075f3e2bcf59bd1c54e8257b03c1f822 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:46:14 +0200 Subject: [PATCH 012/188] Expose JPEG library from SDL --- vcpkg.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index 2417a8f5281c..46017d01996a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,10 @@ "version-string": "0.F", "dependencies": [ "sdl2", - "sdl2-image", + { + "name": "sdl2-image", + "features": [ "libjpeg-turbo" ] + }, { "name": "sdl2-mixer", "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] From f81281e67747bb99a71d66fa32696c9df36a52bd Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:47:17 +0200 Subject: [PATCH 013/188] Switch back to Ninja, no build performance gains wtih MSBuild --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index c793b6d554ac..0dd232533e79 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -9,7 +9,7 @@ "name": "windows-base", "description": "Target Windows with the Visual Studio development environment.", "hidden": true, - "generator": "Visual Studio 17 2022", + "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { From 808b0303706882477ca7faddf95a03c16e7bd055 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:48:04 +0200 Subject: [PATCH 014/188] Tell VCPKG to use static linking --- CMakePresets.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 0dd232533e79..100747f64148 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,7 +16,6 @@ "CMAKE_C_COMPILER": "cl.exe", "CMAKE_CXX_COMPILER": "cl.exe", "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", - "DYNAMIC_LINKING": "True", "CURSES": "False", "LOCALIZE": "False", "TILES": "True" @@ -36,14 +35,22 @@ "value": "x64", "strategy": "external" }, - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "DYNAMIC_LINKING": "False", + "VCPKG_TARGET_TRIPLET": "x64-windows-static", + } }, { "name": "x64-release", "displayName": "x64 Release", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "inherits": "x64-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "DYNAMIC_LINKING": "False", + "VCPKG_TARGET_TRIPLET":"x64-windows-static" + } }, { "name": "x86-debug", From 202b679682316dc7ec1502d84bf02b52f10beb0f Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 17 Oct 2023 20:34:19 +0300 Subject: [PATCH 015/188] Revert "build(cmake): deduplicate library setup (#3248)" This reverts commit a5265911435234595120e6315a275d2b1e17718c. --- src/CMakeLists.txt | 89 ++++++++++++++++++++++++-- src/SetupLibrary.cmake | 47 -------------- tools/clang-tidy-plugin/CMakeLists.txt | 5 -- 3 files changed, 83 insertions(+), 58 deletions(-) delete mode 100644 src/SetupLibrary.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf50b733a0bc..cc2b84758057 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,6 @@ # Cataclysm BN client cmake_minimum_required(VERSION 3.16) -include(SetupLibrary.cmake) - set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp) set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp) set(RESOURCE_RC ${CMAKE_SOURCE_DIR}/src/resource.rc) @@ -35,7 +33,14 @@ add_custom_command( # Build tiles version if requested if (TILES) - setup_library(cataclysm-tiles-common) + add_library(cataclysm-tiles-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS} + ${LUA_C_SOURCES}) + target_include_directories(cataclysm-tiles-common INTERFACE ${CMAKE_SOURCE_DIR}/src) + + if (USE_PCH_HEADER) + target_precompile_headers(cataclysm-tiles-common PRIVATE + ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + endif () if (WIN32) add_definitions(-DUSE_WINMAIN) @@ -44,10 +49,27 @@ if (TILES) add_executable(cataclysm-tiles ${MAIN_CPP} ${MESSAGES_CPP}) endif () + if (LUA) + target_compile_definitions(cataclysm-tiles-common PUBLIC LUA) + target_include_directories(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/src) + target_include_directories(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/src/lua) + endif () + + add_dependencies(cataclysm-tiles-common get_version) + target_link_libraries(cataclysm-tiles cataclysm-tiles-common) target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) target_precompile_headers(cataclysm-tiles-common PUBLIC ../pch/main-pch.hpp) + + if (CMAKE_USE_PTHREADS_INIT) + target_compile_options(cataclysm-tiles-common PUBLIC "-pthread") + endif () + + if (CMAKE_THREAD_LIBS_INIT) + target_link_libraries(cataclysm-tiles-common ${CMAKE_THREAD_LIBS_INIT}) + endif () + if (NOT DYNAMIC_LINKING) # SDL, SDL_Image, SDL_ttf deps are required for static build target_include_directories( @@ -74,15 +96,38 @@ if (TILES) target_link_libraries(cataclysm-tiles-common ${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) + + if (BACKTRACE) + target_link_libraries(cataclysm-tiles-common dbghelp.lib) + endif () + endif () + + if (LIBBACKTRACE) + target_link_libraries(cataclysm-tiles-common backtrace) + endif () + if (RELEASE) install(TARGETS cataclysm-tiles DESTINATION ${BIN_PREFIX}) endif () - endif () # Build curses version if requested if (CURSES) - setup_library(cataclysm-common) + add_library(cataclysm-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS} + ${LUA_C_SOURCES}) + target_include_directories(cataclysm-common INTERFACE ${CMAKE_SOURCE_DIR}/src) + + if (USE_PCH_HEADER) + target_precompile_headers(cataclysm-common PRIVATE ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + endif () if (WIN32) add_executable(cataclysm ${MAIN_CPP} ${MESSAGES_CPP} ${RESOURCE_RC}) @@ -90,15 +135,47 @@ if (CURSES) add_executable(cataclysm ${MAIN_CPP} ${MESSAGES_CPP}) endif () + if (LUA) + target_compile_definitions(cataclysm-common PUBLIC LUA) + target_include_directories(cataclysm-common PUBLIC ${CMAKE_SOURCE_DIR}/src) + target_include_directories(cataclysm-common PUBLIC ${CMAKE_SOURCE_DIR}/src/lua) + endif () + + add_dependencies(cataclysm-common get_version) target_link_libraries(cataclysm cataclysm-common) target_include_directories(cataclysm-common PUBLIC ${CURSES_INCLUDE_DIR}) target_link_libraries(cataclysm-common ${CURSES_LIBRARIES}) + if (CMAKE_USE_PTHREADS_INIT) + target_compile_options(cataclysm-common PUBLIC "-pthread") + endif () + + if (CMAKE_THREAD_LIBS_INIT) + target_link_libraries(cataclysm-common ${CMAKE_THREAD_LIBS_INIT}) + endif () + + if (WIN32) + # Global settings for Windows targets (at end) + target_link_libraries(cataclysm-common gdi32.lib) + target_link_libraries(cataclysm-common winmm.lib) + target_link_libraries(cataclysm-common imm32.lib) + target_link_libraries(cataclysm-common ole32.lib) + target_link_libraries(cataclysm-common oleaut32.lib) + target_link_libraries(cataclysm-common version.lib) + + if (BACKTRACE) + target_link_libraries(cataclysm-common dbghelp.lib) + endif () + endif () + + if (LIBBACKTRACE) + target_link_libraries(cataclysm-common backtrace) + endif () + if (RELEASE) install(TARGETS cataclysm DESTINATION ${BIN_PREFIX}) endif () - endif () if (MINGW AND NOT RELEASE) diff --git a/src/SetupLibrary.cmake b/src/SetupLibrary.cmake deleted file mode 100644 index 1aa47165f4d4..000000000000 --- a/src/SetupLibrary.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-only -# Author: 2023 scarf - -function (setup_library TARGET) - - add_library(${TARGET} OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS} ${LUA_C_SOURCES}) - target_include_directories(${TARGET} INTERFACE ${CMAKE_SOURCE_DIR}/src) - - add_dependencies(${TARGET} get_version) - - if (USE_PCH_HEADER) - target_precompile_headers(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) - endif () - - if (CMAKE_USE_PTHREADS_INIT) - target_compile_options(${TARGET} PUBLIC "-pthread") - endif () - - if (CMAKE_THREAD_LIBS_INIT) - target_link_libraries(${TARGET} ${CMAKE_THREAD_LIBS_INIT}) - endif () - - if (LUA) - target_compile_definitions(${TARGET} PUBLIC LUA) - target_include_directories(${TARGET} PUBLIC ${CMAKE_SOURCE_DIR}/src) - target_include_directories(${TARGET} PUBLIC ${CMAKE_SOURCE_DIR}/src/lua) - endif () - - if (WIN32) - # Global settings for Windows targets (at end) - target_link_libraries(${TARGET} gdi32.lib) - target_link_libraries(${TARGET} winmm.lib) - target_link_libraries(${TARGET} imm32.lib) - target_link_libraries(${TARGET} ole32.lib) - target_link_libraries(${TARGET} oleaut32.lib) - target_link_libraries(${TARGET} version.lib) - - if (BACKTRACE) - target_link_libraries(${TARGET} dbghelp.lib) - endif () - endif () - - if (LIBBACKTRACE) - target_link_libraries(${TARGET} backtrace) - endif () - -endfunction () diff --git a/tools/clang-tidy-plugin/CMakeLists.txt b/tools/clang-tidy-plugin/CMakeLists.txt index 4bd854d2ab1a..baf4cbe53f50 100644 --- a/tools/clang-tidy-plugin/CMakeLists.txt +++ b/tools/clang-tidy-plugin/CMakeLists.txt @@ -30,11 +30,6 @@ target_include_directories(CataAnalyzerPlugin SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS ${CLANG_INCLUDE_DIRS}) if ("${CATA_CLANG_TIDY_INCLUDE_DIR}" STREQUAL "") - # suppress DOWNLOAD_EXTRACT_TIMESTAMP warning - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - cmake_policy(SET CMP0135 NEW) - endif () - set(CTPS_RELEASES https://github.com/jbytheway/clang-tidy-plugin-support/releases/download) set(CTPS_VERSION llvm-12.0.0-r3) set(CTPS_SRC ${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-plugin-support) From b9b2979a6398f6f4eeb4ad8a5749a076fae8b8b0 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 20:48:22 +0200 Subject: [PATCH 016/188] Fix missing symbols required by SDL --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc2b84758057..e060516b6a90 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,7 +104,7 @@ if (TILES) 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) if (BACKTRACE) target_link_libraries(cataclysm-tiles-common dbghelp.lib) endif () From 8467af991f9a9f9b6282411818c44eb23f40eb2d Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 18 Apr 2022 21:20:23 +0200 Subject: [PATCH 017/188] Fix validate_json.py test by removing UTF-8 BOM from presets file --- .editorconfig | 1 + CMakePresets.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 5b6a27beec3c..13288f0c69c2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,6 +15,7 @@ indent_style = tab [*.{json,yml,yaml,md,markdown}] indent_size = 2 +charset = utf-8 [{.clang-tidy,.clang-format}] indent_size = 2 diff --git a/CMakePresets.json b/CMakePresets.json index 100747f64148..2027208bacaa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,4 +1,4 @@ -{ +{ "version": 3, "configurePresets": [ { @@ -38,7 +38,7 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", "DYNAMIC_LINKING": "False", - "VCPKG_TARGET_TRIPLET": "x64-windows-static", + "VCPKG_TARGET_TRIPLET": "x64-windows-static" } }, { From 33d592bd824d012f186f0d0db82239102291e43e Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 30 Apr 2022 19:59:13 +0200 Subject: [PATCH 018/188] Include vcpkg.cmake instead of using as toolchain file --- CMakePresets.json | 1 - build-scripts/MSVC.cmake | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 2027208bacaa..4fdefd917871 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -5,7 +5,6 @@ "environment": { "VCPKG_ROOT": "C:/vcpkg" }, - "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "name": "windows-base", "description": "Target Windows with the Visual Studio development environment.", "hidden": true, diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 5758f94fda0b..f94c71931f14 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -25,3 +25,5 @@ add_link_options( /LTCG:OFF /MANIFEST:NO ) + +include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 9128d7fbbd59c742bf905447177c899ca827a7e0 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 30 Apr 2022 20:00:24 +0200 Subject: [PATCH 019/188] Rewrite presets from scratch --- CMakePresets.json | 77 +++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 49 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 4fdefd917871..3290a2548ef5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,72 +2,51 @@ "version": 3, "configurePresets": [ { - "environment": { - "VCPKG_ROOT": "C:/vcpkg" - }, - "name": "windows-base", - "description": "Target Windows with the Visual Studio development environment.", - "hidden": true, + "name": "base", + "description": "Base Build Configuration", "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", - "CURSES": "False", - "LOCALIZE": "False", - "TILES": "True" - }, + "hidden": true + }, + { + "name": "windows", + "description": "Windows Build Configuration", "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" - } + }, + "hidden": true }, { - "name": "x64-debug", - "displayName": "x64 Debug", - "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)", - "inherits": "windows-base", - "architecture": { - "value": "x64", - "strategy": "external" - }, + "name": "visual-c++", + "inherits": [ "windows" ], + "description": "Visual C++ Configuration", + "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", + "hidden": true + }, + { + "name": "x64-windows-static", + "inherits": [ "base", "visual-c++" ], + "description": "Link Statically", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "DYNAMIC_LINKING": "False", - "VCPKG_TARGET_TRIPLET": "x64-windows-static" - } + "VCPKG_TARGET_TRIPLET": "x64-windows-static", + "DYNAMIC_LINKING": "False" + }, + "hidden": true }, { "name": "x64-release", + "inherits": [ "x64-windows-static" ], "displayName": "x64 Release", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", - "inherits": "x64-debug", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "DYNAMIC_LINKING": "False", - "VCPKG_TARGET_TRIPLET":"x64-windows-static" + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CURSES": "False", + "LOCALIZE": "False", + "TILES": "True" } - }, - { - "name": "x86-debug", - "displayName": "x86 Debug", - "description": "Target Windows (32-bit) with the Visual Studio development environment. (Debug)", - "inherits": "windows-base", - "architecture": { - "value": "x86", - "strategy": "external" - }, - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } - }, - { - "name": "x86-release", - "displayName": "x86 Release", - "description": "Target Windows (32-bit) with the Visual Studio development environment. (RelWithDebInfo)", - "inherits": "x86-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } } ] } From 46fb1e19bcb00d6fd320d0d271d228cc2d03d92e Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 30 Apr 2022 20:01:08 +0200 Subject: [PATCH 020/188] Find VCPK installation through env --- CMakePresets.json | 1 + build-scripts/FindVCPKG.cmake | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 build-scripts/FindVCPKG.cmake diff --git a/CMakePresets.json b/CMakePresets.json index 3290a2548ef5..8a706f14e583 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -42,6 +42,7 @@ "displayName": "x64 Release", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "cacheVariables": { + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/FindVCPKG.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "False", diff --git a/build-scripts/FindVCPKG.cmake b/build-scripts/FindVCPKG.cmake new file mode 100644 index 000000000000..5dc0fa4646e2 --- /dev/null +++ b/build-scripts/FindVCPKG.cmake @@ -0,0 +1,6 @@ +if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") + set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) +endif() +if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) + set(ENV{VCPKG_ROOT} C:/vcpkg) +endif() From 5d9e05359da160beb04e9d0e15337bdce7043667 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 15:12:09 +0200 Subject: [PATCH 021/188] Move Ninja to MSVC preset --- CMakePresets.json | 2 +- build-scripts/MSVC.cmake | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 8a706f14e583..eb68230e8b7f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -4,7 +4,6 @@ { "name": "base", "description": "Base Build Configuration", - "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "hidden": true @@ -24,6 +23,7 @@ "inherits": [ "windows" ], "description": "Visual C++ Configuration", "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", + "generator": "Ninja", "hidden": true }, { diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index f94c71931f14..7f0b4f704619 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,3 +1,7 @@ +if (NOT $ENV{DevEnvDir}) + set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") +endif() +set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") add_compile_options( /MP # cl.exe build with multiple processes /utf-8 # set source and execution character sets to UTF-8 From a1e326e00b4c94ca54d182352190c6f8a91ba2b4 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:22:35 +0200 Subject: [PATCH 022/188] Upgrade to CMake 3.20 to allow new policies --- CMakeLists.txt | 3 +-- src/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71412632e214..2b750ed9360d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -# Main project build script -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) project(CataclysmBN) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e060516b6a90..ad0b9db58d13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,4 @@ -# Cataclysm BN client -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp) set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp) From d45272501a1fe762d77937df29fa15b707759617 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:23:26 +0200 Subject: [PATCH 023/188] Use CMAKE_CXX_FLAGS_INIT instead of add_compile_options() --- build-scripts/MSVC.cmake | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 7f0b4f704619..be70f685483a 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -2,22 +2,34 @@ if (NOT $ENV{DevEnvDir}) set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") endif() set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") -add_compile_options( - /MP # cl.exe build with multiple processes - /utf-8 # set source and execution character sets to UTF-8 - /bigobj # increase # of sections in object files - /permissive- # to allow alternative operators ("and", "or", "not") - /sdl- # disable additional security checks - /GS- # disable buffer security checks - /wd4068 # unknown pragma - /wd4146 # negate unsigned - /wd4819 # codepage? - /wd6237 # short-circuit eval - /wd6319 # a, b: unused a - /wd26444 # unnamed objects - /wd26451 # overflow - /wd26495 # uninitialized member +set(CMAKE_CXX_FLAGS_INIT "\ +/MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy \ +/wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ +/TP /Zc:forScope /Zc:inline /Zc:wchar_t" ) +# /MP # cl.exe build with multiple processes +# /utf-8 # set source and execution character sets to UTF-8 +# /bigobj # increase # of sections in object files +# /permissive- # to allow alternative operators ("and", "or", "not") +# /sdl- # disable additional security checks +# /FC # full path in compiler messages +# /Gd # __cdecl +# /GS- # disable buffer security checks +# /Gy # Enable Function-Level Linking +# /wd4068 # unknown pragma +# /wd4146 # negate unsigned +# /wd4819 # codepage? +# /wd6237 # short-circuit eval +# /wd6319 # a, b: unused a +# /wd26444 # unnamed objects +# /wd26451 # overflow +# /wd26495 # uninitialized member +# /WX- # (do not) Treat Warnings as Errors +# /W1 # Warning Level +# /TP # every file is a C++ file +# /Zc:forScope # Force Conformance in for Loop Scope +# /Zc:inline # Remove unreferenced COMDAT +# /Zc:wchar_t # wchar_t Is Native Type add_compile_definitions( _SCL_SECURE_NO_WARNINGS _CTR_SECURE_NO_WARNINGS From 581f0809d6674dd1cf243d15d3cdf4819937ad9a Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:23:38 +0200 Subject: [PATCH 024/188] Typo --- build-scripts/MSVC.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index be70f685483a..20c61d37876d 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -32,7 +32,7 @@ set(CMAKE_CXX_FLAGS_INIT "\ # /Zc:wchar_t # wchar_t Is Native Type add_compile_definitions( _SCL_SECURE_NO_WARNINGS - _CTR_SECURE_NO_WARNINGS + _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN LOCALIZE USE_VCPKG From d73fe730568983a11b19a48dca9ae477ca4b7138 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:24:04 +0200 Subject: [PATCH 025/188] Specific flag for RelWithDebInfo --- build-scripts/MSVC.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 20c61d37876d..b8be31183620 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -30,6 +30,11 @@ set(CMAKE_CXX_FLAGS_INIT "\ # /Zc:forScope # Force Conformance in for Loop Scope # /Zc:inline # Remove unreferenced COMDAT # /Zc:wchar_t # wchar_t Is Native Type +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT +"/Oi" +) +# /Ob1 # Inline Function Expansion (1 = only when marked as such) +# /Oi # Generate Intrinsic Functions add_compile_definitions( _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS From d9669df06133b61ed6e7872b2726b12d4562df6a Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:24:44 +0200 Subject: [PATCH 026/188] Set new policies to remove other flags --- build-scripts/MSVC.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index b8be31183620..9e334831f8c1 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -47,4 +47,7 @@ add_link_options( /MANIFEST:NO ) +cmake_policy(SET CMP0092 NEW) # remove /W3 +cmake_policy(SET CMP0117 NEW) # remove /GR (RTTI) + include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 52addbe27e572d53476dc378deb5ab6aa2ca22cf Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:25:14 +0200 Subject: [PATCH 027/188] Allow using /MT --- build-scripts/MSVC.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 9e334831f8c1..8bfa4af20d44 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -50,4 +50,7 @@ add_link_options( cmake_policy(SET CMP0092 NEW) # remove /W3 cmake_policy(SET CMP0117 NEW) # remove /GR (RTTI) +cmake_policy(SET CMP0091 NEW) # to remove fixed /MD ... +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 233205ea646107644d287101b64c71e45453a3d6 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 18:31:52 +0200 Subject: [PATCH 028/188] Add a CMake build preset --- CMakePresets.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index eb68230e8b7f..7f64e69d9706 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -49,5 +49,11 @@ "TILES": "True" } } + ], + "buildPresets": [ + { + "name": "x64-release", + "configurePreset": "x64-release" + } ] } From a055ddbeebbce0b67ef09358f2879b4bb53a732d Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 1 May 2022 22:21:17 +0200 Subject: [PATCH 029/188] Add x64-debug for MSVC --- CMakePresets.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index 7f64e69d9706..bba6915ba001 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -48,12 +48,29 @@ "LOCALIZE": "False", "TILES": "True" } + }, + { + "name": "x64-debug", + "inherits": [ "x64-windows-static" ], + "displayName": "x64 Debug", + "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)", + "cacheVariables": { + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/FindVCPKG.cmake", + "CMAKE_BUILD_TYPE": "Debug", + "CURSES": "False", + "LOCALIZE": "False", + "TILES": "True" + } } ], "buildPresets": [ { "name": "x64-release", "configurePreset": "x64-release" + }, + { + "name": "x64-debug", + "configurePreset": "x64-debug" } ] } From c3a78362b2589db65d091d4e3c33944abc49639f Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 4 May 2022 21:13:21 +0200 Subject: [PATCH 030/188] Add /GF as suggested --- build-scripts/MSVC.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 8bfa4af20d44..7f345b285958 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -3,7 +3,7 @@ if (NOT $ENV{DevEnvDir}) endif() set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") set(CMAKE_CXX_FLAGS_INIT "\ -/MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy \ +/MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ /TP /Zc:forScope /Zc:inline /Zc:wchar_t" ) @@ -16,6 +16,7 @@ set(CMAKE_CXX_FLAGS_INIT "\ # /Gd # __cdecl # /GS- # disable buffer security checks # /Gy # Enable Function-Level Linking +# /GF # Eliminate Duplicate Strings # /wd4068 # unknown pragma # /wd4146 # negate unsigned # /wd4819 # codepage? From 76359cf300f25ebd0fe678dc0b9fe91ebb7190e5 Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 4 May 2022 21:17:38 +0200 Subject: [PATCH 031/188] Removed as requested. CMake version refers --- build-scripts/MSVC.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 7f345b285958..2cb1c657b6eb 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -48,10 +48,7 @@ add_link_options( /MANIFEST:NO ) -cmake_policy(SET CMP0092 NEW) # remove /W3 -cmake_policy(SET CMP0117 NEW) # remove /GR (RTTI) -cmake_policy(SET CMP0091 NEW) # to remove fixed /MD ... set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 09a1387aef3f0af04d81dcdbede3747144a5f2fd Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 4 May 2022 21:46:50 +0200 Subject: [PATCH 032/188] Add /OPT as requested --- build-scripts/MSVC.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 2cb1c657b6eb..5864c1b3530f 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -44,9 +44,14 @@ add_compile_definitions( USE_VCPKG ) add_link_options( + /OPT:REF + /OPT:ICF /LTCG:OFF /MANIFEST:NO ) +# TODO use those two in debug builds only +# /OPT:REF # remove unreferenced COMDATs +# /OPT:ICF # folds identical COMDATs set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") From b6e64adf83ec1a297e28c6d41c1648ec28ac9087 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 5 May 2022 22:38:12 +0200 Subject: [PATCH 033/188] Skip PCH when generating compile_commands.json --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad0b9db58d13..31111e5350ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,9 @@ if (TILES) target_link_libraries(cataclysm-tiles cataclysm-tiles-common) target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) - target_precompile_headers(cataclysm-tiles-common PUBLIC ../pch/main-pch.hpp) + if(NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") + target_precompile_headers(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + endif () if (CMAKE_USE_PTHREADS_INIT) target_compile_options(cataclysm-tiles-common PUBLIC "-pthread") From 95ed3a5d867fcd0661ad713000fc7ce16358275b Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 6 May 2022 17:44:54 +0200 Subject: [PATCH 034/188] tab vs. spaces --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31111e5350ab..6b7a32e138f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,7 +60,7 @@ if (TILES) target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) if(NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") - target_precompile_headers(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + target_precompile_headers(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) endif () if (CMAKE_USE_PTHREADS_INIT) From dab44d8b626c2647e9a7a8498b1b1af13b6678f6 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 6 May 2022 18:25:11 +0200 Subject: [PATCH 035/188] Update CMakeLists.txt Line too long (101/100) --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b7a32e138f2..eabfc0bb160d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,7 +60,8 @@ if (TILES) target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) if(NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") - target_precompile_headers(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + target_precompile_headers(cataclysm-tiles-common PUBLIC + ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) endif () if (CMAKE_USE_PTHREADS_INIT) From 53051914c4b2506dc8f9018cd3565968af33ea7f Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 7 May 2022 10:23:43 +0200 Subject: [PATCH 036/188] Move vcpkg.json into msvc directory --- build-scripts/MSVC.cmake | 1 + msvc-full-features/vcpkg.json | 15 +++++++++++---- vcpkg.json | 21 --------------------- 3 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 vcpkg.json diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 5864c1b3530f..f946ba3b6a55 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -56,4 +56,5 @@ add_link_options( set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") +set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index 90151953352f..750165ed3b31 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -3,12 +3,19 @@ "version-string": "experimental", "dependencies": [ "sdl2", - "sdl2-image", + { + "name": "sdl2-image", + "features": [ "libjpeg-turbo" ] + }, { "name": "sdl2-mixer", "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] }, - "sdl2-ttf" - ], - "builtin-baseline": "a7b6122f6b6504d16d96117336a0562693579933" + "sdl2-ttf", + { + "features": [ "tools" ], + "name": "gettext", + "platform": "windows" + } + ] } diff --git a/vcpkg.json b/vcpkg.json deleted file mode 100644 index 46017d01996a..000000000000 --- a/vcpkg.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "cdda-vcpkg-dependencies", - "version-string": "0.F", - "dependencies": [ - "sdl2", - { - "name": "sdl2-image", - "features": [ "libjpeg-turbo" ] - }, - { - "name": "sdl2-mixer", - "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] - }, - "sdl2-ttf", - { - "features": [ "tools" ], - "name": "gettext", - "platform": "windows" - } - ] -} From 2a2839c7131df5fd4d5387d30a6dbd0eb6f8d5a0 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 7 May 2022 10:24:24 +0200 Subject: [PATCH 037/188] Using project's VCPKG Triplets --- build-scripts/MSVC.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index f946ba3b6a55..41e4057def72 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -57,4 +57,5 @@ add_link_options( set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) +set(VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR}/.github/vcpkg_triplets) include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 7569b52d6be0f7b86795bdefb496010d5223b9ea Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 7 May 2022 11:52:28 +0200 Subject: [PATCH 038/188] Forgot ENV{} is special in if() --- build-scripts/MSVC.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 41e4057def72..cd700c1e6fb6 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,5 +1,5 @@ -if (NOT $ENV{DevEnvDir}) - set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") +if (NOT "$ENV{DevEnvDir}") + set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") endif() set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") set(CMAKE_CXX_FLAGS_INIT "\ From 853d419bf67355028f680fa5d2ecfd701b8e5b65 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:34:43 +0200 Subject: [PATCH 039/188] Edit comments --- build-scripts/MSVC.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index cd700c1e6fb6..1e33d3734953 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,6 +1,8 @@ if (NOT "$ENV{DevEnvDir}") + # Use Community Edition when not specified set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") endif() +# Ninja is provided by Microsoft but not in the Path set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ @@ -49,7 +51,6 @@ add_link_options( /LTCG:OFF /MANIFEST:NO ) -# TODO use those two in debug builds only # /OPT:REF # remove unreferenced COMDATs # /OPT:ICF # folds identical COMDATs From c5c221fe059cc53b46e65a50fea4492fc54de637 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:35:43 +0200 Subject: [PATCH 040/188] Use Windows path separator --- build-scripts/MSVC.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 1e33d3734953..7d3cc9be2a8f 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,9 +1,9 @@ if (NOT "$ENV{DevEnvDir}") # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE") + set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") endif() # Ninja is provided by Microsoft but not in the Path -set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe CACHE PATH "") +set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From 836f4a905b1fb78f0b1f22552a246a6d2b9b01b5 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:36:40 +0200 Subject: [PATCH 041/188] Retrieve VS environment variables from VsDevCmd --- build-scripts/MSVC.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 7d3cc9be2a8f..77fa431aa74a 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -4,6 +4,12 @@ if (NOT "$ENV{DevEnvDir}") endif() # Ninja is provided by Microsoft but not in the Path set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +# Run VsDevCmd.bat and set all environment variables it changes +set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") +cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) +execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _ENV) set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From f19462e244caa2c1ea7eb5914349df6d26c54b1d Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:37:49 +0200 Subject: [PATCH 042/188] Rewrite the list of envs to be a CMake list --- build-scripts/MSVC.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 77fa431aa74a..a415b764c7af 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -10,6 +10,8 @@ cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _ENV) +string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") +string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From 58f7a13707c1cd74e3c9232c48f49d93f7325cf1 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:40:06 +0200 Subject: [PATCH 043/188] Loop over envs modified by VsDevCmd --- build-scripts/MSVC.cmake | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index a415b764c7af..b73f14c59ad5 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -12,6 +12,45 @@ execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set OUTPUT_VARIABLE _ENV) string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") +foreach(_env IN LISTS _ENV) + # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + foreach(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) + endforeach() +endforeach() set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From 0aa24073efe81170e3256b84168e5d0ab978dbfa Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:46:06 +0200 Subject: [PATCH 044/188] Split environment variable in key/value and trim value --- build-scripts/MSVC.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index b73f14c59ad5..52e695297e47 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -13,6 +13,10 @@ execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") foreach(_env IN LISTS _ENV) +string(REGEX MATCH ^[^=]+ _key "${_env}") + string(REGEX MATCH =[^\n]+\n _value "${_env}") + string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin + string(STRIP "${_value}" _value) # Remove \r # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" foreach(_replace ExtensionSdkDir= From f88b80c596287f36d748f5c18df9fc2f2af23577 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:47:09 +0200 Subject: [PATCH 045/188] Set CMake environment with VsDevCmd set values --- build-scripts/MSVC.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 52e695297e47..7e7031bfbf75 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -53,6 +53,9 @@ string(REGEX MATCH ^[^=]+ _key "${_env}") WindowsSdkDir= WindowsSdkVerBinPath= ) + if("${_key}=" STREQUAL "${_replace}") + set(ENV{${_key}} "${_value}") + endif() endforeach() endforeach() set(CMAKE_CXX_FLAGS_INIT "\ From 39df7386b6412d9337f03c62780aacfb2ab85f04 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:48:02 +0200 Subject: [PATCH 046/188] Write a JSON string for CMakeUserPresets build environment --- build-scripts/MSVC.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 7e7031bfbf75..49fe78659f76 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -55,6 +55,13 @@ string(REGEX MATCH ^[^=]+ _key "${_env}") ) if("${_key}=" STREQUAL "${_replace}") set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + else() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + endif() endif() endforeach() endforeach() From 1212b507caaf47de1ba6dcdd7f14d68f526ed160 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:49:03 +0200 Subject: [PATCH 047/188] Write CMakeUserPresets.json based on VsDevCmd envs --- .gitignore | 3 +++ build-scripts/CMakeUserPresets.json.in | 13 +++++++++++++ build-scripts/MSVC.cmake | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 build-scripts/CMakeUserPresets.json.in diff --git a/.gitignore b/.gitignore index 734b36c2e162..0fd7ddde6aab 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,9 @@ Release*/ # Distribution script results /msvc-full-features/distribution +# Temporary CMakeFiles +CMakeUserPresets.json + # Visual Studio 2015 /msvc-full-features/*db /msvc-full-features/ipch diff --git a/build-scripts/CMakeUserPresets.json.in b/build-scripts/CMakeUserPresets.json.in new file mode 100644 index 000000000000..eace3d9736e0 --- /dev/null +++ b/build-scripts/CMakeUserPresets.json.in @@ -0,0 +1,13 @@ +{ + "version": 3, + "buildPresets": [ + { + "name": "x64-release", + "configurePreset": "x64-release", + "environment": { + @_MSVC_DEVENV@ + }, + "verbose": true + } + ] +} diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 49fe78659f76..2d9104259dcf 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -65,6 +65,8 @@ string(REGEX MATCH ^[^=]+ _key "${_env}") endif() endforeach() endforeach() +configure_file(build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json @ONLY) + set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From 2721e18e605cd6d4454a4988db02c41dd75a84ed Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:50:53 +0200 Subject: [PATCH 048/188] Set the C and C++ compilers to VS --- build-scripts/MSVC.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 2d9104259dcf..ecb147ca9fca 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -67,6 +67,9 @@ string(REGEX MATCH ^[^=]+ _key "${_env}") endforeach() configure_file(build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json @ONLY) +# Path has changed, so this configure run will find cl.exe +set(CMAKE_C_COMPILER cl.exe) +set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}) set(CMAKE_CXX_FLAGS_INIT "\ /MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ From 224b16e85cdc966819da4d0ea0c1f7f1ec39c569 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 17:51:33 +0200 Subject: [PATCH 049/188] Remove the CMake build presets now in CMakeUserPreset.json --- CMakePresets.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index bba6915ba001..59489c5e6abb 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -64,10 +64,6 @@ } ], "buildPresets": [ - { - "name": "x64-release", - "configurePreset": "x64-release" - }, { "name": "x64-debug", "configurePreset": "x64-debug" From 9a8edf28cf2ef454926f1d3fc59a38662b7c9f85 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 20:46:23 +0200 Subject: [PATCH 050/188] Moving user presets hack into the include_before script One should not use CMAKE_SOURCE_DIR because changes during compiler features testing and wastes time too. Renaming the script because it's not more just looking for VCPKG. --- CMakePresets.json | 2 +- build-scripts/FindVCPKG.cmake | 6 --- build-scripts/MSVC.cmake | 62 ------------------------- build-scripts/x64-release.cmake | 81 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 69 deletions(-) delete mode 100644 build-scripts/FindVCPKG.cmake create mode 100644 build-scripts/x64-release.cmake diff --git a/CMakePresets.json b/CMakePresets.json index 59489c5e6abb..bcc2dca7ae12 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -42,7 +42,7 @@ "displayName": "x64 Release", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/FindVCPKG.cmake", + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/x64-release.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "False", diff --git a/build-scripts/FindVCPKG.cmake b/build-scripts/FindVCPKG.cmake deleted file mode 100644 index 5dc0fa4646e2..000000000000 --- a/build-scripts/FindVCPKG.cmake +++ /dev/null @@ -1,6 +0,0 @@ -if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") - set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) -endif() -if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) - set(ENV{VCPKG_ROOT} C:/vcpkg) -endif() diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index ecb147ca9fca..099ce818397e 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -4,68 +4,6 @@ if (NOT "$ENV{DevEnvDir}") endif() # Ninja is provided by Microsoft but not in the Path set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") -# Run VsDevCmd.bat and set all environment variables it changes -set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") -cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) -execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE _ENV) -string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") -string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") -foreach(_env IN LISTS _ENV) -string(REGEX MATCH ^[^=]+ _key "${_env}") - string(REGEX MATCH =[^\n]+\n _value "${_env}") - string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin - string(STRIP "${_value}" _value) # Remove \r - # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" - foreach(_replace - ExtensionSdkDir= - Framework40Version= - FrameworkDIR64= - FrameworkDir= - FrameworkVersion64= - FrameworkVersion= - INCLUDE= - LIB= - LIBPATH= - NETFXSDKDir= - Path= - UCRTVersion= - UniversalCRTSdkDir= - VCIDEInstallDir= - VCINSTALLDIR= - VCToolsInstallDir= - VCToolsRedistDir= - VCToolsVersion= - VS170COMNTOOLS= - VSCMD_ARG_HOST_ARCH= - VSCMD_ARG_TGT_ARCH= - VSCMD_ARG_app_plat= - VSCMD_VER= - VSINSTALLDIR= - VisualStudioVersion= - WindowsLibPath= - WindowsSDKLibVersion= - WindowsSDKVersion= - WindowsSDK_ExecutablePath_x64= - WindowsSDK_ExecutablePath_x86= - WindowsSdkBinPath= - WindowsSdkDir= - WindowsSdkVerBinPath= - ) - if("${_key}=" STREQUAL "${_replace}") - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") - endif() - endif() - endforeach() -endforeach() -configure_file(build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json @ONLY) # Path has changed, so this configure run will find cl.exe set(CMAKE_C_COMPILER cl.exe) diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake new file mode 100644 index 000000000000..98cfc5ec657a --- /dev/null +++ b/build-scripts/x64-release.cmake @@ -0,0 +1,81 @@ +if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") + set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) +endif() +if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) + set(ENV{VCPKG_ROOT} C:/vcpkg) +endif() + + +if (NOT "$ENV{DevEnvDir}") + # Use Community Edition when not specified + set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") +endif() +# Ninja is provided by Microsoft but not in the Path +set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") + +# Run VsDevCmd.bat and set all environment variables it changes +set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") +cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) +execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _ENV) +string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") +string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") +foreach(_env IN LISTS _ENV) +string(REGEX MATCH ^[^=]+ _key "${_env}") + string(REGEX MATCH =[^\n]+\n _value "${_env}") + string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin + string(STRIP "${_value}" _value) # Remove \r + # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + foreach(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) + if("${_key}=" STREQUAL "${_replace}") + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + else() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + endif() + endif() + endforeach() +endforeach() +configure_file( + ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in + ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json + @ONLY +) From 7bcf44f0e51e7f928ba4b5d09a6c497d80b1bcce Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 20:47:42 +0200 Subject: [PATCH 051/188] More MS linker flags from linking stage in .vcxproj --- build-scripts/MSVC.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 099ce818397e..25a295d76b97 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -54,13 +54,17 @@ add_link_options( /OPT:ICF /LTCG:OFF /MANIFEST:NO + /INCREMENTAL:NO + /DYNAMICBASE + /NXCOMPAT ) # /OPT:REF # remove unreferenced COMDATs # /OPT:ICF # folds identical COMDATs - +# /DYNAMICBASE # does this app really need ASLR ? +# /NXCOMPAT # same as above +# No need to force /TLBID:1 because is default set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") - set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) set(VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR}/.github/vcpkg_triplets) include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 10ef97f907f43b3bef9d62aa46e93b9bcc4a7b76 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 8 May 2022 21:09:44 +0200 Subject: [PATCH 052/188] Use MinGW's msgfmt.exe from Git for Windows --- tests/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 49d1b75892d9..b7ff959c4c0d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,7 +6,10 @@ if (BUILD_TESTING) # TODO: build MO files required for tests if(MSVC) - find_package(Gettext REQUIRED) + find_program(GETTEXT_MSGFMT_EXECUTABLE + msgfmt.exe + HINTS C:\\Prorogram\ Files\\Git\\mingw64\\bin + ) endif() if (TILES) From ef03937417ef9731a16cd96488541e7c1a7bd41d Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 9 May 2022 18:48:29 +0200 Subject: [PATCH 053/188] Removing vcpkg triplets for gha as requested --- build-scripts/MSVC.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 25a295d76b97..1ce153505d85 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -66,5 +66,4 @@ add_link_options( set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) -set(VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR}/.github/vcpkg_triplets) include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) From 2beee5c01d292fdfa59898f17839b3940ec630e5 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 9 May 2022 18:52:49 +0200 Subject: [PATCH 054/188] Set default msgfmt --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b7ff959c4c0d..63abcbc304e9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,7 @@ if (BUILD_TESTING) add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) # TODO: build MO files required for tests + set(GETTEXT_MSGFMT_EXECUTABLE msgfmt) if(MSVC) find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt.exe From bb8336fece29c2da80b0d34ff3dd5d88d2814c8a Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 9 May 2022 20:21:07 +0200 Subject: [PATCH 055/188] Search ninja.exe only when generator is Ninja* --- build-scripts/MSVC.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 1ce153505d85..cd518b5a2102 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -2,8 +2,10 @@ if (NOT "$ENV{DevEnvDir}") # Use Community Edition when not specified set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") endif() -# Ninja is provided by Microsoft but not in the Path -set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +if(CMAKE_GENERATOR MATCHES ^Ninja) + # Ninja is provided by Microsoft but not in the Path + set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +endif() # Path has changed, so this configure run will find cl.exe set(CMAKE_C_COMPILER cl.exe) From e066ff8c66d7faad7de2871230f46a00a2ea3abb Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 9 May 2022 20:26:36 +0200 Subject: [PATCH 056/188] Add MSYS to find_program msgfmt.exe --- tests/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 63abcbc304e9..4efc7a4d03d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,12 +5,16 @@ if (BUILD_TESTING) add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) # TODO: build MO files required for tests - set(GETTEXT_MSGFMT_EXECUTABLE msgfmt) if(MSVC) find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt.exe - HINTS C:\\Prorogram\ Files\\Git\\mingw64\\bin + HINTS + C:\\msys64\\usr\\bin + C:\\Prorogram\ Files\\Git\\mingw64\\bin + REQUIRED ) + else() + set(GETTEXT_MSGFMT_EXECUTABLE msgfmt) endif() if (TILES) From 699450b26ad80ed1db6ef6d7b32e65fa12abead8 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 12 May 2022 18:32:25 +0200 Subject: [PATCH 057/188] Removing gettext/msgfmt whole build, as requested --- msvc-full-features/vcpkg.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index 750165ed3b31..bc752e821e66 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -11,11 +11,6 @@ "name": "sdl2-mixer", "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] }, - "sdl2-ttf", - { - "features": [ "tools" ], - "name": "gettext", - "platform": "windows" - } + "sdl2-ttf" ] } From 9e5a73b0c924753a3ea18d0835e0854a3d97cc88 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 15 May 2022 16:31:24 +0200 Subject: [PATCH 058/188] Fix sourcing VsDevCmd.bat twice --- build-scripts/x64-release.cmake | 135 +++++++++++++++++--------------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake index 98cfc5ec657a..0cf9d957be5b 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/x64-release.cmake @@ -5,75 +5,80 @@ if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) set(ENV{VCPKG_ROOT} C:/vcpkg) endif() +if("$ENV{VSCMD_VER}" STREQUAL "") + # This cmake process is running under VsDevCmd.bat or VS IDE GUI + # Avoid to run VsDevCmd.bat twice -if (NOT "$ENV{DevEnvDir}") - # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") -endif() -# Ninja is provided by Microsoft but not in the Path -set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") + if (NOT "$ENV{DevEnvDir}") + # Use Community Edition when not specified + set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") + endif() + # Ninja is provided by Microsoft but not in the Path + set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") -# Run VsDevCmd.bat and set all environment variables it changes -set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") -cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) -execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE _ENV) -string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") -string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") -foreach(_env IN LISTS _ENV) -string(REGEX MATCH ^[^=]+ _key "${_env}") - string(REGEX MATCH =[^\n]+\n _value "${_env}") - string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin - string(STRIP "${_value}" _value) # Remove \r - # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" - foreach(_replace - ExtensionSdkDir= - Framework40Version= - FrameworkDIR64= - FrameworkDir= - FrameworkVersion64= - FrameworkVersion= - INCLUDE= - LIB= - LIBPATH= - NETFXSDKDir= - Path= - UCRTVersion= - UniversalCRTSdkDir= - VCIDEInstallDir= - VCINSTALLDIR= - VCToolsInstallDir= - VCToolsRedistDir= - VCToolsVersion= - VS170COMNTOOLS= - VSCMD_ARG_HOST_ARCH= - VSCMD_ARG_TGT_ARCH= - VSCMD_ARG_app_plat= - VSCMD_VER= - VSINSTALLDIR= - VisualStudioVersion= - WindowsLibPath= - WindowsSDKLibVersion= - WindowsSDKVersion= - WindowsSDK_ExecutablePath_x64= - WindowsSDK_ExecutablePath_x86= - WindowsSdkBinPath= - WindowsSdkDir= - WindowsSdkVerBinPath= - ) - if("${_key}=" STREQUAL "${_replace}") - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + # Run VsDevCmd.bat and set all environment variables it changes + set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") + cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) + execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _ENV) + string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") + string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") + foreach(_env IN LISTS _ENV) + string(REGEX MATCH ^[^=]+ _key "${_env}") + string(REGEX MATCH =[^\n]+\n _value "${_env}") + message(XX${_value}XX) + string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin + string(STRIP "${_value}" _value) # Remove \r + # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + foreach(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) + if("${_key}=" STREQUAL "${_replace}") + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + else() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + endif() endif() - endif() + endforeach() endforeach() -endforeach() +endif() # VSCMD_VER configure_file( ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json From 3ede77f3500ef8b41d3f8d8d4e8b83ac83f1bcb9 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 15 May 2022 16:37:31 +0200 Subject: [PATCH 059/188] Enable LOCALIZE in Release --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index bcc2dca7ae12..123e2bf4e2b8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -45,7 +45,7 @@ "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/x64-release.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", - "LOCALIZE": "False", + "LOCALIZE": "True", "TILES": "True" } }, From c6581795a5ecc2b996dc305676aa6999951c80ea Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 6 Jun 2022 10:07:49 +0200 Subject: [PATCH 060/188] PREFIX doesn't go through C preprocessor stringification * Apply -Wno-unknown-warning-option to clang only * Remove GNU C++ extensions * Define PREFIX in prefix.h. Similar as done with version.h Removes the Q/QUOTE stringify macros * Fix cmake-lint --- .gitignore | 1 + CMakeLists.txt | 12 +++++++++++- Makefile | 10 ++++++++-- src/main.cpp | 9 ++++++--- src/prefix.h.in | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/prefix.h.in diff --git a/.gitignore b/.gitignore index 0fd7ddde6aab..4c37b66ae7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ /objwin/ /save/ /src/version.h +/src/prefix.h /sound/ /templates/ /tools/format/json_formatter.cgi diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b750ed9360d..e45891964b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,10 @@ else () AND NOT WIN32 AND USE_PREFIX_DATA_DIR) 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 () endif () @@ -261,8 +265,12 @@ else () -Wsuggest-override \ -Wunused-macros \ -Wzero-as-null-pointer-constant \ - -Wno-unknown-warning-option \ -Wno-range-loop-analysis") + if(Clang STREQUAL ${CMAKE_CXX_COMPILER_ID}) + set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option") + else() + set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning") + endif() if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Windows") set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls") endif () @@ -274,6 +282,8 @@ else () 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}") diff --git a/Makefile b/Makefile index 14f76f4dd1f7..ea2224f6678f 100644 --- a/Makefile +++ b/Makefile @@ -882,7 +882,7 @@ ifeq ($(LTO), 1) endif endif -all: version $(CHECKS) $(TARGET) $(L10N) $(TESTS) +all: version prefix $(CHECKS) $(TARGET) $(L10N) $(TESTS) @ $(TARGET): $(OBJS) $(LUA_OBJS) @@ -913,7 +913,7 @@ else @$(AR) rcs $(BUILD_PREFIX)$(TARGET_NAME).a $(filter-out $(ODIR)/main.o $(ODIR)/messages.o,$(OBJS)) $(LUA_OBJS) endif -.PHONY: version +.PHONY: version prefix version: @( VERSION_STRING=$(VERSION) ; \ VERSION_AUTOMATIC=$(VERSION_AUTOMATIC) ; \ @@ -922,6 +922,12 @@ version: if [ "x$$VERSION_STRING" != "x$$OLDVERSION" ]; then printf '// NOLINT(cata-header-guard)\n#define VERSION "%s"\n' "$$VERSION_STRING" | tee $(SRC_DIR)/version.h ; fi \ ) +prefix: + @( PREFIX_STRING=$(PREFIX) ; \ + [ -e "$(SRC_DIR)/prefix.h" ] && OLDPREFIX=$$(grep PREFIX $(SRC_DIR)/PREFIX.h|cut -d '"' -f2) ; \ + if [ "x$$PREFIX_STRING" != "x$$OLDPREFIX" ]; then printf '// NOLINT(cata-header-guard)\n#define PREFIX "%s"\n' "$$PREFIX_STRING" | tee $(SRC_DIR)/prefix.h ; fi \ + ) + # Unconditionally create the object dir on every invocation. $(shell mkdir -p $(ODIR)) $(shell mkdir -p $(ODIRLUA)) diff --git a/src/main.cpp b/src/main.cpp index 739a52d924e9..a1cfab0fc4a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,6 +44,11 @@ #include "type_id.h" #include "ui_manager.h" +#if defined(PREFIX) +# undef PREFIX +# include "prefix.h" +#endif + class ui_adaptor; #if defined(TILES) @@ -215,9 +220,7 @@ int main( int argc, char *argv[] ) #else // Set default file paths #if defined(PREFIX) -#define Q(STR) #STR -#define QUOTE(STR) Q(STR) - PATH_INFO::init_base_path( std::string( QUOTE( PREFIX ) ) ); + PATH_INFO::init_base_path( std::string( PREFIX ) ); #else PATH_INFO::init_base_path( "" ); #endif diff --git a/src/prefix.h.in b/src/prefix.h.in new file mode 100644 index 000000000000..4631a2d0312f --- /dev/null +++ b/src/prefix.h.in @@ -0,0 +1 @@ +#define PREFIX "@PREFIX@" From 33fc43397bb6b4f03e9e671b457dd8f2a39d4a7e Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Sun, 19 Jun 2022 20:42:51 -0400 Subject: [PATCH 061/188] Correct logic for -Wno-unknown-warning-option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Correct logic for -Wno-unknown-warning-option It looks like both AppleClang and LLVM Clang use -Wno-unknown-warning-option instead of -Wno-unknown-warning, so this updates the logic from b1e5ada to match that. It'd probably also be possible to just add both -Wno-unknown-warning and -Wno-unknown-warning-option, but who knows. * Quote in if condition of CMakeLists.txt Co-authored-by: Jianxiang Wang (王健翔) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e45891964b19..4e3dc6708e25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,7 +266,7 @@ else () -Wunused-macros \ -Wzero-as-null-pointer-constant \ -Wno-range-loop-analysis") - if(Clang STREQUAL ${CMAKE_CXX_COMPILER_ID}) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option") else() set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning") From 1826515950acfbbe69e2e494735519194f945a51 Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Sat, 2 Jul 2022 16:26:00 -0400 Subject: [PATCH 062/188] Use correct cmake variable for prefix.h.in --- src/prefix.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefix.h.in b/src/prefix.h.in index 4631a2d0312f..e3f3bdbaa9cd 100644 --- a/src/prefix.h.in +++ b/src/prefix.h.in @@ -1 +1 @@ -#define PREFIX "@PREFIX@" +#define PREFIX "@CMAKE_INSTALL_PREFIX@" From 366f466f8bf4be0941e5c2822271639d3735484b Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 14 Aug 2022 17:28:35 +0200 Subject: [PATCH 063/188] Use CMake 3.21 or later --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e3dc6708e25..b44960df5c28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.21) project(CataclysmBN) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eabfc0bb160d..b682f0e1c7d1 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) set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp) set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp) From 436c3b239b52b0a0381f1790c37020a4e1be08d3 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 26 May 2022 19:55:28 +0200 Subject: [PATCH 064/188] Change all target_link_libraries to interface form --- src/CMakeLists.txt | 61 +++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b682f0e1c7d1..ff40f5a42eac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,46 +69,57 @@ 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) # SDL, SDL_Image, SDL_ttf deps are required for static build - target_include_directories( - cataclysm-tiles-common - PUBLIC ${FREETYPE_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIRS} ${BZIP2_INCLUDE_DIR}) - target_link_libraries(cataclysm-tiles-common ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} - ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES}) + target_include_directories(cataclysm-tiles-common PUBLIC + ${FREETYPE_INCLUDE_DIRS} + ${PNG_INCLUDE_DIRS} + ${JPEG_INCLUDE_DIR} + ${BZIP2_INCLUDE_DIR}) + target_link_libraries(cataclysm-tiles-common PUBLIC + ${FREETYPE_LIBRARIES} + ${PNG_LIBRARIES} + ${JPEG_LIBRARIES} + ${BZIP2_LIBRARIES}) endif () - - target_include_directories( - cataclysm-tiles-common PUBLIC ${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIRS} - ${SDL2_TTF_INCLUDE_DIRS}) - target_link_libraries(cataclysm-tiles-common ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARIES} - ${SDL2_TTF_LIBRARIES}) + 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 PUBLIC + ${SDL2_LIBRARY} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_TTF_LIBRARIES} + ${ZLIB_LIBRARIES}) if (SOUND) 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 () From 5fe91dcd83121d747db7d008c6c7baecb9b665e4 Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 24 May 2022 23:01:18 +0200 Subject: [PATCH 065/188] Change find_package if using VCPKG manitest - Add all SDL2:: targets found by VCPKG - Fix clang-tidy and cmake-lint --- CMakeLists.txt | 33 +++++++++++++++++++++++---------- src/CMakeLists.txt | 17 +++++++++++++++-- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b44960df5c28..8a34f9df1ac3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,7 +304,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 be compiled in graphical mode. \ @@ -325,7 +325,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 be compiled in graphical mode. \ @@ -335,8 +335,12 @@ if (TILES) endif () message(STATUS "Searching for SDL2_image library --\n") - 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 be compiled in graphical mode. \ @@ -378,12 +382,21 @@ if (SOUND) # 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. \ - See CMake compiling guide 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 CMake compiling guide 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 CMake compiling guide for details and more info.") + endif () + endif() endif () if (BACKTRACE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff40f5a42eac..7cd4d5d98009 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,7 @@ if (TILES) ${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} @@ -95,9 +96,21 @@ if (TILES) ${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) - target_compile_definitions(cataclysm-tiles-common PUBLIC SDL_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 PUBLIC ${OGG_LIBRARY}) target_link_libraries(cataclysm-tiles-common PUBLIC ${VORBIS_LIBRARY}) From 14e4db26265625bcc91678b0a4a60566ac65bc31 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 14 Aug 2022 21:32:55 +0200 Subject: [PATCH 066/188] Set the correct property for using ccache --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a34f9df1ac3..494a3c090a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -431,8 +431,10 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P 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) + 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 () if (USE_UNITY_BUILD) From 141cceeb4f23f7de007368eff272783a45f5becc Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 14 Aug 2022 22:35:58 +0200 Subject: [PATCH 067/188] Set compiler launchers before adding subdirectories --- CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 494a3c090a6f..f511f6dbb0a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,6 +411,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) add_subdirectory(lang) @@ -429,15 +437,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" 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(CMAKE_C_COMPILER_LAUNCHER ccache) - set(CMAKE_CXX_COMPILER_LAUNCHER ccache) - set(CMAKE_C_LINKER_LAUNCHER ccache) - set(CMAKE_CXX_LINKER_LAUNCHER ccache) -endif () - if (USE_UNITY_BUILD) set_property(GLOBAL PROPERTY UNITY_BUILD ON) endif () -# vim:noet From f7fd170b2be4a4f173974f3071999dd1e97c688c Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 20 Sep 2022 16:31:04 +0200 Subject: [PATCH 068/188] Fix release installation paths --- CMakeLists.txt | 2 +- data/CMakeLists.txt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f511f6dbb0a6..48b87f8964c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ 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 BIN_PREFIX) set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 6d3c79e04730..f8e984b368d8 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -16,14 +16,13 @@ if (SOUND) set(CATACLYSM_DATA_DIRS ${CATACLYSM_DATA_DIRS} ${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}/LICENSE.txt) if (RELEASE) install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) + if (TILES) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif() endif () From c0abe812b56f986b680f6f1ef306edc54d8163bd Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 20 Sep 2022 18:08:45 +0200 Subject: [PATCH 069/188] Align CMake release install --- data/CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index f8e984b368d8..90a0b22e5be5 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -16,13 +16,20 @@ if (SOUND) set(CATACLYSM_DATA_DIRS ${CATACLYSM_DATA_DIRS} ${CMAKE_SOURCE_DIR}/data/sound) endif () -set(CATACLYSM_DATA_FILES ${CMAKE_SOURCE_DIR}/data/changelog.txt - ${CMAKE_SOURCE_DIR}/data/cataicon.ico ${CMAKE_SOURCE_DIR}/LICENSE.txt) +set(CATACLYSM_DATA_FILES + ${CMAKE_SOURCE_DIR}/data/changelog.txt + ${CMAKE_SOURCE_DIR}/data/cataicon.ico) 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}) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${CMAKE_INSTALL_PREFIX}) endif() endif () From 157871aac62ad05b80cc5f1f890065630cd5923d Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 14 Aug 2022 17:41:48 +0200 Subject: [PATCH 070/188] Do not use our Find* modules under VCPKG --- CMakeLists.txt | 7 ++++++- CMakeModules/{ => Find}/FindSDL2.cmake | 0 CMakeModules/{ => Find}/FindSDL2_image.cmake | 0 CMakeModules/{ => Find}/FindSDL2_mixer.cmake | 0 CMakeModules/{ => Find}/FindSDL2_ttf.cmake | 0 5 files changed, 6 insertions(+), 1 deletion(-) rename CMakeModules/{ => Find}/FindSDL2.cmake (100%) rename CMakeModules/{ => Find}/FindSDL2_image.cmake (100%) rename CMakeModules/{ => Find}/FindSDL2_mixer.cmake (100%) rename CMakeModules/{ => Find}/FindSDL2_ttf.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48b87f8964c8..db88ffbcabc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.21) project(CataclysmBN) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) +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() include(AstyleFormatSource) 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 From db6584d92fb769bb540d50d2c80e3cc76151c33d Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 27 May 2022 12:20:52 +0200 Subject: [PATCH 071/188] Remove redundant modules from CMakeModules CMakeParseArguments.cmake since v3.4 CMakePushCheckState.cmake since v2.8.6 CheckLibraryExists since v2.8.2 FindCurses since v3.21.0 FindPackageHandleStandardArgs since v3.1.0 FindPackageMessage since v3.0.0 --- CMakeModules/CMakeParseArguments.cmake | 160 -------- CMakeModules/CMakePushCheckState.cmake | 120 ------ CMakeModules/CheckLibraryExists.cmake | 78 ---- CMakeModules/FindCurses.cmake | 305 --------------- .../FindPackageHandleStandardArgs.cmake | 351 ------------------ CMakeModules/FindPackageMessage.cmake | 57 --- 6 files changed, 1071 deletions(-) delete mode 100644 CMakeModules/CMakeParseArguments.cmake delete mode 100644 CMakeModules/CMakePushCheckState.cmake delete mode 100644 CMakeModules/CheckLibraryExists.cmake delete mode 100644 CMakeModules/FindCurses.cmake delete mode 100644 CMakeModules/FindPackageHandleStandardArgs.cmake delete mode 100644 CMakeModules/FindPackageMessage.cmake diff --git a/CMakeModules/CMakeParseArguments.cmake b/CMakeModules/CMakeParseArguments.cmake deleted file mode 100644 index 4248176ad664..000000000000 --- a/CMakeModules/CMakeParseArguments.cmake +++ /dev/null @@ -1,160 +0,0 @@ -#.rst: -# CMakeParseArguments -# ------------------- -# -# -# -# CMAKE_PARSE_ARGUMENTS( -# args...) -# -# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions -# for parsing the arguments given to that macro or function. It -# processes the arguments and defines a set of variables which hold the -# values of the respective options. -# -# The argument contains all options for the respective macro, -# i.e. keywords which can be used when calling the macro without any -# value following, like e.g. the OPTIONAL keyword of the install() -# command. -# -# The argument contains all keywords for this macro -# which are followed by one value, like e.g. DESTINATION keyword of the -# install() command. -# -# The argument contains all keywords for this -# macro which can be followed by more than one value, like e.g. the -# TARGETS or FILES keywords of the install() command. -# -# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the -# keywords listed in , and -# a variable composed of the given -# followed by "_" and the name of the respective keyword. These -# variables will then hold the respective value from the argument list. -# For the keywords this will be TRUE or FALSE. -# -# All remaining arguments are collected in a variable -# _UNPARSED_ARGUMENTS, this can be checked afterwards to see -# whether your macro was called with unrecognized parameters. -# -# As an example here a my_install() macro, which takes similar arguments -# as the real install() command: -# -# :: -# -# function(MY_INSTALL) -# set(options OPTIONAL FAST) -# set(oneValueArgs DESTINATION RENAME) -# set(multiValueArgs TARGETS CONFIGURATIONS) -# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) -# ... -# -# -# -# Assume my_install() has been called like this: -# -# :: -# -# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) -# -# -# -# After the cmake_parse_arguments() call the macro will have set the -# following variables: -# -# :: -# -# MY_INSTALL_OPTIONAL = TRUE -# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() -# MY_INSTALL_DESTINATION = "bin" -# MY_INSTALL_RENAME = "" (was not used) -# MY_INSTALL_TARGETS = "foo;bar" -# MY_INSTALL_CONFIGURATIONS = "" (was not used) -# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" -# -# -# -# You can then continue and process these variables. -# -# Keywords terminate lists of values, e.g. if directly after a -# one_value_keyword another recognized keyword follows, this is -# interpreted as the beginning of the new option. E.g. -# my_install(TARGETS foo DESTINATION OPTIONAL) would result in -# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION -# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. - -#============================================================================= -# Copyright 2010 Alexander Neundorf -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - -if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) - return() -endif() -set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - - -function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) - # first set all result variables to empty/FALSE - foreach(arg_name ${_singleArgNames} ${_multiArgNames}) - set(${prefix}_${arg_name}) - endforeach() - - foreach(option ${_optionNames}) - set(${prefix}_${option} FALSE) - endforeach() - - set(${prefix}_UNPARSED_ARGUMENTS) - - set(insideValues FALSE) - set(currentArgName) - - # now iterate over all arguments and fill the result variables - foreach(currentArg ${ARGN}) - list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword - - if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) - if(insideValues) - if("${insideValues}" STREQUAL "SINGLE") - set(${prefix}_${currentArgName} ${currentArg}) - set(insideValues FALSE) - elseif("${insideValues}" STREQUAL "MULTI") - list(APPEND ${prefix}_${currentArgName} ${currentArg}) - endif() - else() - list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) - endif() - else() - if(NOT ${optionIndex} EQUAL -1) - set(${prefix}_${currentArg} TRUE) - set(insideValues FALSE) - elseif(NOT ${singleArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "SINGLE") - elseif(NOT ${multiArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "MULTI") - endif() - endif() - - endforeach() - - # propagate the result variables to the caller: - foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) - endforeach() - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) - -endfunction() diff --git a/CMakeModules/CMakePushCheckState.cmake b/CMakeModules/CMakePushCheckState.cmake deleted file mode 100644 index cc5a93e24c47..000000000000 --- a/CMakeModules/CMakePushCheckState.cmake +++ /dev/null @@ -1,120 +0,0 @@ -#============================================================================= -# Copyright 2000-2022 Kitware, Inc. and Contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= - -#[=======================================================================[.rst: -CMakePushCheckState -------------------- - - - -This module defines three macros: ``CMAKE_PUSH_CHECK_STATE()`` -``CMAKE_POP_CHECK_STATE()`` and ``CMAKE_RESET_CHECK_STATE()`` These macros can -be used to save, restore and reset (i.e., clear contents) the state of -the variables ``CMAKE_REQUIRED_FLAGS``, ``CMAKE_REQUIRED_DEFINITIONS``, -``CMAKE_REQUIRED_LINK_OPTIONS``, ``CMAKE_REQUIRED_LIBRARIES``, -``CMAKE_REQUIRED_INCLUDES`` and ``CMAKE_EXTRA_INCLUDE_FILES`` used by the -various Check-files coming with CMake, like e.g. ``check_function_exists()`` -etc. -The variable contents are pushed on a stack, pushing multiple times is -supported. This is useful e.g. when executing such tests in a Find-module, -where they have to be set, but after the Find-module has been executed they -should have the same value as they had before. - -``CMAKE_PUSH_CHECK_STATE()`` macro receives optional argument ``RESET``. -Whether it's specified, ``CMAKE_PUSH_CHECK_STATE()`` will set all -``CMAKE_REQUIRED_*`` variables to empty values, same as -``CMAKE_RESET_CHECK_STATE()`` call will do. - -Usage: - -.. code-block:: cmake - - cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF) - check_function_exists(...) - cmake_reset_check_state() - set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF) - check_function_exists(...) - cmake_pop_check_state() -#]=======================================================================] - -macro(CMAKE_RESET_CHECK_STATE) - - set(CMAKE_EXTRA_INCLUDE_FILES) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_DEFINITIONS) - set(CMAKE_REQUIRED_LINK_OPTIONS) - set(CMAKE_REQUIRED_LIBRARIES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_QUIET) - -endmacro() - -macro(CMAKE_PUSH_CHECK_STATE) - - if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) - set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) - endif() - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") - - set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) - set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) - set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) - set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS}) - set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) - set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) - set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) - - if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") - cmake_reset_check_state() - endif() - -endmacro() - -macro(CMAKE_POP_CHECK_STATE) - -# don't pop more than we pushed - if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") - - set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") - endif() - -endmacro() diff --git a/CMakeModules/CheckLibraryExists.cmake b/CMakeModules/CheckLibraryExists.cmake deleted file mode 100644 index 67d1b47dd2af..000000000000 --- a/CMakeModules/CheckLibraryExists.cmake +++ /dev/null @@ -1,78 +0,0 @@ -#.rst: -# CheckLibraryExists -# ------------------ -# -# Check if the function exists. -# -# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) -# -# :: -# -# LIBRARY - the name of the library you are looking for -# FUNCTION - the name of the function -# LOCATION - location where the library should be found -# VARIABLE - variable to store the result -# -# -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2002-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - - -macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) - if(${VARIABLE} MATCHES "^${VARIABLE}$") - set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION - "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") - set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) - if(CMAKE_REQUIRED_LIBRARIES) - set(CHECK_LIBRARY_EXISTS_LIBRARIES - ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}) - endif() - try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/CheckFunctionExists.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} - CMAKE_FLAGS - -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION} - -DLINK_DIRECTORIES:STRING=${LOCATION} - OUTPUT_VARIABLE OUTPUT) - - if(${VARIABLE}) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") - set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " - "passed with the following output:\n" - "${OUTPUT}\n\n") - else() - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") - set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " - "failed with the following output:\n" - "${OUTPUT}\n\n") - endif() - endif() -endmacro() diff --git a/CMakeModules/FindCurses.cmake b/CMakeModules/FindCurses.cmake deleted file mode 100644 index dbd252bba695..000000000000 --- a/CMakeModules/FindCurses.cmake +++ /dev/null @@ -1,305 +0,0 @@ -#============================================================================= -# Copyright 2000-2022 Kitware, Inc. and Contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= - -#[=======================================================================[.rst: -FindCurses ----------- - -Find the curses or ncurses include file and library. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -``CURSES_FOUND`` - True if Curses is found. -``CURSES_INCLUDE_DIRS`` - The include directories needed to use Curses. -``CURSES_LIBRARIES`` - The libraries needed to use Curses. -``CURSES_CFLAGS`` - .. versionadded:: 3.16 - - Parameters which ought be given to C/C++ compilers when using Curses. -``CURSES_HAVE_CURSES_H`` - True if curses.h is available. -``CURSES_HAVE_NCURSES_H`` - True if ncurses.h is available. -``CURSES_HAVE_NCURSES_NCURSES_H`` - True if ``ncurses/ncurses.h`` is available. -``CURSES_HAVE_NCURSES_CURSES_H`` - True if ``ncurses/curses.h`` is available. - -Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the -``find_package(Curses)`` call if NCurses functionality is required. - -.. versionadded:: 3.10 - Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the - ``find_package(Curses)`` call if unicode functionality is required. - -Backward Compatibility -^^^^^^^^^^^^^^^^^^^^^^ - -The following variable are provided for backward compatibility: - -``CURSES_INCLUDE_DIR`` - Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead. -``CURSES_LIBRARY`` - Path to Curses library. Use ``CURSES_LIBRARIES`` instead. -#]=======================================================================] - -include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) - -# we don't know anything about cursesw, so only ncurses -# may be ncursesw -if(NOT CURSES_NEED_WIDE) - set(NCURSES_LIBRARY_NAME "ncurses") - set(CURSES_FORM_LIBRARY_NAME "form") -else() - set(NCURSES_LIBRARY_NAME "ncursesw") - set(CURSES_FORM_LIBRARY_NAME "formw") - # Also, if we are searching for wide curses - we are actually searching - # for ncurses, we don't know about any other unicode version. - set(CURSES_NEED_NCURSES TRUE) -endif() - -find_library(CURSES_CURSES_LIBRARY NAMES curses) - -find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" ) -set(CURSES_USE_NCURSES FALSE) - -if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES)) - set(CURSES_USE_NCURSES TRUE) -endif() -# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html -# cygwin ncurses stopped providing curses.h symlinks see above -# message. Cygwin is an ncurses package, so force ncurses on -# cygwin if the curses.h is missing -if(CURSES_NCURSES_LIBRARY AND CYGWIN) - if (CURSES_NEED_WIDE) - if(NOT EXISTS /usr/include/ncursesw/curses.h) - set(CURSES_USE_NCURSES TRUE) - endif() - else() - if(NOT EXISTS /usr/include/curses.h) - set(CURSES_USE_NCURSES TRUE) - endif() - endif() -endif() - - -# Not sure the logic is correct here. -# If NCurses is required, use the function wsyncup() to check if the library -# has NCurses functionality (at least this is where it breaks on NetBSD). -# If wsyncup is in curses, use this one. -# If not, try to find ncurses and check if this has the symbol. -# Once the ncurses library is found, search the ncurses.h header first, but -# some web pages also say that even with ncurses there is not always a ncurses.h: -# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html -# So at first try ncurses.h, if not found, try to find curses.h under the same -# prefix as the library was found, if still not found, try curses.h with the -# default search paths. -if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) - include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) - cmake_push_check_state() - set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY}) - CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" - wsyncup "" CURSES_CURSES_HAS_WSYNCUP) - - if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - wsyncup "" CURSES_NCURSES_HAS_WSYNCUP) - if( CURSES_NCURSES_HAS_WSYNCUP) - set(CURSES_USE_NCURSES TRUE) - endif() - endif() - cmake_pop_check_state() - -endif() - -if(CURSES_USE_NCURSES) - get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH) - get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH) - - # Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility. - if(CURSES_NCURSES_INCLUDE_PATH) - if (CURSES_NEED_WIDE) - find_path(CURSES_INCLUDE_PATH - NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h - PATHS ${CURSES_NCURSES_INCLUDE_PATH} - NO_DEFAULT_PATH - ) - else() - find_path(CURSES_INCLUDE_PATH - NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - PATHS ${CURSES_NCURSES_INCLUDE_PATH} - NO_DEFAULT_PATH - ) - endif() - endif() - - if (CURSES_NEED_WIDE) - set(CURSES_TINFO_LIBRARY_NAME tinfow) - find_path(CURSES_INCLUDE_PATH - NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h - HINTS "${_cursesParentDir}/include" - ) - else() - set(CURSES_TINFO_LIBRARY_NAME tinfo) - find_path(CURSES_INCLUDE_PATH - NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - HINTS "${_cursesParentDir}/include" - ) - endif() - - # Previous versions of FindCurses provided these values. - if(NOT DEFINED CURSES_LIBRARY) - set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}") - endif() - - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - cbreak "" CURSES_NCURSES_HAS_CBREAK) - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - nodelay "" CURSES_NCURSES_HAS_NODELAY) - if(NOT CURSES_NCURSES_HAS_CBREAK OR NOT CURSES_NCURSES_HAS_NODELAY) - find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}") - find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" ) - - mark_as_advanced( - CURSES_EXTRA_LIBRARY - ) - endif() -else() - get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) - get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH) - - #We can't find anything with CURSES_NEED_WIDE because we know - #only about ncursesw unicode curses version - if(NOT CURSES_NEED_WIDE) - find_path(CURSES_INCLUDE_PATH - NAMES curses.h - HINTS "${_cursesParentDir}/include" - ) - endif() - - # Previous versions of FindCurses provided these values. - if(NOT DEFINED CURSES_CURSES_H_PATH) - set(CURSES_CURSES_H_PATH "${CURSES_INCLUDE_PATH}") - endif() - if(NOT DEFINED CURSES_LIBRARY) - set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}") - endif() -endif() - -# Report whether each possible header name exists in the include directory. -if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) - if(CURSES_NEED_WIDE) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") - set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") - endif() - elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") - set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") - endif() - if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) - set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND") - endif() -endif() -if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) - if(CURSES_NEED_WIDE) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") - set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") - endif() - elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h") - set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h") - endif() - if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) - set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND") - endif() -endif() -if(NOT CURSES_NEED_WIDE) - #ncursesw can't be found for this paths - if(NOT DEFINED CURSES_HAVE_NCURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h") - set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h") - else() - set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND") - endif() - endif() - if(NOT DEFINED CURSES_HAVE_CURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h") - set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h") - else() - set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND") - endif() - endif() -endif() - -find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" HINTS "${_cursesLibDir}") -find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" ) - -# Previous versions of FindCurses provided these values. -if(NOT DEFINED FORM_LIBRARY) - set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}") -endif() - -# Need to provide the *_LIBRARIES -set(CURSES_LIBRARIES ${CURSES_LIBRARY}) - -if(CURSES_EXTRA_LIBRARY) - set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY}) -endif() - -if(CURSES_FORM_LIBRARY) - set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY}) -endif() - -# Provide the *_INCLUDE_DIRS and *_CFLAGS results. -set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH}) -set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility - -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(NCURSES QUIET ${NCURSES_LIBRARY_NAME}) - set(CURSES_CFLAGS ${NCURSES_CFLAGS_OTHER}) -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG - CURSES_LIBRARY CURSES_INCLUDE_PATH) - -mark_as_advanced( - CURSES_INCLUDE_PATH - CURSES_CURSES_LIBRARY - CURSES_NCURSES_LIBRARY - CURSES_FORM_LIBRARY - ) diff --git a/CMakeModules/FindPackageHandleStandardArgs.cmake b/CMakeModules/FindPackageHandleStandardArgs.cmake deleted file mode 100644 index d03041852de8..000000000000 --- a/CMakeModules/FindPackageHandleStandardArgs.cmake +++ /dev/null @@ -1,351 +0,0 @@ -#.rst: -# FindPackageHandleStandardArgs -# ----------------------------- -# -# -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) -# -# This function is intended to be used in FindXXX.cmake modules files. -# It handles the REQUIRED, QUIET and version-related arguments to -# find_package(). It also sets the _FOUND variable. The -# package is considered found if all variables ... listed contain -# valid results, e.g. valid filepaths. -# -# There are two modes of this function. The first argument in both -# modes is the name of the Find-module where it is called (in original -# casing). -# -# The first simple mode looks like this: -# -# :: -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) -# -# If the variables to are all valid, then -# _FOUND will be set to TRUE. If DEFAULT_MSG is given -# as second argument, then the function will generate itself useful -# success and error messages. You can also supply a custom error -# message for the failure case. This is not recommended. -# -# The second mode is more powerful and also supports version checking: -# -# :: -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR ] -# [REQUIRED_VARS ...] -# [VERSION_VAR ] -# [HANDLE_COMPONENTS] -# [CONFIG_MODE] -# [FAIL_MESSAGE "Custom failure message"] ) -# -# -# -# In this mode, the name of the result-variable can be set either to -# either _FOUND or _FOUND using the -# FOUND_VAR option. Other names for the result-variable are not -# allowed. So for a Find-module named FindFooBar.cmake, the two -# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended -# to use the original case version. If the FOUND_VAR option is not -# used, the default is _FOUND. -# -# As in the simple mode, if through are all valid, -# _FOUND will be set to TRUE. After REQUIRED_VARS the -# variables which are required for this package are listed. Following -# VERSION_VAR the name of the variable can be specified which holds the -# version of the package which has been found. If this is done, this -# version will be checked against the (potentially) specified required -# version used in the find_package() call. The EXACT keyword is also -# handled. The default messages include information about the required -# version and the version which has been actually found, both if the -# version is ok or not. If the package supports components, use the -# HANDLE_COMPONENTS option to enable handling them. In this case, -# find_package_handle_standard_args() will report which components have -# been found and which are missing, and the _FOUND variable -# will be set to FALSE if any of the required components (i.e. not the -# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option -# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a -# find_package(... NO_MODULE) call. In this case VERSION_VAR will be -# set to _VERSION and the macro will automatically check whether -# the Config module was found. Via FAIL_MESSAGE a custom failure -# message can be specified, if this is not used, the default message -# will be displayed. -# -# Example for mode 1: -# -# :: -# -# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) -# -# -# -# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and -# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to -# TRUE. If it is not found and REQUIRED was used, it fails with -# FATAL_ERROR, independent whether QUIET was used or not. If it is -# found, success will be reported, including the content of . On -# repeated Cmake runs, the same message won't be printed again. -# -# Example for mode 2: -# -# :: -# -# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND -# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS -# VERSION_VAR LibXslt_VERSION_STRING) -# -# In this case, LibXslt is considered to be found if the variable(s) -# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and -# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in -# LibXslt_FOUND . Also the version of LibXslt will be checked by using -# the version contained in LibXslt_VERSION_STRING. Since no -# FAIL_MESSAGE is given, the default messages will be printed. -# -# Another example for mode 2: -# -# :: -# -# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) -# find_package_handle_standard_args(Automoc4 CONFIG_MODE) -# -# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 -# NO_MODULE) and adds an additional search directory for automoc4. Here -# the result will be stored in AUTOMOC4_FOUND. The following -# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper -# success/error message. - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - -# internal helper macro -macro(_FPHSA_FAILURE_MESSAGE _msg) - if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") - else () - if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") - endif () - endif () -endmacro() - - -# internal helper macro to generate the failure message when used in CONFIG_MODE: -macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: - if(${_NAME}_CONFIG) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") - else() - # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. - # List them all in the error message: - if(${_NAME}_CONSIDERED_CONFIGS) - set(configsText "") - list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) - math(EXPR configsCount "${configsCount} - 1") - foreach(currentConfigIndex RANGE ${configsCount}) - list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) - list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - set(configsText "${configsText} ${filename} (version ${version})\n") - endforeach() - if (${_NAME}_NOT_FOUND_MESSAGE) - set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") - endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") - - else() - # Simple case: No Config-file was found at all: - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") - endif() - endif() -endmacro() - - -function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) - -# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in -# new extended or in the "old" mode: - set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) - set(multiValueArgs REQUIRED_VARS) - set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) - list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) - - if(${INDEX} EQUAL -1) - set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) - set(FPHSA_REQUIRED_VARS ${ARGN}) - set(FPHSA_VERSION_VAR) - else() - - CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) - - if(FPHSA_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT FPHSA_FAIL_MESSAGE) - set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") - endif() - endif() - -# now that we collected all arguments, process them - - if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") - set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") - endif() - - # In config-mode, we rely on the variable _CONFIG, which is set by find_package() - # when it successfully found the config-file, including version checking: - if(FPHSA_CONFIG_MODE) - list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) - list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) - set(FPHSA_VERSION_VAR ${_NAME}_VERSION) - endif() - - if(NOT FPHSA_REQUIRED_VARS) - message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - endif() - - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) - - string(TOUPPER ${_NAME} _NAME_UPPER) - string(TOLOWER ${_NAME} _NAME_LOWER) - - if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") - set(_FOUND_VAR ${FPHSA_FOUND_VAR}) - else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") - endif() - else() - set(_FOUND_VAR ${_NAME_UPPER}_FOUND) - endif() - - # collect all variables which were not found, so they can be printed, so the - # user knows better what went wrong (#6375) - set(MISSING_VARS "") - set(DETAILS "") - # check if all passed variables are valid - unset(${_FOUND_VAR}) - foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) - if(NOT ${_CURRENT_VAR}) - set(${_FOUND_VAR} FALSE) - set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") - else() - set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") - endif() - endforeach() - if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE") - set(${_FOUND_VAR} TRUE) - endif() - - # component handling - unset(FOUND_COMPONENTS_MSG) - unset(MISSING_COMPONENTS_MSG) - - if(FPHSA_HANDLE_COMPONENTS) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(${_NAME}_${comp}_FOUND) - - if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") - endif() - set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") - - else() - - if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") - endif() - set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") - - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_FOUND_VAR} FALSE) - set(MISSING_VARS "${MISSING_VARS} ${comp}") - endif() - - endif() - endforeach() - set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") - endif() - - # version handling: - set(VERSION_MSG "") - set(VERSION_OK TRUE) - set(VERSION ${${FPHSA_VERSION_VAR}} ) - if (${_NAME}_FIND_VERSION) - - if(VERSION) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") - set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") - endif () - - else() # minimum version specified: - if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") - set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () - endif() - - else() - - # if the package was not found, but a version was given, add that to the output: - if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") - else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") - endif() - - endif() - else () - if(VERSION) - set(VERSION_MSG "(found version \"${VERSION}\")") - endif() - endif () - - if(VERSION_OK) - set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") - else() - set(${_FOUND_VAR} FALSE) - endif() - - - # print the result: - if (${_FOUND_VAR}) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") - else () - - if(FPHSA_CONFIG_MODE) - _FPHSA_HANDLE_FAILURE_CONFIG_MODE() - else() - if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") - else() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") - endif() - endif() - - endif () - - set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE) - -endfunction() diff --git a/CMakeModules/FindPackageMessage.cmake b/CMakeModules/FindPackageMessage.cmake deleted file mode 100644 index b6a58e427d14..000000000000 --- a/CMakeModules/FindPackageMessage.cmake +++ /dev/null @@ -1,57 +0,0 @@ -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE( "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() - -#============================================================================= -# Copyright 2008-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -function(FIND_PACKAGE_MESSAGE pkg msg details) - # Avoid printing a message repeatedly for the same find result. - if(NOT ${pkg}_FIND_QUIETLY) - string(REGEX REPLACE "[\n]" "" details "${details}") - set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) - if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") - # The message has not yet been printed. - message(STATUS "${msg}") - - # Save the find details in the cache to avoid printing the same - # message again. - set("${DETAILS_VAR}" "${details}" - CACHE INTERNAL "Details about finding ${pkg}") - endif() - endif() -endfunction() From df9a436f98e20edba9afbbc77147025ed95b3659 Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 24 May 2022 22:57:55 +0200 Subject: [PATCH 072/188] Add documentation for CMake+VCPKG build - Move build configuration into the preset - Explain how to use multi-config generator - Fix "/permessive" description Co-authored-by: akrieger --- build-scripts/CMakeUserPresets.json.in | 1 + build-scripts/MSVC.cmake | 85 ++++++++++++++++---------- build-scripts/x64-release.cmake | 24 +++++++- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 53 ++++++++++++++++ 4 files changed, 129 insertions(+), 34 deletions(-) create mode 100644 doc/COMPILING/COMPILING-CMAKE-VCPKG.md diff --git a/build-scripts/CMakeUserPresets.json.in b/build-scripts/CMakeUserPresets.json.in index eace3d9736e0..4026a9b5e7c3 100644 --- a/build-scripts/CMakeUserPresets.json.in +++ b/build-scripts/CMakeUserPresets.json.in @@ -7,6 +7,7 @@ "environment": { @_MSVC_DEVENV@ }, + "configuration": "@CMAKE_BUILD_TYPE@", "verbose": true } ] diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index cd518b5a2102..cc6b3c3fdc74 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,3 +1,53 @@ +#[=======================================================================[ + +MSVC +---- + +Toolchain file for Microsoft Visual C++. + +Used by CMakePresets.json -> "toolchainFile". + +C++ flags used by all builds: + +/MP cl.exe build with multiple processes +/utf-8 set source and execution character sets to UTF-8 +/bigobj increase # of sections in object files +/permissive- enforce more standards compliant behavior +/sdl- disable additional security checks +/FC full path in compiler messages +/Gd __cdecl +/GS- disable buffer security checks +/Gy Enable Function-Level Linking +/GF Eliminate Duplicate Strings +/wd4068 unknown pragma +/wd4146 negate unsigned +/wd4819 codepage? +/wd6237 short-circuit eval +/wd6319 a, b: unused a +/wd26444 unnamed objects +/wd26451 overflow +/wd26495 uninitialized member +/WX- (do not) Treat Warnings as Errors +/W1 Warning Level +/TP every file is a C++ file +/Zc:forScope Force Conformance in for Loop Scope +/Zc:inline Remove unreferenced COMDAT +/Zc:wchar_t wchar_t Is Native Type + +Additional C++ flags used by RelWithDebInfo builds: + +/Ob1 Inline Function Expansion (1 = only when marked as such) +/Oi Generate Intrinsic Functions + +Linker flags used by all builds: + +/OPT:REF remove unreferenced COMDATs +/OPT:ICF folds identical COMDATs +/DYNAMICBASE does this app really need ASLR ? +/NXCOMPAT same as above +No need to force /TLBID:1 because is default + +#]=======================================================================] if (NOT "$ENV{DevEnvDir}") # Use Community Edition when not specified set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") @@ -15,35 +65,9 @@ set(CMAKE_CXX_FLAGS_INIT "\ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ /TP /Zc:forScope /Zc:inline /Zc:wchar_t" ) -# /MP # cl.exe build with multiple processes -# /utf-8 # set source and execution character sets to UTF-8 -# /bigobj # increase # of sections in object files -# /permissive- # to allow alternative operators ("and", "or", "not") -# /sdl- # disable additional security checks -# /FC # full path in compiler messages -# /Gd # __cdecl -# /GS- # disable buffer security checks -# /Gy # Enable Function-Level Linking -# /GF # Eliminate Duplicate Strings -# /wd4068 # unknown pragma -# /wd4146 # negate unsigned -# /wd4819 # codepage? -# /wd6237 # short-circuit eval -# /wd6319 # a, b: unused a -# /wd26444 # unnamed objects -# /wd26451 # overflow -# /wd26495 # uninitialized member -# /WX- # (do not) Treat Warnings as Errors -# /W1 # Warning Level -# /TP # every file is a C++ file -# /Zc:forScope # Force Conformance in for Loop Scope -# /Zc:inline # Remove unreferenced COMDAT -# /Zc:wchar_t # wchar_t Is Native Type set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/Oi" ) -# /Ob1 # Inline Function Expansion (1 = only when marked as such) -# /Oi # Generate Intrinsic Functions add_compile_definitions( _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS @@ -60,12 +84,11 @@ add_link_options( /DYNAMICBASE /NXCOMPAT ) -# /OPT:REF # remove unreferenced COMDATs -# /OPT:ICF # folds identical COMDATs -# /DYNAMICBASE # does this app really need ASLR ? -# /NXCOMPAT # same as above -# No need to force /TLBID:1 because is default set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + +# Where is vcpkg.json ? set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) + +# Bring VCPKG in include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake index 0cf9d957be5b..281f0bc518b6 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/x64-release.cmake @@ -1,6 +1,22 @@ +#[=======================================================================[ + +x64-release +----------- + +Pre-load script for Microsoft Visual Studio builds. + +Used by CMakePresets.json -> "cacheVariables" -> "CMAKE_PROJECT_INCLUDE_BEFORE". + +When CMake does not run under VS environment, it sources the VsDevCmd.bat on it own. +It then writes CMakeUserPresets.json -> "buildPresets" -> "environment" + +#]=======================================================================] + +# Ref https://github.com/actions/virtual-environments/blob/win19/20220515.1/images/win/Windows2019-Readme.md#environment-variables if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) endif() +# Ref https://vcpkg.io/en/docs/users/config-environment.html#vcpkg_root if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) set(ENV{VCPKG_ROOT} C:/vcpkg) endif() @@ -30,7 +46,7 @@ if("$ENV{VSCMD_VER}" STREQUAL "") message(XX${_value}XX) string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin string(STRIP "${_value}" _value) # Remove \r - # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" foreach(_replace ExtensionSdkDir= Framework40Version= @@ -76,9 +92,11 @@ if("$ENV{VSCMD_VER}" STREQUAL "") string(APPEND _MSVC_DEVENV ",\n${_json_entry}") endif() endif() - endforeach() - endforeach() + endforeach() # replace + endforeach() # _ENV endif() # VSCMD_VER + +# It's fine to keep @_MSVC_DEVENV@ undefined configure_file( ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md new file mode 100644 index 000000000000..55840e12f179 --- /dev/null +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -0,0 +1,53 @@ +# Disclaimer + +**WARNING**: CMake build is **NOT** officially supported and should be used for *dev purposes ONLY*. + +For the official way to build CataclysmDDA, see: + * [COMPILING.md](COMPILING.md) + + +# Contents + +1. Prerequisites + +# Prerequisites + +`cmake` => 3.20.0
+`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) + +## Visual Studio + +`C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe` + +## vcpkg + +If different from `C:\vcpkg`, define the installed path via `VCPKG_ROOT` env, add `-DVCPKG_ROOT=path` to `cmake` command, or edit `CMakePresets.json`'s `VCPKG_ROOT` cache variable. + +# Presets + +Presets will build into `out/build//` + +Run the command `cmake --list-presets` to show the presets available to you. +The list changes based on the environment you are in. + + +# Configure + +Run the command + * `cmake --preset ` + +# Build + +Run the command + * `cmake --build --preset --config RelWithDebInfo` + +# Install + +Run the command + * `cmake --install out/build// --config RelWithDebInfo` + + # Run + + Run the commands + * `cd out/install//` + * `cataclysm` or `cataclysm-tiles.exe` From 797ea3cd7252bf650f25ba0249884f10ac7fe13b Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 24 May 2022 22:59:21 +0200 Subject: [PATCH 073/188] Use VCPKG triplets from build-scripts/ - Point to triplets from base configuration - Move Ninja to basic preset requirement - Remove x64-debug because not used --- CMakePresets.json | 24 ++++-------------------- build-scripts/x64-windows-static.cmake | 5 +++++ 2 files changed, 9 insertions(+), 20 deletions(-) create mode 100644 build-scripts/x64-windows-static.cmake diff --git a/CMakePresets.json b/CMakePresets.json index 123e2bf4e2b8..a9af488753ba 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,6 +6,10 @@ "description": "Base Build Configuration", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", + "generator": "Ninja", + "cacheVariables": { + "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" + }, "hidden": true }, { @@ -23,7 +27,6 @@ "inherits": [ "windows" ], "description": "Visual C++ Configuration", "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", - "generator": "Ninja", "hidden": true }, { @@ -48,25 +51,6 @@ "LOCALIZE": "True", "TILES": "True" } - }, - { - "name": "x64-debug", - "inherits": [ "x64-windows-static" ], - "displayName": "x64 Debug", - "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)", - "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/FindVCPKG.cmake", - "CMAKE_BUILD_TYPE": "Debug", - "CURSES": "False", - "LOCALIZE": "False", - "TILES": "True" - } - } - ], - "buildPresets": [ - { - "name": "x64-debug", - "configurePreset": "x64-debug" } ] } diff --git a/build-scripts/x64-windows-static.cmake b/build-scripts/x64-windows-static.cmake new file mode 100644 index 000000000000..66655f187771 --- /dev/null +++ b/build-scripts/x64-windows-static.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_BUILD_TYPE release) From 39d25f938a3e9dd0c8da2644b73a6fa40b691ab8 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 26 May 2022 17:44:10 +0200 Subject: [PATCH 074/188] Optmize replacing ENV vars loop with find() --- build-scripts/x64-release.cmake | 94 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake index 281f0bc518b6..47e3e73c4bad 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/x64-release.cmake @@ -38,61 +38,61 @@ if("$ENV{VSCMD_VER}" STREQUAL "") execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _ENV) + # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + set(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") foreach(_env IN LISTS _ENV) string(REGEX MATCH ^[^=]+ _key "${_env}") string(REGEX MATCH =[^\n]+\n _value "${_env}") - message(XX${_value}XX) string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin string(STRIP "${_value}" _value) # Remove \r - # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" - foreach(_replace - ExtensionSdkDir= - Framework40Version= - FrameworkDIR64= - FrameworkDir= - FrameworkVersion64= - FrameworkVersion= - INCLUDE= - LIB= - LIBPATH= - NETFXSDKDir= - Path= - UCRTVersion= - UniversalCRTSdkDir= - VCIDEInstallDir= - VCINSTALLDIR= - VCToolsInstallDir= - VCToolsRedistDir= - VCToolsVersion= - VS170COMNTOOLS= - VSCMD_ARG_HOST_ARCH= - VSCMD_ARG_TGT_ARCH= - VSCMD_ARG_app_plat= - VSCMD_VER= - VSINSTALLDIR= - VisualStudioVersion= - WindowsLibPath= - WindowsSDKLibVersion= - WindowsSDKVersion= - WindowsSDK_ExecutablePath_x64= - WindowsSDK_ExecutablePath_x86= - WindowsSdkBinPath= - WindowsSdkDir= - WindowsSdkVerBinPath= - ) - if("${_key}=" STREQUAL "${_replace}") - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") - endif() + list(FIND _replace ${_key}= _idx) + if(NOT -1 EQUAL _idx) + list(REMOVE_AT _replace ${_idx}) + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + else() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") endif() - endforeach() # replace + endif() endforeach() # _ENV endif() # VSCMD_VER From 3f97adf8e5bc434940574ee1e7123a21514d50e4 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 26 May 2022 18:20:06 +0200 Subject: [PATCH 075/188] Force ninja.exe path in the INCLUDE_BEFORE file --- build-scripts/MSVC.cmake | 8 -------- build-scripts/x64-release.cmake | 5 +++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index cc6b3c3fdc74..62ca248825fa 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -48,14 +48,6 @@ Linker flags used by all builds: No need to force /TLBID:1 because is default #]=======================================================================] -if (NOT "$ENV{DevEnvDir}") - # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") -endif() -if(CMAKE_GENERATOR MATCHES ^Ninja) - # Ninja is provided by Microsoft but not in the Path - set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") -endif() # Path has changed, so this configure run will find cl.exe set(CMAKE_C_COMPILER cl.exe) diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake index 47e3e73c4bad..5a65c54f4932 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/x64-release.cmake @@ -29,8 +29,6 @@ if("$ENV{VSCMD_VER}" STREQUAL "") # Use Community Edition when not specified set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") endif() - # Ninja is provided by Microsoft but not in the Path - set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") # Run VsDevCmd.bat and set all environment variables it changes set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") @@ -102,3 +100,6 @@ configure_file( ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json @ONLY ) + +# Ninja is provided by Microsoft but not in the Path +set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") From af1fb416218a588bf7d461fd979e622f154c73bb Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 1 Jun 2022 22:12:27 +0200 Subject: [PATCH 076/188] Add varialbes to "name" and "configurePreset" This way CMakeUserPresets.json.in can be reused for other targets --- build-scripts/CMakeUserPresets.json.in | 4 ++-- build-scripts/x64-release.cmake | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build-scripts/CMakeUserPresets.json.in b/build-scripts/CMakeUserPresets.json.in index 4026a9b5e7c3..c94506d48a11 100644 --- a/build-scripts/CMakeUserPresets.json.in +++ b/build-scripts/CMakeUserPresets.json.in @@ -2,8 +2,8 @@ "version": 3, "buildPresets": [ { - "name": "x64-release", - "configurePreset": "x64-release", + "name": "@BUILD_PRESET_NAME@", + "configurePreset": "@CONFIGURE_PRESET@", "environment": { @_MSVC_DEVENV@ }, diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake index 5a65c54f4932..cda295d6112d 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/x64-release.cmake @@ -95,6 +95,8 @@ if("$ENV{VSCMD_VER}" STREQUAL "") endif() # VSCMD_VER # It's fine to keep @_MSVC_DEVENV@ undefined +set(BUILD_PRESET_NAME "windows-tiles-sounds-x64-msvc") +set(CONFIGURE_PRESET "windows-tiles-sounds-x64-msvc") configure_file( ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json From 23a20c4e7b4ad48acf16bde0ef8089dbb85472cc Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 1 Jun 2022 22:14:21 +0200 Subject: [PATCH 077/188] Rename presets to match release.yml names Rename preset to MSVC and pre-load script to be consistent. --- CMakePresets.json | 8 ++++---- ...-release.cmake => windows-tiles-sounds-x64-msvc.cmake} | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) rename build-scripts/{x64-release.cmake => windows-tiles-sounds-x64-msvc.cmake} (98%) diff --git a/CMakePresets.json b/CMakePresets.json index a9af488753ba..f282bad5c7fa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,7 +23,7 @@ "hidden": true }, { - "name": "visual-c++", + "name": "MSVC", "inherits": [ "windows" ], "description": "Visual C++ Configuration", "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", @@ -31,7 +31,7 @@ }, { "name": "x64-windows-static", - "inherits": [ "base", "visual-c++" ], + "inherits": [ "base", "MSVC" ], "description": "Link Statically", "cacheVariables": { "VCPKG_TARGET_TRIPLET": "x64-windows-static", @@ -40,12 +40,12 @@ "hidden": true }, { - "name": "x64-release", + "name": "windows-tiles-sounds-x64-msvc", "inherits": [ "x64-windows-static" ], "displayName": "x64 Release", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/x64-release.cmake", + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "True", diff --git a/build-scripts/x64-release.cmake b/build-scripts/windows-tiles-sounds-x64-msvc.cmake similarity index 98% rename from build-scripts/x64-release.cmake rename to build-scripts/windows-tiles-sounds-x64-msvc.cmake index cda295d6112d..d4f2e3052e28 100644 --- a/build-scripts/x64-release.cmake +++ b/build-scripts/windows-tiles-sounds-x64-msvc.cmake @@ -1,7 +1,7 @@ #[=======================================================================[ -x64-release ------------ +windows-tiles-sounds-x64-msvc +----------------------------- Pre-load script for Microsoft Visual Studio builds. From 1f7def7388f31d3ba1c38f0e15085a20f06c2d4c Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 8 Jul 2022 21:54:35 +0200 Subject: [PATCH 078/188] Move VsDevCmd environment parsing to its dedicated script --- build-scripts/VsDevCmd.cmake | 73 +++++++++++++++++++ .../windows-tiles-sounds-x64-msvc.cmake | 73 +------------------ 2 files changed, 74 insertions(+), 72 deletions(-) create mode 100644 build-scripts/VsDevCmd.cmake diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake new file mode 100644 index 000000000000..2329240dfc3a --- /dev/null +++ b/build-scripts/VsDevCmd.cmake @@ -0,0 +1,73 @@ +if("$ENV{VSCMD_VER}" STREQUAL "") + # This cmake process is running under VsDevCmd.bat or VS IDE GUI + # Avoid to run VsDevCmd.bat twice + + if (NOT "$ENV{DevEnvDir}") + # Use Community Edition when not specified + set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") + endif() + + # Run VsDevCmd.bat and set all environment variables it changes + set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") + cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) + execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _ENV) + # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + set(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) + string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") + string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") + foreach(_env IN LISTS _ENV) + string(REGEX MATCH ^[^=]+ _key "${_env}") + string(REGEX MATCH =[^\n]+\n _value "${_env}") + string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin + string(STRIP "${_value}" _value) # Remove \r + list(FIND _replace ${_key}= _idx) + if(NOT -1 EQUAL _idx) + list(REMOVE_AT _replace ${_idx}) + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + else() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + endif() + endif() + endforeach() # _ENV +endif() # VSCMD_VER + diff --git a/build-scripts/windows-tiles-sounds-x64-msvc.cmake b/build-scripts/windows-tiles-sounds-x64-msvc.cmake index d4f2e3052e28..0a7a2fbc0c12 100644 --- a/build-scripts/windows-tiles-sounds-x64-msvc.cmake +++ b/build-scripts/windows-tiles-sounds-x64-msvc.cmake @@ -21,78 +21,7 @@ if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) set(ENV{VCPKG_ROOT} C:/vcpkg) endif() -if("$ENV{VSCMD_VER}" STREQUAL "") - # This cmake process is running under VsDevCmd.bat or VS IDE GUI - # Avoid to run VsDevCmd.bat twice - - if (NOT "$ENV{DevEnvDir}") - # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") - endif() - - # Run VsDevCmd.bat and set all environment variables it changes - set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") - cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) - execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE _ENV) - # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" - set(_replace - ExtensionSdkDir= - Framework40Version= - FrameworkDIR64= - FrameworkDir= - FrameworkVersion64= - FrameworkVersion= - INCLUDE= - LIB= - LIBPATH= - NETFXSDKDir= - Path= - UCRTVersion= - UniversalCRTSdkDir= - VCIDEInstallDir= - VCINSTALLDIR= - VCToolsInstallDir= - VCToolsRedistDir= - VCToolsVersion= - VS170COMNTOOLS= - VSCMD_ARG_HOST_ARCH= - VSCMD_ARG_TGT_ARCH= - VSCMD_ARG_app_plat= - VSCMD_VER= - VSINSTALLDIR= - VisualStudioVersion= - WindowsLibPath= - WindowsSDKLibVersion= - WindowsSDKVersion= - WindowsSDK_ExecutablePath_x64= - WindowsSDK_ExecutablePath_x86= - WindowsSdkBinPath= - WindowsSdkDir= - WindowsSdkVerBinPath= - ) - string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") - string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") - foreach(_env IN LISTS _ENV) - string(REGEX MATCH ^[^=]+ _key "${_env}") - string(REGEX MATCH =[^\n]+\n _value "${_env}") - string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin - string(STRIP "${_value}" _value) # Remove \r - list(FIND _replace ${_key}= _idx) - if(NOT -1 EQUAL _idx) - list(REMOVE_AT _replace ${_idx}) - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") - endif() - endif() - endforeach() # _ENV -endif() # VSCMD_VER +include(${CMAKE_SOURCE_DIR}/build-scripts/VsDevCmd.cmake) # It's fine to keep @_MSVC_DEVENV@ undefined set(BUILD_PRESET_NAME "windows-tiles-sounds-x64-msvc") From 83de2eff18ef7b45baf06262df74955dd09e0504 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 Aug 2022 16:58:49 +0200 Subject: [PATCH 079/188] Fix checking for DevEnvDir --- build-scripts/VsDevCmd.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake index 2329240dfc3a..2493d69faabe 100644 --- a/build-scripts/VsDevCmd.cmake +++ b/build-scripts/VsDevCmd.cmake @@ -2,13 +2,13 @@ if("$ENV{VSCMD_VER}" STREQUAL "") # This cmake process is running under VsDevCmd.bat or VS IDE GUI # Avoid to run VsDevCmd.bat twice - if (NOT "$ENV{DevEnvDir}") + if ("$ENV{DevEnvDir}" STREQUAL "") # Use Community Edition when not specified set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") endif() # Run VsDevCmd.bat and set all environment variables it changes - set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") + set(VSDEVCMD_BAT $ENV{DevEnvDir}..\\Tools\\VsDevCmd.bat) cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set OUTPUT_STRIP_TRAILING_WHITESPACE From 08a20633a01c8060f0c7cf6e3750c4ab56e386b8 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 6 Aug 2022 18:11:36 +0200 Subject: [PATCH 080/188] Fix parsing non variables output --- build-scripts/VsDevCmd.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake index 2493d69faabe..8d88c3a11ad4 100644 --- a/build-scripts/VsDevCmd.cmake +++ b/build-scripts/VsDevCmd.cmake @@ -54,6 +54,9 @@ if("$ENV{VSCMD_VER}" STREQUAL "") foreach(_env IN LISTS _ENV) string(REGEX MATCH ^[^=]+ _key "${_env}") string(REGEX MATCH =[^\n]+\n _value "${_env}") + if(NOT _value MATCHES ^=) + continue() + endif() string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin string(STRIP "${_value}" _value) # Remove \r list(FIND _replace ${_key}= _idx) From ca5e1d459b6a07603949a28993d740efa058b85b Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 14 Aug 2022 15:29:13 +0200 Subject: [PATCH 081/188] Document and improve VsDevCmd.cmake It uses DOS short names to workaround a CMake issue. --- build-scripts/VsDevCmd.cmake | 57 ++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake index 8d88c3a11ad4..b2991c009889 100644 --- a/build-scripts/VsDevCmd.cmake +++ b/build-scripts/VsDevCmd.cmake @@ -1,19 +1,42 @@ +#[=======================================================================[ + +VsDevCmd.cmake +-------------- + +Run VsDevCmd.bat and extracts environment variables it changes. +Inject them into the global scope and _MSVC_DEVENV for +CMakeUserPreset.json at a later step. + +#]=======================================================================] + if("$ENV{VSCMD_VER}" STREQUAL "") # This cmake process is running under VsDevCmd.bat or VS IDE GUI # Avoid to run VsDevCmd.bat twice if ("$ENV{DevEnvDir}" STREQUAL "") # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") + set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/") endif() # Run VsDevCmd.bat and set all environment variables it changes - set(VSDEVCMD_BAT $ENV{DevEnvDir}..\\Tools\\VsDevCmd.bat) - cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) + set(DevEnvDir $ENV{DevEnvDir}) + cmake_path(APPEND DevEnvDir ../Tools/VsDevCmd.bat OUTPUT_VARIABLE VSDEVCMD_BAT) + cmake_path(NATIVE_PATH VSDEVCMD_BAT NORMALIZE VSDEVCMD_BAT) + cmake_path(NATIVE_PATH DevEnvDir NORMALIZE DevEnvDir) + set(ENV{DevEnvDir} ${DevEnvDir}) + set(ENV{VSDEVCMD_BAT} \"${VSDEVCMD_BAT}\") + # Use short DOS path names because of spaces in path names + # See https://gitlab.kitware.com/cmake/cmake/-/issues/16321 + execute_process(COMMAND cmd /c for %A in (%VSDEVCMD_BAT%) do @echo %~sA + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE VSDEVCMD_BAT) + # Run it execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _ENV) - # This list is essentially a revised result of: comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + # This list the environment variables we need. + # It is essentially a revised result of: + # comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" set(_replace ExtensionSdkDir= Framework40Version= @@ -54,23 +77,25 @@ if("$ENV{VSCMD_VER}" STREQUAL "") foreach(_env IN LISTS _ENV) string(REGEX MATCH ^[^=]+ _key "${_env}") string(REGEX MATCH =[^\n]+\n _value "${_env}") + # We may get some spurious output. Skip the line if(NOT _value MATCHES ^=) continue() endif() - string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin - string(STRIP "${_value}" _value) # Remove \r + string(SUBSTRING "${_value}" 1 -1 _value) # Removes the = at begin + string(STRIP "${_value}" _value) # Remove the \r list(FIND _replace ${_key}= _idx) - if(NOT -1 EQUAL _idx) - list(REMOVE_AT _replace ${_idx}) - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") - endif() + if(-1 EQUAL _idx) + continue() + endif() + list(REMOVE_AT _replace ${_idx}) + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + continue() endif() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") endforeach() # _ENV endif() # VSCMD_VER From 2ae73c297d09dd538880e438033786af1f1655f0 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 9 Sep 2022 17:44:09 +0200 Subject: [PATCH 082/188] Use vswhere.exe as suggested by akrieger Fix not finding VS prereleases --- build-scripts/VsDevCmd.cmake | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake index b2991c009889..efdefa3bdb3a 100644 --- a/build-scripts/VsDevCmd.cmake +++ b/build-scripts/VsDevCmd.cmake @@ -15,7 +15,21 @@ if("$ENV{VSCMD_VER}" STREQUAL "") if ("$ENV{DevEnvDir}" STREQUAL "") # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/") + file(DOWNLOAD https://github.com/microsoft/vswhere/releases/download/3.0.3/vswhere.exe vswhere.exe + TLS_VERIFY ON + EXPECTED_HASH SHA1=8569081535767af53811f47c0e6abeabd695f8f4 + STATUS vswhere + ) + list(GET vswhere 0 vswhere) + if("0" EQUAL vswhere) + execute_process(COMMAND vswhere.exe -all -latest -property productPath + OUTPUT_VARIABLE DevEnvDir + OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET DevEnvDir PARENT_PATH DevEnvDir) + set(ENV{DevEnvDir} ${DevEnvDir}) + else() + set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/") + endif() endif() # Run VsDevCmd.bat and set all environment variables it changes From d2662fae2ed895bace7251cc31966f86309598bf Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 2 Nov 2022 20:08:43 +0100 Subject: [PATCH 083/188] Makes Ninja generators on Windows optional --- CMakePresets.json | 1 - build-scripts/windows-tiles-sounds-x64-msvc.cmake | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index f282bad5c7fa..b0ff592e0813 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,7 +6,6 @@ "description": "Base Build Configuration", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", - "generator": "Ninja", "cacheVariables": { "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" }, diff --git a/build-scripts/windows-tiles-sounds-x64-msvc.cmake b/build-scripts/windows-tiles-sounds-x64-msvc.cmake index 0a7a2fbc0c12..a6a508586950 100644 --- a/build-scripts/windows-tiles-sounds-x64-msvc.cmake +++ b/build-scripts/windows-tiles-sounds-x64-msvc.cmake @@ -33,4 +33,6 @@ configure_file( ) # Ninja is provided by Microsoft but not in the Path -set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +if (CMAKE_GENERATOR MATCHES "^Ninja") + set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +endif() From c3a09945c85f38fd81ebf5173bb11c2bbbcbe69f Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 4 Nov 2022 20:15:39 +0100 Subject: [PATCH 084/188] Move hardcoded path into preset --- CMakePresets.json | 3 +++ build-scripts/windows-tiles-sounds-x64-msvc.cmake | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index b0ff592e0813..dcf728048b5f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -26,6 +26,9 @@ "inherits": [ "windows" ], "description": "Visual C++ Configuration", "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", + "cacheVariables": { + "VCPKG_ROOT": "C:/vcpkg" + }, "hidden": true }, { diff --git a/build-scripts/windows-tiles-sounds-x64-msvc.cmake b/build-scripts/windows-tiles-sounds-x64-msvc.cmake index a6a508586950..6bb7d17cd9d7 100644 --- a/build-scripts/windows-tiles-sounds-x64-msvc.cmake +++ b/build-scripts/windows-tiles-sounds-x64-msvc.cmake @@ -18,7 +18,7 @@ if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") endif() # Ref https://vcpkg.io/en/docs/users/config-environment.html#vcpkg_root if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) - set(ENV{VCPKG_ROOT} C:/vcpkg) + set(ENV{VCPKG_ROOT} $CACHE{VCPKG_ROOT}) endif() include(${CMAKE_SOURCE_DIR}/build-scripts/VsDevCmd.cmake) From 88810eae5a82e75dcb03aa7e13dfc292861101ee Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 9 Nov 2022 19:37:39 +0100 Subject: [PATCH 085/188] Build a release --- CMakePresets.json | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakePresets.json b/CMakePresets.json index dcf728048b5f..a7c2dae9d95f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -49,6 +49,7 @@ "cacheVariables": { "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "RELEASE": "True", "CURSES": "False", "LOCALIZE": "True", "TILES": "True" From dd82e650e08284da4980b505967dab7143ee53a9 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 11 Nov 2022 12:31:09 +0100 Subject: [PATCH 086/188] Rewrite instructions addin VS procedure. Change displayed name --- CMakePresets.json | 2 +- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 60 ++++++++++++++++++-------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index a7c2dae9d95f..81e58b176edd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -44,7 +44,7 @@ { "name": "windows-tiles-sounds-x64-msvc", "inherits": [ "x64-windows-static" ], - "displayName": "x64 Release", + "displayName": "Windows Tiles Sounds x64 MSVC", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "cacheVariables": { "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake", diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md index 55840e12f179..8ee6af88d128 100644 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -5,49 +5,71 @@ For the official way to build CataclysmDDA, see: * [COMPILING.md](COMPILING.md) - # Contents 1. Prerequisites +2. Configure +3. Build +4. Install +5. Run -# Prerequisites +# 1 Prerequisites -`cmake` => 3.20.0
+`cmake` >= 3.20.0
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) -## Visual Studio - -`C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe` - -## vcpkg -If different from `C:\vcpkg`, define the installed path via `VCPKG_ROOT` env, add `-DVCPKG_ROOT=path` to `cmake` command, or edit `CMakePresets.json`'s `VCPKG_ROOT` cache variable. +# 2 Configure -# Presets +## Presets +The file `CMakePresets.json` contains all the presets.
+They will all build the code into the directory `out/build//`. -Presets will build into `out/build//` +## Visual Studio +The Standard toolbar shows the presets in the _Configuration_ drop-down box.
+From the main menu, select _Project -> Configure Cache_ -Run the command `cmake --list-presets` to show the presets available to you. +## Terminal +Run the command + * `cmake --list-presets`
+It will show the presets available to you. The list changes based on the environment you are in. - -# Configure - Run the command * `cmake --preset ` -# Build +If different from `C:\vcpkg` you can + * append `-DVCPKG_ROOT=your\path` to the above command + * set your path via `VCPKG_ROOT` environment variable + * edit `VCPKG_ROOT` cache variable in `CMakePresets.json` + +# 3 Build + +## Visual Studio +From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.
+From the main menu, select _Build -> Build All_ +## Terminal Run the command - * `cmake --build --preset --config RelWithDebInfo` + * `cmake --build --preset ` -# Install +# 4 Install +## Visual Studio +From the main menu, select _Build -> Install CataclysmDDA_ + +## Terminal Run the command * `cmake --install out/build// --config RelWithDebInfo` - # Run + # 5 Run + + ## Visual Studio +From the Standard toolbar's _Select Startup Item..._ drop-down menu select `cataclysm-tiles.exe (Install)`
+The _Project Configuration_ drop-down menu will show `RelWithDebInfo`.
+You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start Debugging_ (default F5). + ## Terminal Run the commands * `cd out/install//` * `cataclysm` or `cataclysm-tiles.exe` From 947b868655fcf0a176b2d2e76dd4685a5a23083d Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 16 Nov 2022 21:38:03 +0100 Subject: [PATCH 087/188] Add a missing target public interface --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7cd4d5d98009..9863f006ddb5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,7 +137,7 @@ if (TILES) endif () if (LIBBACKTRACE) - target_link_libraries(cataclysm-tiles-common backtrace) + target_link_libraries(cataclysm-tiles-common PUBLIC backtrace) endif () if (RELEASE) From e9db703cc74fd3c2f95537205163d2495282decb Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 25 Nov 2022 17:35:12 +0100 Subject: [PATCH 088/188] Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md Co-authored-by: akrieger --- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md index 8ee6af88d128..7bd92722db11 100644 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -18,13 +18,19 @@ For the official way to build CataclysmDDA, see: `cmake` >= 3.20.0
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) - # 2 Configure ## Presets The file `CMakePresets.json` contains all the presets.
They will all build the code into the directory `out/build//`. +## vcpkg + +If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one of the following: + * append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands + * set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout. + * edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path + ## Visual Studio The Standard toolbar shows the presets in the _Configuration_ drop-down box.
From the main menu, select _Project -> Configure Cache_ @@ -37,12 +43,7 @@ The list changes based on the environment you are in. Run the command * `cmake --preset ` - -If different from `C:\vcpkg` you can - * append `-DVCPKG_ROOT=your\path` to the above command - * set your path via `VCPKG_ROOT` environment variable - * edit `VCPKG_ROOT` cache variable in `CMakePresets.json` - + # 3 Build ## Visual Studio @@ -62,7 +63,7 @@ From the main menu, select _Build -> Install CataclysmDDA_ Run the command * `cmake --install out/build// --config RelWithDebInfo` - # 5 Run +# 5 Run ## Visual Studio From the Standard toolbar's _Select Startup Item..._ drop-down menu select `cataclysm-tiles.exe (Install)`
From d2868a4ad53bde737eda218341f545e44fe05014 Mon Sep 17 00:00:00 2001 From: alef Date: Fri, 25 Nov 2022 18:01:55 +0100 Subject: [PATCH 089/188] Reverting SDL2 TTF library name resolution in VCPKG Requires VCPK at their commit 659b6b5 --- CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db88ffbcabc4..19762e6d49d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,8 +329,8 @@ if (TILES) endif () message(STATUS "Searching for SDL2_TTF library --") - find_package(SDL2_ttf) - if (NOT (SDL2_TTF_FOUND OR TARGET SDL2_ttf::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) + find_package(sdl2-ttf) + if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static)) message( FATAL_ERROR "This project requires SDL2_ttf to be installed to be compiled in graphical mode. \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9863f006ddb5..84d17369ae77 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,7 @@ if (TILES) target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2 SDL2::SDL2main SDL2::SDL2_image - $,SDL2_ttf::SDL2_ttf,SDL2_ttf::SDL2_ttf-static>) + SDL2::SDL2_ttf) endif() if (SOUND) if (VCPKG_MANIFEST_MODE) From d0d0d345e7b8afdc2ba32304fc76b9f002868bde Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 26 Nov 2022 19:25:38 +0100 Subject: [PATCH 090/188] Move VCPKG to Windows only builds --- CMakePresets.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 81e58b176edd..a4fd4a91f5f7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,9 +6,6 @@ "description": "Base Build Configuration", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" - }, "hidden": true }, { @@ -19,6 +16,9 @@ "lhs": "${hostSystemName}", "rhs": "Windows" }, + "cacheVariables": { + "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" + }, "hidden": true }, { From 4f0a8cc7f4485cef76813dc4d5993b3cb0845153 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 26 Nov 2022 19:26:02 +0100 Subject: [PATCH 091/188] Use SDL2_ttf when not using VCPKG --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19762e6d49d1..00e6e4b205f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,7 +329,11 @@ if (TILES) endif () message(STATUS "Searching for SDL2_TTF library --") - find_package(sdl2-ttf) + if (NOT VCPKG_MANIFEST_MODE) + find_package(SDL2_ttf) + else() + find_package(sdl2-ttf) + endif() if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static)) message( FATAL_ERROR From a03a1c7dcc709c92da8b5a666ae9258653d13075 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 11:05:12 +0100 Subject: [PATCH 092/188] Disable the MSYS build preset --- CMakePresets.json | 16 +++++++++++++--- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index a4fd4a91f5f7..c22df30c2dfc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,9 +12,19 @@ "name": "windows", "description": "Windows Build Configuration", "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" + "type": "allOf", + "conditions": [ + { + "type": "equals", + "lhs": "$env{MSYSTEM}", + "rhs": "" + }, + { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + ] }, "cacheVariables": { "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md index 7bd92722db11..74f91948bc05 100644 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -40,6 +40,7 @@ Run the command * `cmake --list-presets`
It will show the presets available to you. The list changes based on the environment you are in. +If empty, the environment is not supported. Run the command * `cmake --preset ` From 28383153df7d70d75e9eb504aa338002e908b597 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 11:47:42 +0100 Subject: [PATCH 093/188] Search for gettext in one place --- CMakeLists.txt | 7 +++++++ tests/CMakeLists.txt | 11 ----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e6e4b205f3..e06f6b14bb08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -415,6 +415,13 @@ if (BACKTRACE) endif () endif () +if (LOCALIZE OR BUILD_TESTING) + if(MSVC) + list(APPEND Gettext_ROOT C:\\msys64\\usr) + list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\mingw64) + endif(MSVC) + find_package(Gettext) +endif () # Ok. Now create build and install recipes if (USE_HOME_DIR) add_definitions(-DUSE_HOME_DIR) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4efc7a4d03d2..e46c919e71ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,17 +5,6 @@ if (BUILD_TESTING) add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) # TODO: build MO files required for tests - if(MSVC) - find_program(GETTEXT_MSGFMT_EXECUTABLE - msgfmt.exe - HINTS - C:\\msys64\\usr\\bin - C:\\Prorogram\ Files\\Git\\mingw64\\bin - REQUIRED - ) - else() - set(GETTEXT_MSGFMT_EXECUTABLE msgfmt) - endif() if (TILES) add_executable(cata_test-tiles ${CATACLYSM_BN_TEST_SOURCES}) From d092896f2ff9ab937b39b3a086d6283bdaad76e9 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 11:49:09 +0100 Subject: [PATCH 094/188] Make VCPKG_ROOT optional in MSVC too Fixes an error when using cmake-gui --- build-scripts/MSVC.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 62ca248825fa..95d8067b7004 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -82,5 +82,7 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") # Where is vcpkg.json ? set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) -# Bring VCPKG in -include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) +if (NOT $ENV{VCPKG_ROOT} STREQUAL "") + # Bring VCPKG in + include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) +endif() From 537161ff3db3be253738b9dc4a39493197ae927a Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 12:34:57 +0100 Subject: [PATCH 095/188] Allow to configure msgfmt and VCPKG paths --- CMakeLists.txt | 3 ++- build-scripts/MSVC.cmake | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e06f6b14bb08..19b08e55cf1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ set(GIT_BINARY set(LINKER "" CACHE STRING "Custom Linker to use") +set(GETTEXT_MSGFMT_EXECUTABLE "" CACHE FILEPATH "msgfmt binary name or path.") include(CTest) @@ -415,7 +416,7 @@ if (BACKTRACE) endif () endif () -if (LOCALIZE OR BUILD_TESTING) +if ((LOCALIZE OR BUILD_TESTING) AND NOT GETTEXT_MSGFMT_EXECUTABLE STREQUAL "") if(MSVC) list(APPEND Gettext_ROOT C:\\msys64\\usr) list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\mingw64) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index 95d8067b7004..b2d37ad0715e 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -82,7 +82,9 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") # Where is vcpkg.json ? set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) +set(VCPKG_ROOT "" CACHE PATH "Path to VCPKG installation") if (NOT $ENV{VCPKG_ROOT} STREQUAL "") - # Bring VCPKG in include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) +elseif(NOT $CACHE{VCPKG_ROOT} STREQUAL "") + include($CACHE{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) endif() From 593874007cc2990791dca460bc13061f654560f3 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 18:49:27 +0100 Subject: [PATCH 096/188] Fix using cache var in find_program(). Remove extra find_package --- CMakeLists.txt | 8 ++++++-- lang/CMakeLists.txt | 9 +++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19b08e55cf1b..1d20cea650d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ set(GIT_BINARY set(LINKER "" CACHE STRING "Custom Linker to use") -set(GETTEXT_MSGFMT_EXECUTABLE "" CACHE FILEPATH "msgfmt binary name or path.") +set(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.") include(CTest) @@ -416,13 +416,17 @@ if (BACKTRACE) endif () endif () -if ((LOCALIZE OR BUILD_TESTING) AND NOT GETTEXT_MSGFMT_EXECUTABLE STREQUAL "") +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\\mingw64) 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 (USE_HOME_DIR) add_definitions(-DUSE_HOME_DIR) diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index ef5cf2c0ceff..1175cd7ee517 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -5,15 +5,12 @@ if (LANGUAGES STREQUAL none) return() endif () -find_package(Gettext) - -if (NOT GETTEXT_FOUND) - message( - FATAL_ERROR +if(NOT GETTEXT_MSGFMT_EXECUTABLE) + message(FATAL_ERROR "Gettext not found. Install gettext package or disable \ compilation of language files with: -DLANGUAGES=none. \ See CMake compiling guide for details and more info.") -endif () +endif() if (LANGUAGES STREQUAL all) set(LANGUAGES "") From e526411278258ba19ee8382adcd7c0b46f8bbcec Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 19:19:54 +0100 Subject: [PATCH 097/188] Use correct Git for Windows directory Co-authored-by: akrieger --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d20cea650d3..aa7db923d902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,7 +419,7 @@ 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\\mingw64) + list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\usr) endif(MSVC) find_package(Gettext) endif () From c750cd12d18513a490014beacb9e9260047ac34c Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 20:28:27 +0100 Subject: [PATCH 098/188] Make building tests optional. Use "TESTS" cache var --- CMakeLists.txt | 7 ++++++- CMakePresets.json | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa7db923d902..062342752900 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(USE_UNITY_BUILD "Use unity build." "OFF") option(USE_PCH_HEADER "Use precompiled PCH header." "OFF") option(JSON_FORMAT "Build JSON formatter" "OFF") option(CATA_CCACHE "Try to find and build with ccache" "ON") +option(TESTS "Compile Cata's tests" "OFF") option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF") set(CATA_CLANG_TIDY_INCLUDE_DIR "" @@ -48,7 +49,9 @@ set(LINKER CACHE STRING "Custom Linker to use") set(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.") +if (TESTS) include(CTest) +endif() include(GetGitRevisionDescription) git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*") @@ -444,7 +447,9 @@ add_subdirectory(src) add_subdirectory(data) add_subdirectory(lang) -add_subdirectory(tests) +if(TESTS) + add_subdirectory(tests) +endif() if (JSON_FORMAT) add_subdirectory(tools/format) endif () diff --git a/CMakePresets.json b/CMakePresets.json index c22df30c2dfc..a648784b0035 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -62,7 +62,8 @@ "RELEASE": "True", "CURSES": "False", "LOCALIZE": "True", - "TILES": "True" + "TILES": "True", + "TESTS": "True" } } ] From 0eb91e2e65f08d9af9596ae63554b291aabf1d1b Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 21:48:02 +0100 Subject: [PATCH 099/188] Install more directories --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 062342752900..a2d1d290423b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -457,6 +457,9 @@ if (CATA_CLANG_TIDY_PLUGIN) add_subdirectory(tools/clang-tidy-plugin) endif () +install(DIRECTORY doc gfx + DESTINATION . +) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) From 498227464c7380e23f4531b6f7a59419c895d5dc Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 21:23:27 +0100 Subject: [PATCH 100/188] Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md Co-authored-by: akrieger --- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md index 74f91948bc05..d34eb77b0ff8 100644 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -17,7 +17,7 @@ For the official way to build CataclysmDDA, see: `cmake` >= 3.20.0
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) - +`msgfmt` (optional) as part of Git Bash or msys2 in the default install paths. # 2 Configure ## Presets @@ -35,6 +35,9 @@ If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcp The Standard toolbar shows the presets in the _Configuration_ drop-down box.
From the main menu, select _Project -> Configure Cache_ +If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`. + * Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do not commit this change. + ## Terminal Run the command * `cmake --list-presets`
@@ -45,6 +48,10 @@ If empty, the environment is not supported. Run the command * `cmake --preset ` + If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally pass `-DLOCALIZE=OFF`. + + * `cmake --preset -DLOCALIZE=OFF` + # 3 Build ## Visual Studio From 0aeacf7f7f3a756e89e4fdff88a6523291e4756d Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 27 Nov 2022 22:03:29 +0100 Subject: [PATCH 101/188] Satisfy cmake-lint --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2d1d290423b..3fa5fcaf524c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -457,7 +457,7 @@ if (CATA_CLANG_TIDY_PLUGIN) add_subdirectory(tools/clang-tidy-plugin) endif () -install(DIRECTORY doc gfx +install(DIRECTORY doc gfx DESTINATION . ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" From 69c968d75a2b284f4ba89afe885d0207d25ab9de Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 28 Nov 2022 21:43:12 +0100 Subject: [PATCH 102/188] Move logic non belonging to data/ up --- CMakeLists.txt | 18 ++++++++++++++++-- data/CMakeLists.txt | 9 --------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fa5fcaf524c..8d553a4bd29c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -460,8 +460,22 @@ endif () install(DIRECTORY doc gfx DESTINATION . ) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) + +if (RELEASE) + install(FILES + ${CMAKE_SOURCE_DIR}/README.md + ${CMAKE_SOURCE_DIR}/LICENSE.txt + ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt + DESTINATION .) + if (TILES) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION .) + 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") diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 90a0b22e5be5..0e506584854b 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -23,13 +23,4 @@ set(CATACLYSM_DATA_FILES 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 () From 7be796b2a000c7dda3bc0330af0c5ae11f545904 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 28 Nov 2022 23:01:08 +0100 Subject: [PATCH 103/188] Install VERSION.txt --- CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d553a4bd29c..a3942711d493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,8 +90,19 @@ if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND") "// NOLINT(cata-header-guard)\n\#define VERSION \"${GIT_VERSION}\"\n") message(STATUS "${PROJECT_NAME} build version is : ${GIT_VERSION}\n") add_definitions(-DGIT_VERSION) -else () - message("") + + # get_git_head_revision() does not work with worktrees in Windows + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE _sha1 + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(TIMESTAMP _timestamp %Y-%m-%d-%H%M) + file(WRITE VERSION.txt "\ +build type: ${BUILD_PRESET_NAME}\n\ +build number: ${_timestamp}\n\ +commit sha: ${_sha1}\n\ +commit url: https://github.com/CleverRaven/Cataclysm-DDA/commit/${_sha1}" + ) endif () #OS Check Placeholders. Will be used for BINDIST @@ -466,6 +477,7 @@ if (RELEASE) ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt + ${CMAKE_SOURCE_DIR}/VERSION.txt DESTINATION .) if (TILES) install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION .) From d84084c22ee032cc877c02b815c2efec38272857 Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 30 Nov 2022 21:47:07 +0100 Subject: [PATCH 104/188] Switch building tests from CMake to presets --- CMakeLists.txt | 2 +- CMakePresets.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3942711d493..ef33a741831e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ option(USE_UNITY_BUILD "Use unity build." "OFF") option(USE_PCH_HEADER "Use precompiled PCH header." "OFF") option(JSON_FORMAT "Build JSON formatter" "OFF") option(CATA_CCACHE "Try to find and build with ccache" "ON") -option(TESTS "Compile Cata's tests" "OFF") +option(TESTS "Compile Cata's tests" "ON") option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF") set(CATA_CLANG_TIDY_INCLUDE_DIR "" diff --git a/CMakePresets.json b/CMakePresets.json index a648784b0035..f28aff06000d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -63,7 +63,7 @@ "CURSES": "False", "LOCALIZE": "True", "TILES": "True", - "TESTS": "True" + "TESTS": "False" } } ] From dde9e433b5ef54b6151f48add13fc87913998029 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 1 Dec 2022 00:32:57 +0100 Subject: [PATCH 105/188] Add shlwapi required by mpg123 --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84d17369ae77..a6f832e407f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -128,6 +128,9 @@ if (TILES) 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 (SOUND) + target_link_libraries(cataclysm-tiles-common PUBLIC shlwapi.lib) + endif() if (BACKTRACE) target_link_libraries(cataclysm-tiles-common PUBLIC dbghelp.lib) if (LIBBACKTRACE) From ee997446f59eb43798abe462cd4674c8d6bf5dac Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 1 Dec 2022 00:33:49 +0100 Subject: [PATCH 106/188] Split SDL2 mixer package names --- CMakeLists.txt | 11 +++++++---- src/CMakeLists.txt | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef33a741831e..aa8f85268f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -404,16 +404,19 @@ if (SOUND) endif () # Sound requires SDL_mixer library - message(STATUS "Searching for SDL2_mixer library --\n") - find_package(SDL2_mixer) if(VCPKG_MANIFEST_MODE) - if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static + message(STATUS "Searching for sdl2-mixer library --") + find_package(sdl2-mixer) + if (NOT TARGET SDL2::SDL2_mixer) message(FATAL_ERROR - "You need the SDL2_mixer development library \ + "You need the sdl2-mixer development library \ to be able to compile with sound enabled. \ See CMake compiling guide for details and more info.") endif() else() + message(STATUS "Searching for SDL2_mixer library --") + find_package(SDL2_mixer) + # if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static ? if (NOT SDL2_MIXER_FOUND) message(FATAL_ERROR "You need the SDL2_mixer development library \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6f832e407f8..0f86fcbf0b9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,7 +106,8 @@ if (TILES) if (VCPKG_MANIFEST_MODE) find_package(Ogg REQUIRED) find_package(Vorbis REQUIRED) - target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static + # SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ? + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2_mixer Ogg::ogg Vorbis::vorbis) endif() From e843301ce6d5a46cad869ea548749ba56285c151 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 1 Dec 2022 00:33:57 +0100 Subject: [PATCH 107/188] Enable sound --- CMakePresets.json | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakePresets.json b/CMakePresets.json index f28aff06000d..43f17b9642aa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -63,6 +63,7 @@ "CURSES": "False", "LOCALIZE": "True", "TILES": "True", + "SOUND": "True", "TESTS": "False" } } From 0825feefe5bc0d1c24536a8ee66f605264b7ab3e Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Mon, 9 Jan 2023 01:08:39 -0500 Subject: [PATCH 108/188] Correct CMake install locations on *nix --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa8f85268f88..800d6f38a2a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,6 +159,9 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Linux|FreeBSD|Darwin)") if (NOT DATA_PREFIX) set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-bn) endif () + if (NOT README_DIR) + set(README_DIR ${DATA_PREFIX}) + endif () if (NOT BIN_PREFIX) set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin) endif () @@ -180,6 +183,9 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Windows|MSYS)") if (NOT DATA_PREFIX) set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/data) endif () + if (NOT README_DIR) + set(README_DIR ${CMAKE_INSTALL_PREFIX}) + endif () if (NOT BIN_PREFIX) set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) endif () @@ -472,7 +478,7 @@ if (CATA_CLANG_TIDY_PLUGIN) endif () install(DIRECTORY doc gfx - DESTINATION . + DESTINATION ${DATA_PREFIX} ) if (RELEASE) @@ -481,9 +487,9 @@ if (RELEASE) ${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt ${CMAKE_SOURCE_DIR}/VERSION.txt - DESTINATION .) + DESTINATION ${README_DIR}) if (TILES) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION .) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${DATA_PREFIX}) endif() endif() From b80763053608dbb8a59850e11fa6a5c5ffa5d698 Mon Sep 17 00:00:00 2001 From: Binrui Dong Date: Wed, 7 Dec 2022 01:37:34 +0800 Subject: [PATCH 109/188] Remove x86 specific macro definitions in MSVC build in CMake (#62602) --- CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 800d6f38a2a2..d2f8e71b68f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,13 +271,7 @@ endif () message(STATUS "See CMake compiling guide 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 () -else () +if (NOT MSVC) set(CATA_WARNINGS "-Werror -Wall -Wextra \ -Wformat-signedness \ From c8b91f952e19efaa6a15af6b36fc5ffcefaf0d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jianxiang=20Wang=20=28=E7=8E=8B=E5=81=A5=E7=BF=94=29?= Date: Sun, 22 Jan 2023 16:11:30 +0800 Subject: [PATCH 110/188] Fix CMake compilation and localization Localization: - Outdated .gitignore entry Compilation: - `target_link_libraries` mixed signature error --- .gitignore | 1 - src/CMakeLists.txt | 28 +++++++++++++--------------- tests/CMakeLists.txt | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 4c37b66ae7f6..fd8d35ec8a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -98,7 +98,6 @@ tags # Generated translation source /lang/po/cataclysm-bn.pot -/lang/po/en.po # Compiled binary translations /lang/mo/ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f86fcbf0b9a..4d8573becac3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,9 +56,8 @@ if (TILES) add_dependencies(cataclysm-tiles-common get_version) - target_link_libraries(cataclysm-tiles cataclysm-tiles-common) - target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) - + target_link_libraries(cataclysm-tiles PRIVATE cataclysm-tiles-common) + target_compile_definitions(cataclysm-tiles-common PUBLIC TILES ) if(NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") target_precompile_headers(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) @@ -172,35 +171,34 @@ if (CURSES) endif () add_dependencies(cataclysm-common get_version) - target_link_libraries(cataclysm cataclysm-common) + target_link_libraries(cataclysm PRIVATE cataclysm-common) target_include_directories(cataclysm-common PUBLIC ${CURSES_INCLUDE_DIR}) - target_link_libraries(cataclysm-common ${CURSES_LIBRARIES}) + target_link_libraries(cataclysm-common PUBLIC ${CURSES_LIBRARIES}) if (CMAKE_USE_PTHREADS_INIT) target_compile_options(cataclysm-common PUBLIC "-pthread") endif () if (CMAKE_THREAD_LIBS_INIT) - target_link_libraries(cataclysm-common ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(cataclysm-common PUBLIC ${CMAKE_THREAD_LIBS_INIT}) endif () if (WIN32) # Global settings for Windows targets (at end) - target_link_libraries(cataclysm-common gdi32.lib) - target_link_libraries(cataclysm-common winmm.lib) - target_link_libraries(cataclysm-common imm32.lib) - target_link_libraries(cataclysm-common ole32.lib) - target_link_libraries(cataclysm-common oleaut32.lib) - target_link_libraries(cataclysm-common version.lib) - + target_link_libraries(cataclysm-common PUBLIC gdi32.lib) + target_link_libraries(cataclysm-common PUBLIC winmm.lib) + target_link_libraries(cataclysm-common PUBLIC imm32.lib) + target_link_libraries(cataclysm-common PUBLIC ole32.lib) + target_link_libraries(cataclysm-common PUBLIC oleaut32.lib) + target_link_libraries(cataclysm-common PUBLIC version.lib) if (BACKTRACE) - target_link_libraries(cataclysm-common dbghelp.lib) + target_link_libraries(cataclysm-common PUBLIC dbghelp.lib) endif () endif () if (LIBBACKTRACE) - target_link_libraries(cataclysm-common backtrace) + target_link_libraries(cataclysm-common PUBLIC backtrace) endif () if (RELEASE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e46c919e71ad..35c56dfe262a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,7 @@ if (BUILD_TESTING) if (LUA) target_compile_definitions(cata_test-tiles PUBLIC LUA) endif () - target_link_libraries(cata_test-tiles cataclysm-tiles-common) + target_link_libraries(cata_test-tiles PRIVATE cataclysm-tiles-common) add_test( NAME test-tiles COMMAND sh -c "$ --rng-seed time" @@ -23,7 +23,7 @@ if (BUILD_TESTING) if (LUA) target_compile_definitions(cata_test PUBLIC LUA) endif () - target_link_libraries(cata_test cataclysm-common) + target_link_libraries(cata_test PRIVATE cataclysm-common) add_test( NAME test COMMAND sh -c "$ --rng-seed time" From e590c7ed174c7f46db2c329546891c395bdfca6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jianxiang=20Wang=20=28=E7=8E=8B=E5=81=A5=E7=BF=94=29?= Date: Fri, 31 Mar 2023 10:44:59 +0800 Subject: [PATCH 111/188] Enable -g1 in CMake release build to produce source and line number in stack trace (#64705) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2f8e71b68f2..f08f441b1615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,11 +294,11 @@ if (NOT MSVC) if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Windows") set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls") endif () - set(CATA_OTHER_FLAGS "${CATA_OTHER_FLAGS} -fsigned-char") + 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 -g") + set(CMAKE_CXX_FLAGS_DEBUG "-Og -g2") endif () set(CMAKE_CXX_STANDARD 17) From e2696e8eeabbc20534a4797ff4e8079a8f187946 Mon Sep 17 00:00:00 2001 From: "Clarence \"Sparr\" Risher" Date: Fri, 7 Apr 2023 22:24:16 -0400 Subject: [PATCH 112/188] Add CMake option for XDG directories --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f08f441b1615..665a774c72bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,8 @@ option(SOUND "Support for in-game sounds & music." "OFF") option(LUA "Support for in-game scripting with Lua." "OFF") option(BACKTRACE "Support for printing stack backtraces on crash" "ON") option(LIBBACKTRACE "Print backtrace with libbacktrace." "OFF") -option(USE_HOME_DIR "Use user's home directory for save files." "ON") +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") option(USE_PREFIX_DATA_DIR "Use UNIX system directories for game data in release build." "ON") set(LANGUAGES "" @@ -213,6 +214,11 @@ 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) @@ -260,6 +266,7 @@ message(STATUS "LUA : ${LUA}") message(STATUS "BACKTRACE : ${BACKTRACE}") message(STATUS "LIBBACKTRACE : ${LIBBACKTRACE}") message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}\n") +message(STATUS "USE_XDG_DIR : ${USE_XDG_DIR}") message(STATUS "UNITY_BUILD : ${USE_UNITY_BUILD}") message(STATUS "PCH_HEADER : ${USE_PCH_HEADER}") @@ -449,6 +456,10 @@ 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) if (CCACHE_FOUND AND CATA_CCACHE) set(CMAKE_C_COMPILER_LAUNCHER ccache) From c8f30e5278adea0727112bbcb8adc4a903323033 Mon Sep 17 00:00:00 2001 From: akrieger Date: Thu, 6 Apr 2023 06:45:53 -0700 Subject: [PATCH 113/188] Update vcpkg configuration, again --- .github/workflows/msvc-full-features.yml | 15 ++++++--------- .github/workflows/release.yml | 22 ++++++++-------------- msvc-full-features/vcpkg.json | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/msvc-full-features.yml b/.github/workflows/msvc-full-features.yml index 0e86dc543ca8..ef971269b40a 100644 --- a/.github/workflows/msvc-full-features.yml +++ b/.github/workflows/msvc-full-features.yml @@ -59,18 +59,15 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.3.1 - - name: Restore artifacts, or run vcpkg, build and cache artifacts - uses: lukka/run-vcpkg@v10 + - name: Install stable CMake + uses: lukka/get-cmake@latest + + - name: Install vcpkg + uses: lukka/run-vcpkg@v11 id: runvcpkg with: - # run-vcpkg tries to hash vcpkg.json but complans if it finds more than one. - # That said, we also have our custom vcpkg_triplets to hash, so we keep everything the same. - appendedCacheKey: ${{ hashFiles( 'msvc-full-features/vcpkg.json', '.github/vcpkg_triplets/**' ) }}-x64 vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' - # Keep vcpkg version here in sync with the builtin-baseline - # field in vcpkg.json. Caching happens as a post-action which runs at the end of - # the whole workflow, after vcpkg install happens during msbuild run. - vcpkgGitCommitId: 'a7b6122f6b6504d16d96117336a0562693579933' + vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' - name: Integrate vcpkg run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 941a48e1aa62..c49462efaab2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -182,24 +182,18 @@ jobs: commit sha: ${{ github.sha }} commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }} EOL - - name: Install dependencies (windows msvc) (1/3) + - name: Install MSBuild (windows msvc) if: runner.os == 'Windows' uses: microsoft/setup-msbuild@v1.3.1 - - name: Install dependencies (windows msvc) (2/3) - if: runner.os == 'Windows' - uses: lukka/run-vcpkg@main + - name: Install stable CMake + uses: lukka/get-cmake@latest + - name: Install vcpkg + uses: lukka/run-vcpkg@v11 id: runvcpkg with: - additionalCachedPaths: "${{ runner.workspace }}/Cataclysm-BN/msvc-full-features/vcpkg_installed" - appendedCacheKey: ${{ hashFiles( 'msvc-full-features/vcpkg.json', '.github/vcpkg_triplets/**' ) }}-${{ matrix.arch }}-1 - setupOnly: true - vcpkgDirectory: "${{ runner.workspace }}/b/vcpkg" - # We have to use at least this version of vcpkg to include fixes for - # various issues we've encountered over time. Keep it in sync with the builtin-baseline - # field in vcpkg.json. Caching happens as a post-action which runs at the end of - # the whole workflow, after vcpkg install happens during msbuild run. - vcpkgGitCommitId: "a7b6122f6b6504d16d96117336a0562693579933" - - name: Install dependencies (windows msvc) (3/3) + vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' + vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' + - name: Integrate vcpkg if: runner.os == 'Windows' run: | vcpkg integrate install diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index bc752e821e66..558eafe94d8c 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -9,7 +9,7 @@ }, { "name": "sdl2-mixer", - "features": [ "libflac", "mpg123", "libmodplug", "libvorbis" ] + "features": [ "libflac", "mpg123", "libmodplug" ] }, "sdl2-ttf" ] From f3068fe78049f13d2149db8a301cf0308a6d2d77 Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 2 May 2023 03:14:51 +0200 Subject: [PATCH 114/188] Downgrade cmake files to v3.20 * Use CMake version 3.20 and presets version 2 * Flatten presets into one * Use presetName for the include file * Start using multi-config generators * Add a Linux release configuration and build preset * Display PROJECT_NAME during configuration * Fix all SDL2 related target names --- CMakeLists.txt | 20 +++--- CMakePresets.json | 90 +++++++++++--------------- build-scripts/CMakeUserPresets.json.in | 2 +- src/CMakeLists.txt | 10 ++- 4 files changed, 52 insertions(+), 70 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 665a774c72bd..76d73fa9bdfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.20) project(CataclysmBN) @@ -70,7 +70,7 @@ message(" --= Bright Nights =--") message("\n * https://github.com/cataclysmbnteam/Cataclysm-BN\n") -message(STATUS "${PROJECT} build environment -- \n") +message(STATUS "${PROJECT_NAME} build environment -- \n") message( STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}") @@ -222,8 +222,7 @@ endif () # Set build types and display info if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") set(RELEASE 0) - message("\n") - message(STATUS "Build ${PROJECT} in development mode --\n") + 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 @@ -354,9 +353,9 @@ if (TILES) if (NOT VCPKG_MANIFEST_MODE) find_package(SDL2_ttf) else() - find_package(sdl2-ttf) + find_package(SDL2_ttf) endif() - if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static)) + if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) message( FATAL_ERROR "This project requires SDL2_ttf to be installed to be compiled in graphical mode. \ @@ -367,11 +366,11 @@ if (TILES) message(STATUS "Searching for SDL2_image library --\n") if(VCPKG_MANIFEST_MODE) - find_package(sdl2-image) + find_package(SDL2_image) else() find_package(SDL2_image) endif() - if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image)) + if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2_image::SDL2_image-static)) message( FATAL_ERROR "This project requires SDL2_image to be installed to be compiled in graphical mode. \ @@ -413,8 +412,9 @@ if (SOUND) # Sound requires SDL_mixer library if(VCPKG_MANIFEST_MODE) message(STATUS "Searching for sdl2-mixer library --") - find_package(sdl2-mixer) - if (NOT TARGET SDL2::SDL2_mixer) + find_package(Ogg REQUIRED) + find_package(SDL2_mixer) + if (NOT (TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static)) message(FATAL_ERROR "You need the sdl2-mixer development library \ to be able to compile with sound enabled. \ diff --git a/CMakePresets.json b/CMakePresets.json index 43f17b9642aa..d3c484d59a99 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,71 +1,55 @@ { - "version": 3, + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, "configurePresets": [ { - "name": "base", - "description": "Base Build Configuration", + "name": "windows-tiles-sounds-x64-msvc", "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "hidden": true - }, - { - "name": "windows", - "description": "Windows Build Configuration", - "condition": { - "type": "allOf", - "conditions": [ - { - "type": "equals", - "lhs": "$env{MSYSTEM}", - "rhs": "" - }, - { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - } - ] - }, - "cacheVariables": { - "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" - }, - "hidden": true - }, - { - "name": "MSVC", - "inherits": [ "windows" ], - "description": "Visual C++ Configuration", - "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", - "cacheVariables": { - "VCPKG_ROOT": "C:/vcpkg" - }, - "hidden": true - }, - { - "name": "x64-windows-static", - "inherits": [ "base", "MSVC" ], - "description": "Link Statically", + "displayName": "Windows Tiles Sounds x64 MSVC", + "description": "Target Windows (64-bit) with the Visual Studio development environment.", + "generator": "Ninja Multi-Config", "cacheVariables": { + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake", + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", - "DYNAMIC_LINKING": "False" - }, - "hidden": true + "VCPKG_ROOT": "C:/vcpkg", + "DYNAMIC_LINKING": "False", + "RELEASE": "True", + "CURSES": "False", + "LOCALIZE": "True", + "TILES": "True", + "SOUND": "True", + "TESTS": "False" + } }, { - "name": "windows-tiles-sounds-x64-msvc", - "inherits": [ "x64-windows-static" ], - "displayName": "Windows Tiles Sounds x64 MSVC", - "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", + "name": "linux-tiles-sounds-x64", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "displayName": "Linux Tiles Sounds x64", + "description": "Target Linux (64-bit) with the GCC development environment.", + "generator": "Ninja Multi-Config", "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "VCPKG_TARGET_TRIPLET": "x64-linux", + "CMAKE_TOOLCHAIN_FILE": "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake", + "VCPKG_MANIFEST_DIR": "msvc-full-features/", + "DYNAMIC_LINKING": "False", "RELEASE": "True", "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", - "TESTS": "False" + "TESTS": "False" } } + ], + "buildPresets": [ + { + "name": "linux-tiles-sounds-x64", + "configurePreset": "linux-tiles-sounds-x64" + } ] } diff --git a/build-scripts/CMakeUserPresets.json.in b/build-scripts/CMakeUserPresets.json.in index c94506d48a11..47a6f1ba9ec5 100644 --- a/build-scripts/CMakeUserPresets.json.in +++ b/build-scripts/CMakeUserPresets.json.in @@ -1,5 +1,5 @@ { - "version": 3, + "version": 2, "buildPresets": [ { "name": "@BUILD_PRESET_NAME@", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d8573becac3..94941359a017 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.21) - set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp) set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp) set(RESOURCE_RC ${CMAKE_SOURCE_DIR}/src/resource.rc) @@ -98,15 +96,15 @@ if (TILES) if(TARGET SDL2::SDL2) target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2 SDL2::SDL2main - SDL2::SDL2_image - SDL2::SDL2_ttf) + SDL2_image::SDL2_image-static + SDL2_ttf::SDL2_ttf-static) endif() if (SOUND) if (VCPKG_MANIFEST_MODE) find_package(Ogg REQUIRED) - find_package(Vorbis REQUIRED) # SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ? - target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2_mixer + find_package(Vorbis REQUIRED) + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static Ogg::ogg Vorbis::vorbis) endif() From 24fcf29db403ca1e6934b52e8c69444a6ff33008 Mon Sep 17 00:00:00 2001 From: Binrui Dong Date: Wed, 7 Dec 2022 01:37:15 +0800 Subject: [PATCH 115/188] Add VERSION.txt to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index fd8d35ec8a6d..6b186b827547 100644 --- a/.gitignore +++ b/.gitignore @@ -207,3 +207,6 @@ Xcode/ /tests/pch/tests-pch.hpp.pch /tests/catch/catch.hpp.gch /tests/catch/catch.hpp.pch + +# VERSION.txt generated by our CMakeLists.txt +VERSION.txt From 0b593fc74617bb9a01d854d33d9240d3157f24d6 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 24 Oct 2023 22:26:58 +0300 Subject: [PATCH 116/188] Add 'out/' to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6b186b827547..68a116e8c6a5 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ Release*/ # Temporary CMakeFiles CMakeUserPresets.json +out/ # Visual Studio 2015 /msvc-full-features/*db From d74bcf5d816753ab2e879255fc6e119ddf833757 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 24 Oct 2023 22:27:31 +0300 Subject: [PATCH 117/188] Fix merge conflict related to PCH, always use PCH --- CMakeLists.txt | 2 -- src/CMakeLists.txt | 13 +++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76d73fa9bdfa..61fb217ea319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ set(LANGUAGES option(DYNAMIC_LINKING "Use dynamic linking. Or use static to remove MinGW dependency instead." "ON") option(USE_UNITY_BUILD "Use unity build." "OFF") -option(USE_PCH_HEADER "Use precompiled PCH header." "OFF") option(JSON_FORMAT "Build JSON formatter" "OFF") option(CATA_CCACHE "Try to find and build with ccache" "ON") option(TESTS "Compile Cata's tests" "ON") @@ -268,7 +267,6 @@ message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}\n") message(STATUS "USE_XDG_DIR : ${USE_XDG_DIR}") message(STATUS "UNITY_BUILD : ${USE_UNITY_BUILD}") -message(STATUS "PCH_HEADER : ${USE_PCH_HEADER}") message(STATUS "LANGUAGES : ${LANGUAGES}\n") if (LINKER) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94941359a017..6e5724084192 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ if (TILES) ${LUA_C_SOURCES}) target_include_directories(cataclysm-tiles-common INTERFACE ${CMAKE_SOURCE_DIR}/src) - if (USE_PCH_HEADER) + if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") target_precompile_headers(cataclysm-tiles-common PRIVATE ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) endif () @@ -55,11 +55,7 @@ if (TILES) add_dependencies(cataclysm-tiles-common get_version) target_link_libraries(cataclysm-tiles PRIVATE cataclysm-tiles-common) - target_compile_definitions(cataclysm-tiles-common PUBLIC TILES ) - if(NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") - target_precompile_headers(cataclysm-tiles-common PUBLIC - ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) - endif () + target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) if (CMAKE_USE_PTHREADS_INIT) target_compile_options(cataclysm-tiles-common PUBLIC "-pthread") @@ -152,8 +148,9 @@ if (CURSES) ${LUA_C_SOURCES}) target_include_directories(cataclysm-common INTERFACE ${CMAKE_SOURCE_DIR}/src) - if (USE_PCH_HEADER) - target_precompile_headers(cataclysm-common PRIVATE ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") + target_precompile_headers(cataclysm-common PRIVATE + ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) endif () if (WIN32) From 7e79c001edb697378559479a653a4b5b0a333309 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 24 Oct 2023 22:29:38 +0300 Subject: [PATCH 118/188] BNify link in VERSION.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61fb217ea319..be27cf38d27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,8 +101,7 @@ if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND") build type: ${BUILD_PRESET_NAME}\n\ build number: ${_timestamp}\n\ commit sha: ${_sha1}\n\ -commit url: https://github.com/CleverRaven/Cataclysm-DDA/commit/${_sha1}" - ) +commit url: https://github.com/cataclysmbnteam/Cataclysm-BN/commit/${_sha1}") endif () #OS Check Placeholders. Will be used for BINDIST From a9390c09198222173233880ecea0435619746388 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 24 Oct 2023 22:30:18 +0300 Subject: [PATCH 119/188] BNify comment --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be27cf38d27f..2a3065f45364 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,7 +223,7 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 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 + # Since CataclysmBN 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 From be268e73faeee8834e512d1cd75cb010df375715 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 24 Oct 2023 23:55:17 +0300 Subject: [PATCH 120/188] Fix Lua build --- src/CMakeLists.txt | 17 ++++++----------- src/lua/CMakeLists.txt | 5 +++++ src/sol/CMakeLists.txt | 5 +++++ src/sol/{ => sol}/config.hpp | 0 src/sol/{ => sol}/forward.hpp | 0 src/sol/{ => sol}/sol.hpp | 0 6 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 src/lua/CMakeLists.txt create mode 100644 src/sol/CMakeLists.txt rename src/sol/{ => sol}/config.hpp (100%) rename src/sol/{ => sol}/forward.hpp (100%) rename src/sol/{ => sol}/sol.hpp (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e5724084192..85180f139ce2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,9 +9,8 @@ list(REMOVE_ITEM CATACLYSM_BN_SOURCES ${MAIN_CPP} ${MESSAGES_CPP}) file(GLOB CATACLYSM_BN_HEADERS ${CMAKE_SOURCE_DIR}/src/*.h) if (LUA) - file(GLOB LUA_C_SOURCES ${CMAKE_SOURCE_DIR}/src/lua/*.c) -else () - set(LUA_C_SOURCES "") + add_subdirectory(lua) + add_subdirectory(sol) endif () # Get GIT version strings @@ -30,8 +29,7 @@ add_custom_command( # Build tiles version if requested if (TILES) - add_library(cataclysm-tiles-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS} - ${LUA_C_SOURCES}) + add_library(cataclysm-tiles-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS}) target_include_directories(cataclysm-tiles-common INTERFACE ${CMAKE_SOURCE_DIR}/src) if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") @@ -48,8 +46,7 @@ if (TILES) if (LUA) target_compile_definitions(cataclysm-tiles-common PUBLIC LUA) - target_include_directories(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/src) - target_include_directories(cataclysm-tiles-common PUBLIC ${CMAKE_SOURCE_DIR}/src/lua) + target_link_libraries(cataclysm-tiles-common PUBLIC libsol) endif () add_dependencies(cataclysm-tiles-common get_version) @@ -144,8 +141,7 @@ endif () # Build curses version if requested if (CURSES) - add_library(cataclysm-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS} - ${LUA_C_SOURCES}) + add_library(cataclysm-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS}) target_include_directories(cataclysm-common INTERFACE ${CMAKE_SOURCE_DIR}/src) if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") @@ -161,8 +157,7 @@ if (CURSES) if (LUA) target_compile_definitions(cataclysm-common PUBLIC LUA) - target_include_directories(cataclysm-common PUBLIC ${CMAKE_SOURCE_DIR}/src) - target_include_directories(cataclysm-common PUBLIC ${CMAKE_SOURCE_DIR}/src/lua) + target_link_libraries(cataclysm-common PUBLIC libsol) endif () add_dependencies(cataclysm-common get_version) diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt new file mode 100644 index 000000000000..c018b2307be3 --- /dev/null +++ b/src/lua/CMakeLists.txt @@ -0,0 +1,5 @@ +file(GLOB LUA_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c) +file(GLOB LUA_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) + +add_library(liblua ${LUA_SOURCES} ${LUA_HEADERS}) +target_include_directories(liblua PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/sol/CMakeLists.txt b/src/sol/CMakeLists.txt new file mode 100644 index 000000000000..bf0d06d9c381 --- /dev/null +++ b/src/sol/CMakeLists.txt @@ -0,0 +1,5 @@ +file(GLOB SOL_SOURCES sol/config.hpp sol/forward.hpp sol/sol.hpp) + +add_library(libsol INTERFACE ${SOL_SOURCES}) +target_include_directories(libsol INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(libsol INTERFACE liblua) diff --git a/src/sol/config.hpp b/src/sol/sol/config.hpp similarity index 100% rename from src/sol/config.hpp rename to src/sol/sol/config.hpp diff --git a/src/sol/forward.hpp b/src/sol/sol/forward.hpp similarity index 100% rename from src/sol/forward.hpp rename to src/sol/sol/forward.hpp diff --git a/src/sol/sol.hpp b/src/sol/sol/sol.hpp similarity index 100% rename from src/sol/sol.hpp rename to src/sol/sol/sol.hpp From 8413515a3b276c760b8b7805598a8ebd2148df01 Mon Sep 17 00:00:00 2001 From: Olanti Date: Wed, 25 Oct 2023 03:23:50 +0300 Subject: [PATCH 121/188] Makefile fix --- src/sol/CMakeLists.txt | 6 ++++-- src/sol/{sol => }/config.hpp | 0 src/sol/{sol => }/forward.hpp | 0 src/sol/{sol => }/sol.hpp | 0 4 files changed, 4 insertions(+), 2 deletions(-) rename src/sol/{sol => }/config.hpp (100%) rename src/sol/{sol => }/forward.hpp (100%) rename src/sol/{sol => }/sol.hpp (100%) diff --git a/src/sol/CMakeLists.txt b/src/sol/CMakeLists.txt index bf0d06d9c381..a4dfa73ae7ea 100644 --- a/src/sol/CMakeLists.txt +++ b/src/sol/CMakeLists.txt @@ -1,5 +1,7 @@ -file(GLOB SOL_SOURCES sol/config.hpp sol/forward.hpp sol/sol.hpp) +file(GLOB SOL_SOURCES config.hpp forward.hpp sol.hpp) add_library(libsol INTERFACE ${SOL_SOURCES}) -target_include_directories(libsol INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +# HACK: "/.." here is needed to avoid custom logic in Makefile. +# Get rid of it once we get rid of Make, and move sol sources into subdirectory. +target_include_directories(libsol INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..) target_link_libraries(libsol INTERFACE liblua) diff --git a/src/sol/sol/config.hpp b/src/sol/config.hpp similarity index 100% rename from src/sol/sol/config.hpp rename to src/sol/config.hpp diff --git a/src/sol/sol/forward.hpp b/src/sol/forward.hpp similarity index 100% rename from src/sol/sol/forward.hpp rename to src/sol/forward.hpp diff --git a/src/sol/sol/sol.hpp b/src/sol/sol.hpp similarity index 100% rename from src/sol/sol/sol.hpp rename to src/sol/sol.hpp From 3afd2038f27b71bb109544ccadc18fe3d5cb72b2 Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 01:48:54 +0300 Subject: [PATCH 122/188] Restore builtin-baseline in manifest --- msvc-full-features/vcpkg.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index 558eafe94d8c..2423d8406eac 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -12,5 +12,6 @@ "features": [ "libflac", "mpg123", "libmodplug" ] }, "sdl2-ttf" - ] + ], + "builtin-baseline": "5b1214315250939257ef5d62ecdcbca18cf4fb1c" } From 00391f4a219e448e29c13f4b2c251555a71f717e Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:30:12 +0200 Subject: [PATCH 123/188] Make USE_PREFIX_DATA_DIR option available to Unix only --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a3065f45364..8eb4b3c53616 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ include(AstyleFormatSource) set(CMAKE_TLS_VERIFY ON) # Build options +include(CMakeDependentOption) option(TILES "Build graphical tileset version." "OFF") option(CURSES "Build curses version." "ON") option(SOUND "Support for in-game sounds & music." "OFF") @@ -22,7 +23,9 @@ 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") -option(USE_PREFIX_DATA_DIR "Use UNIX system directories for game data in release build." "ON") +cmake_dependent_option(USE_PREFIX_DATA_DIR "Use UNIX system directories for game data in release build." ON + "UNIX" OFF +) set(LANGUAGES "" CACHE STRING "Compile localization files for specified languages. \ From fb672bbfc352c4e87e2f9d81904f1ba1c95cc687 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:34:00 +0200 Subject: [PATCH 124/188] Replace all system specific *_DIR with CMAKE_INSTALL_* --- CMakeLists.txt | 75 +++++++++++++++------------------------------ data/CMakeLists.txt | 4 +-- src/CMakeLists.txt | 11 ++++--- 3 files changed, 32 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eb4b3c53616..bc93693c4627 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,44 +156,7 @@ else () endif () endif () -# System specific actions -if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Linux|FreeBSD|Darwin)") - if (NOT DATA_PREFIX) - set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-bn) - endif () - if (NOT README_DIR) - set(README_DIR ${DATA_PREFIX}) - endif () - if (NOT BIN_PREFIX) - set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin) - endif () - if (NOT DESKTOP_ENTRY_PATH) - set(DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications) - endif () - if (NOT PIXMAPS_ENTRY_PATH) - set(PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) - endif () - if (NOT PIXMAPS_UNITY_ENTRY_PATH) - set(PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark) - endif () - if (NOT MANPAGE_ENTRY_PATH) - set(MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man) - endif () -endif () - -if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Windows|MSYS)") - if (NOT DATA_PREFIX) - set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/data) - endif () - if (NOT README_DIR) - set(README_DIR ${CMAKE_INSTALL_PREFIX}) - endif () - if (NOT BIN_PREFIX) - set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}) - endif () -endif () - -message(STATUS "${PROJECT_NAME} build options --\n") +message(STATUS "${PROJECT_NAME} build options --") # Preset variables if (NOT LANGUAGES) @@ -229,15 +192,21 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") # Since CataclysmBN 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}) + 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) + if(USE_PREFIX_DATA_DIR) + 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 "BIN_PREFIX : ${BIN_PREFIX}") - message(STATUS "DATA_PREFIX : ${DATA_PREFIX}") + message(STATUS "CMAKE_INSTALL_BINDIR : ${CMAKE_INSTALL_BINDIR}") 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}") @@ -482,9 +451,7 @@ if (CATA_CLANG_TIDY_PLUGIN) add_subdirectory(tools/clang-tidy-plugin) endif () -install(DIRECTORY doc gfx - DESTINATION ${DATA_PREFIX} -) +install(DIRECTORY doc TYPE DOC) if (RELEASE) install(FILES @@ -492,11 +459,17 @@ if (RELEASE) ${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt ${CMAKE_SOURCE_DIR}/VERSION.txt - DESTINATION ${README_DIR}) + TYPE DOC) if (TILES) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${DATA_PREFIX}) - endif() -endif() + 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" diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 0e506584854b..28e5e312f935 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -21,6 +21,6 @@ set(CATACLYSM_DATA_FILES ${CMAKE_SOURCE_DIR}/data/cataicon.ico) if (RELEASE) - install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) - install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) + install(DIRECTORY ${CATACLYSM_DATA_DIRS} TYPE DATA) + install(FILES ${CATACLYSM_DATA_FILES} TYPE DATA) endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85180f139ce2..1201150457d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -135,7 +135,7 @@ if (TILES) endif () if (RELEASE) - install(TARGETS cataclysm-tiles DESTINATION ${BIN_PREFIX}) + install(TARGETS cataclysm-tiles RUNTIME) endif () endif () @@ -192,7 +192,7 @@ if (CURSES) endif () if (RELEASE) - install(TARGETS cataclysm DESTINATION ${BIN_PREFIX}) + install(TARGETS cataclysm RUNTIME) endif () endif () @@ -266,9 +266,10 @@ if (MINGW AND NOT RELEASE) ${RuntimeLib_mpeg}) endif () endif () - - install(FILES ${RuntimeLib_GCC_ALL} ${RuntimeLib_SDL} ${RuntimeLib_SDL_SOUND} - DESTINATION ${BIN_PREFIX}) + install(FILES ${RuntimeLib_GCC_ALL} + ${RuntimeLib_SDL} + ${RuntimeLib_SDL_SOUND} + TYPE BIN) endif () # vim:noet From 40ab8f2e9322f77f44b8f11ee414f205f29a1594 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:35:35 +0200 Subject: [PATCH 125/188] Use relative paths, use list append command --- data/CMakeLists.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 28e5e312f935..c7c06b6f1ca7 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -2,23 +2,23 @@ cmake_minimum_required(VERSION 3.16) 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/help) + font + json + mods + names + raw + motd + credits + title + help) if (SOUND) - set(CATACLYSM_DATA_DIRS ${CATACLYSM_DATA_DIRS} ${CMAKE_SOURCE_DIR}/data/sound) + list(APPEND CATACLYSM_DATA_DIRS sound) endif () set(CATACLYSM_DATA_FILES - ${CMAKE_SOURCE_DIR}/data/changelog.txt - ${CMAKE_SOURCE_DIR}/data/cataicon.ico) + changelog.txt + cataicon.ico) if (RELEASE) install(DIRECTORY ${CATACLYSM_DATA_DIRS} TYPE DATA) From 1d0318b0e9205bb685d212dced067cad3dad7042 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:37:34 +0200 Subject: [PATCH 126/188] Configure prefix.h.in earlier --- CMakeLists.txt | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc93693c4627..0324e15c543d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,7 +198,16 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 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)") + 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 . ) @@ -210,19 +219,7 @@ else () 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 CMAKE_INSTALL_PREFIX as storage of data,gfx, etc.. Useful only on *nix OS. - if (CMAKE_INSTALL_PREFIX - AND NOT WIN32 - AND USE_PREFIX_DATA_DIR) - 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 () + message(STATUS "MANPAGE_ENTRY_PATH : ${MANPAGE_ENTRY_PATH}") endif () message(STATUS "GIT_BINARY : ${GIT_EXECUTABLE}") From 49a470a8320adfe265f5c84708c56cb557a2e433 Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:38:30 +0200 Subject: [PATCH 127/188] Compact presets. VCPKG_ROOT now an env variable --- CMakePresets.json | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index d3c484d59a99..a18fef09b22d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,18 +12,16 @@ "displayName": "Windows Tiles Sounds x64 MSVC", "description": "Target Windows (64-bit) with the Visual Studio development environment.", "generator": "Ninja Multi-Config", + "environment": { + "VCPKG_ROOT": "C:/vcpkg" + }, "cacheVariables": { "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake", "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", - "VCPKG_ROOT": "C:/vcpkg", - "DYNAMIC_LINKING": "False", - "RELEASE": "True", - "CURSES": "False", - "LOCALIZE": "True", - "TILES": "True", - "SOUND": "True", - "TESTS": "False" + "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", + "CMAKE_INSTALL_MESSAGE": "NEVER" } }, { @@ -32,17 +30,16 @@ "displayName": "Linux Tiles Sounds x64", "description": "Target Linux (64-bit) with the GCC development environment.", "generator": "Ninja Multi-Config", + "environment": { + "VCPKG_ROOT": "/usr/local/vcpkg" + }, "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "VCPKG_TARGET_TRIPLET": "x64-linux", - "CMAKE_TOOLCHAIN_FILE": "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake", - "VCPKG_MANIFEST_DIR": "msvc-full-features/", - "DYNAMIC_LINKING": "False", - "RELEASE": "True", - "CURSES": "False", - "LOCALIZE": "True", - "TILES": "True", - "SOUND": "True", - "TESTS": "False" + "VCPKG_MANIFEST_DIR": "${sourceDir}/msvc-full-features/", + "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", + "CMAKE_INSTALL_MESSAGE": "NEVER", } } ], From a881c121f2d67cb1b9c22972135ba5ecc172ddca Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:40:50 +0200 Subject: [PATCH 128/188] Remove cmake_minimum_required from subdirectories --- data/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index c7c06b6f1ca7..37ff7ac2519d 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,6 +1,3 @@ -# Cataclysm data files -cmake_minimum_required(VERSION 3.16) - set(CATACLYSM_DATA_DIRS font json From e7b14859411bc405185ae0859f235b6830c6d6ed Mon Sep 17 00:00:00 2001 From: alef Date: Sat, 13 May 2023 22:41:34 +0200 Subject: [PATCH 129/188] Reduce CMake configuration output for releases --- lang/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index 1175cd7ee517..a0148a65cfaf 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -24,7 +24,7 @@ if (LANGUAGES STREQUAL all) endif () foreach (LANG ${LANGUAGES}) - message(STATUS "Add translation for ${LANG}: ${LANG}.po") + message(VERBOSE "Add translation for ${LANG}: ${LANG}.po") endforeach () message("\n") From 5f5b577d6eae7b498d2b9c696eebe16d095de097 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 22 May 2023 18:59:25 +0200 Subject: [PATCH 130/188] Use pkg-config to help finding mostly static libraries The FindSDL2*.cmake modules create the *::*-static imported targets like VCPKG does. This way we can reuse the same names and reduce the complexity in the main and src CMakeLists.txt. --- CMakeLists.txt | 89 ++++++++++---------------- CMakeModules/Find/FindSDL2_image.cmake | 35 +++++++++- CMakeModules/Find/FindSDL2_mixer.cmake | 16 ++++- CMakeModules/Find/FindSDL2_ttf.cmake | 22 ++++++- src/CMakeLists.txt | 59 +++++------------ 5 files changed, 120 insertions(+), 101 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0324e15c543d..a06e1dac56a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,7 @@ include(CheckCXXCompilerFlag) #SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32") #SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32") +find_package(PkgConfig) if (NOT DYNAMIC_LINKING) if(NOT MSVC) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a") @@ -295,32 +296,26 @@ find_package(Threads REQUIRED) if (TILES) # Find SDL, SDL_ttf & SDL_image for graphical install message(STATUS "Searching for SDL2 library --") - find_package(SDL2) - if (NOT (SDL2_FOUND OR TARGET SDL2::SDL2)) - 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. \ - See CMake compiling guide for details and more info.") - endif () - - 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) + if (NOT CMAKE_FIND_PACKAGE_PREFER_CONFIG) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) # Use sdl2-config.cmake provided by the system or VCPKG + find_package(SDL2) + if(NOT SDL2_FOUND) + # Use our CMakeModules/Find/FindSDL2.cmake + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) + find_package(SDL2) + endif() + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) + endif() + if (NOT (SDL2_FOUND OR TARGET SDL2::SDL2 OR TARGET SDL2::SDL2-static)) + message(FATAL_ERROR + "This project requires SDL2 to be installed to compile in graphical mode. \ + Please install the SDL2 development libraries, \ + or try compiling without -DTILES=1 for a text-only compilation. \ + See CMake compiling guide for details and more info.") endif () message(STATUS "Searching for SDL2_TTF library --") - if (NOT VCPKG_MANIFEST_MODE) - find_package(SDL2_ttf) - else() - find_package(SDL2_ttf) - endif() + find_package(SDL2_ttf) if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) message( FATAL_ERROR @@ -330,19 +325,14 @@ if (TILES) See CMake compiling guide for details and more info.") endif () - message(STATUS "Searching for SDL2_image library --\n") - if(VCPKG_MANIFEST_MODE) - find_package(SDL2_image) - else() - find_package(SDL2_image) - endif() - if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2_image::SDL2_image-static)) - 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. \ - See CMake compiling guide for details and more info.") + message(STATUS "Searching for SDL2_image library --") + find_package(SDL2_image) + if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image OR TARGET SDL2_image::SDL2_image-static)) + message(FATAL_ERROR + "This project requires SDL2_image to be installed to compile in graphical mode. \ + Please install the SDL2_image development libraries, \ + or try compiling without -DTILES=1 for a text-only compilation. \ + See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") endif () add_definitions(-DTILES) endif () @@ -376,26 +366,13 @@ if (SOUND) endif () # Sound requires SDL_mixer library - if(VCPKG_MANIFEST_MODE) - message(STATUS "Searching for sdl2-mixer library --") - find_package(Ogg REQUIRED) - find_package(SDL2_mixer) - if (NOT (TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static)) - message(FATAL_ERROR - "You need the sdl2-mixer development library \ - to be able to compile with sound enabled. \ - See CMake compiling guide for details and more info.") - endif() - else() - message(STATUS "Searching for SDL2_mixer library --") - find_package(SDL2_mixer) - # if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static ? - if (NOT SDL2_MIXER_FOUND) - message(FATAL_ERROR - "You need the SDL2_mixer development library \ - to be able to compile with sound enabled. \ - See CMake compiling guide for details and more info.") - endif () + message(STATUS "Searching for SDL2_mixer library --") + find_package(SDL2_mixer) + if (NOT (SDL2_MIXER_FOUND OR TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static)) + message(FATAL_ERROR + "You need the SDL2_mixer development library \ + to be able to compile with sound enabled. \ + See CMake compiling guide for details and more info.") endif() endif () diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index d04518faaa66..215fd4f954d3 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -94,4 +94,37 @@ set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES}) set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS}) set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND}) -mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR) \ No newline at end of file +mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR) + +if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) + if (NOT TARGET SDL2_image:SDL2_image-static) + add_library(SDL2_image::SDL2_image-static STATIC IMPORTED) + set_property(TARGET SDL2_image::SDL2_image-static + PROPERTY IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} + ) + endif() + message(STATUS "Searching for SDL_images deps libraries --") + find_package(JPEG REQUIRED) + find_package(PNG REQUIRED) + find_package(TIFF REQUIRED) + find_library(JBIG jbig REQUIRED) + find_package(LibLZMA REQUIRED) + target_link_libraries(SDL2_image::SDL2_image-static INTERFACE + JPEG::JPEG + PNG::PNG + TIFF::TIFF + ${JBIG} + LibLZMA::LibLZMA + ${ZSTD} + ) + pkg_check_modules(WEBP REQUIRED IMPORTED_TARGET libwebp) + pkg_check_modules(ZIP REQUIRED IMPORTED_TARGET libzip) + pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET libzstd) + pkg_check_modules(DEFLATE REQUIRED IMPORTED_TARGET libdeflate) + target_link_libraries(SDL2_image::SDL2_image-static INTERFACE + PkgConfig::WEBP + PkgConfig::ZIP + PkgConfig::ZSTD + PkgConfig::DEFLATE + ) +endif() diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index 537719238e75..f4f68c08d43d 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -94,4 +94,18 @@ set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES}) set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS}) set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND}) -mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) \ No newline at end of file +mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) + +if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) + if (NOT TARGET SDL2_mixer::SDL2_mixer-static) + add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) + set_property(TARGET SDL2_mixer::SDL2_mixer-static + PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + ) + endif() + message(STATUS "Searching for SDL_mixer deps libraries --") + pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) + target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE + PkgConfig::FLAC + ) +endif() \ No newline at end of file diff --git a/CMakeModules/Find/FindSDL2_ttf.cmake b/CMakeModules/Find/FindSDL2_ttf.cmake index 733c667593cd..1dad88808be8 100644 --- a/CMakeModules/Find/FindSDL2_ttf.cmake +++ b/CMakeModules/Find/FindSDL2_ttf.cmake @@ -93,4 +93,24 @@ set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES}) set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS}) set(SDL2TTF_FOUND ${SDL2_TTF_FOUND}) -mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR) \ No newline at end of file +mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR) + +if (NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) + if (NOT TARGET SDL2_ttf::SDL2_ttf-static) + add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) + set_property(TARGET SDL2_ttf::SDL2_ttf-static + PROPERTY IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + ) + endif() + message(STATUS "Searching for SDL_ttf deps libraries --") + find_package(Freetype REQUIRED) + find_package(Harfbuzz REQUIRED) + target_link_libraries(SDL2_ttf::SDL2_ttf-static INTERFACE + Freetype::Freetype + harfbuzz::harfbuzz + ) + pkg_check_modules(BROTLI REQUIRED IMPORTED_TARGET libbrotlidec libbrotlicommon) + target_link_libraries(Freetype::Freetype INTERFACE + PkgConfig::BROTLI + ) +endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1201150457d1..22becac0115f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,51 +63,26 @@ if (TILES) endif () if (NOT DYNAMIC_LINKING) - # SDL, SDL_Image, SDL_ttf deps are required for static build - target_include_directories(cataclysm-tiles-common PUBLIC - ${FREETYPE_INCLUDE_DIRS} - ${PNG_INCLUDE_DIRS} - ${JPEG_INCLUDE_DIR} - ${BZIP2_INCLUDE_DIR}) - 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 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 + target_link_libraries(cataclysm-tiles-common PUBLIC + SDL2::SDL2-static SDL2_image::SDL2_image-static - SDL2_ttf::SDL2_ttf-static) - endif() + SDL2_ttf::SDL2_ttf-static + ) + else() + target_link_libraries(cataclysm-tiles-common PUBLIC + SDL2::SDL2 + SDL2_image::SDL2_image + SDL2_ttf::SDL2_ttf + ) + endif () if (SOUND) - if (VCPKG_MANIFEST_MODE) - find_package(Ogg REQUIRED) - # SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ? - find_package(Vorbis REQUIRED) - target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static - Ogg::ogg - Vorbis::vorbis) + if (NOT DYNAMIC_LINKING) + target_link_libraries(cataclysm-tiles-common PUBLIC + SDL2_mixer::SDL2_mixer-static + ) + else() + # TODO 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 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 PUBLIC ${SDL2_MIXER_LIBRARIES}) endif () if (WIN32) From 74ff612ab9a00fa2f20943af8d07e13776f2d03a Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 22 May 2023 19:12:00 +0200 Subject: [PATCH 131/188] Prefer MSBuild on Windows --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index a18fef09b22d..514aa64012fe 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -11,7 +11,7 @@ "binaryDir": "${sourceDir}/out/build/${presetName}", "displayName": "Windows Tiles Sounds x64 MSVC", "description": "Target Windows (64-bit) with the Visual Studio development environment.", - "generator": "Ninja Multi-Config", + "generator": "Visual Studio 16 2019", "environment": { "VCPKG_ROOT": "C:/vcpkg" }, From 9aa47d31059eba6bb8108346c98491f27c77c968 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 22 May 2023 19:14:44 +0200 Subject: [PATCH 132/188] Make Linux preset name refer to VCPKG The presets inherits from the configuration not using VCPKG --- CMakePresets.json | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 514aa64012fe..b60b8d7ccc64 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -30,16 +30,26 @@ "displayName": "Linux Tiles Sounds x64", "description": "Target Linux (64-bit) with the GCC development environment.", "generator": "Ninja Multi-Config", + "cacheVariables": { + "CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold", + "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", + "CMAKE_INSTALL_MESSAGE": "NEVER" + } + }, + { + "name": "linux-tiles-sounds-x64-vcpkg", + "inherits": ["linux-tiles-sounds-x64"], + "displayName": "Linux Tiles Sounds x64 VCPKG", + "description": "Target Linux (64-bit) with the GCC development environment and VCPKG.", + "generator": "Ninja Multi-Config", "environment": { "VCPKG_ROOT": "/usr/local/vcpkg" }, "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "VCPKG_TARGET_TRIPLET": "x64-linux", - "VCPKG_MANIFEST_DIR": "${sourceDir}/msvc-full-features/", - "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", - "CMAKE_INSTALL_MESSAGE": "NEVER", + "VCPKG_MANIFEST_DIR": "${sourceDir}/msvc-full-features/" } } ], @@ -47,6 +57,10 @@ { "name": "linux-tiles-sounds-x64", "configurePreset": "linux-tiles-sounds-x64" + }, + { + "name": "linux-tiles-sounds-x64-vcpkg", + "configurePreset": "linux-tiles-sounds-x64-vcpkg" } ] } From 30ca8715800c4e1972f5a2c553782d91b9c4b5f8 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 22 May 2023 19:16:41 +0200 Subject: [PATCH 133/188] Dynamically link SDL2_mixer --- CMakeLists.txt | 9 ++++++--- src/CMakeLists.txt | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a06e1dac56a5..62764caa15c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,8 @@ 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 +cmake_dependent_option(USE_PREFIX_DATA_DIR + "Use UNIX system directories for game data in release build." OFF "UNIX" OFF ) set(LANGUAGES @@ -297,7 +298,8 @@ if (TILES) # Find SDL, SDL_ttf & SDL_image for graphical install message(STATUS "Searching for SDL2 library --") if (NOT CMAKE_FIND_PACKAGE_PREFER_CONFIG) - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) # Use sdl2-config.cmake provided by the system or VCPKG + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + # ^^ Use sdl2-config.cmake provided by the system or VCPKG find_package(SDL2) if(NOT SDL2_FOUND) # Use our CMakeModules/Find/FindSDL2.cmake @@ -368,7 +370,8 @@ if (SOUND) # Sound requires SDL_mixer library message(STATUS "Searching for SDL2_mixer library --") find_package(SDL2_mixer) - if (NOT (SDL2_MIXER_FOUND OR TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static)) + if (NOT (SDL2_MIXER_FOUND OR TARGET SDL2_mixer::SDL2_mixer + OR TARGET SDL2_mixer::SDL2_mixer-static)) message(FATAL_ERROR "You need the SDL2_mixer development library \ to be able to compile with sound enabled. \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 22becac0115f..9891de4ab8c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,13 +63,13 @@ if (TILES) endif () if (NOT DYNAMIC_LINKING) - target_link_libraries(cataclysm-tiles-common PUBLIC + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2-static SDL2_image::SDL2_image-static SDL2_ttf::SDL2_ttf-static ) else() - target_link_libraries(cataclysm-tiles-common PUBLIC + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2 SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf @@ -78,10 +78,12 @@ if (TILES) if (SOUND) if (NOT DYNAMIC_LINKING) target_link_libraries(cataclysm-tiles-common PUBLIC - SDL2_mixer::SDL2_mixer-static + SDL2_mixer::SDL2_mixer-static ) else() - # TODO + target_link_libraries(cataclysm-tiles-common PUBLIC + SDL2_mixer::SDL2_mixer + ) endif() endif () From 3a70a4aa9abb6b81abc6e62bbdcaa756ecb4c57d Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 23 May 2023 22:41:04 +0200 Subject: [PATCH 134/188] Add a function to force an fs::path to a dir --- src/filesystem.cpp | 11 +++++++++++ src/filesystem.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index c23474b4c666..ac8ba7f1b757 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -82,7 +82,18 @@ bool file_exist( const std::string &path ) } #endif +template std::string as_norm_dir(const T& path) +{ + auto dir = std::filesystem::path(path) / std::filesystem::path{}; + auto norm = dir.lexically_normal(); + return norm.generic_u8string(); +} + +template std::string as_norm_dir(const std::filesystem::path&); +template std::string as_norm_dir(const std::string&); + #if defined(_WIN32) + bool remove_file( const std::string &path ) { return DeleteFileW( utf8_to_wstr( path ).c_str() ) != 0; diff --git a/src/filesystem.h b/src/filesystem.h index 86c5f6a7fb55..7645441310d0 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -60,6 +60,9 @@ std::string get_pid_string(); */ std::string read_entire_file( const std::string &path ); +/** Force 'path' to be a normalized directory */ +template std::string as_norm_dir(const T& path); + namespace cata_files { const char *eol(); From 3e4210f7fd383602b75cad0a7e2900981f4a22b3 Mon Sep 17 00:00:00 2001 From: alef Date: Tue, 23 May 2023 22:42:14 +0200 Subject: [PATCH 135/188] Use the normalized directory path --- src/filesystem.cpp | 9 +++------ src/filesystem.h | 2 +- src/main.cpp | 3 --- src/path_info.cpp | 11 ++--------- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index ac8ba7f1b757..9cc8c6548fdc 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -82,16 +82,13 @@ bool file_exist( const std::string &path ) } #endif -template std::string as_norm_dir(const T& path) +std::string as_norm_dir( const std::string &path ) { - auto dir = std::filesystem::path(path) / std::filesystem::path{}; - auto norm = dir.lexically_normal(); + std::filesystem::path dir = std::filesystem::u8path( path ) / std::filesystem::path{}; + std::filesystem::path norm = dir.lexically_normal(); return norm.generic_u8string(); } -template std::string as_norm_dir(const std::filesystem::path&); -template std::string as_norm_dir(const std::string&); - #if defined(_WIN32) bool remove_file( const std::string &path ) diff --git a/src/filesystem.h b/src/filesystem.h index 7645441310d0..f1fe675f842f 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -61,7 +61,7 @@ std::string get_pid_string(); std::string read_entire_file( const std::string &path ); /** Force 'path' to be a normalized directory */ -template std::string as_norm_dir(const T& path); +std::string as_norm_dir( const std::string &path ); namespace cata_files { diff --git a/src/main.cpp b/src/main.cpp index a1cfab0fc4a9..1402eaa4c79a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,9 +212,6 @@ int main( int argc, char *argv[] ) // On Android first launch, we copy all data files from the APK into the app's writeable folder so std::io stuff works. // Use the external storage so it's publicly modifiable data (so users can mess with installed data, save games etc.) std::string external_storage_path( SDL_AndroidGetExternalStoragePath() ); - if( external_storage_path.back() != '/' ) { - external_storage_path += '/'; - } PATH_INFO::init_base_path( external_storage_path ); #else diff --git a/src/path_info.cpp b/src/path_info.cpp index 88bbeea7e562..86c27b2fc255 100644 --- a/src/path_info.cpp +++ b/src/path_info.cpp @@ -38,14 +38,7 @@ static std::string memorialdir_value; void PATH_INFO::init_base_path( std::string path ) { - if( !path.empty() ) { - const char ch = path.back(); - if( ch != '/' && ch != '\\' ) { - path.push_back( '/' ); - } - } - - base_path_value = path; + base_path_value = as_norm_dir( path ); } void PATH_INFO::init_user_dir( std::string dir ) @@ -72,7 +65,7 @@ void PATH_INFO::init_user_dir( std::string dir ) #endif } - user_dir_value = dir; + user_dir_value = as_norm_dir( dir ); } void PATH_INFO::set_standard_filenames() From 3c6ea93519c5af122740c23123b0e057f5363d85 Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 24 May 2023 19:51:51 +0200 Subject: [PATCH 136/188] Add SDL2 targets for dynamic linking --- CMakeModules/Find/FindSDL2_image.cmake | 5 +++++ CMakeModules/Find/FindSDL2_mixer.cmake | 6 ++++++ CMakeModules/Find/FindSDL2_ttf.cmake | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index 215fd4f954d3..095841d2e5df 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -127,4 +127,9 @@ if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) PkgConfig::ZSTD PkgConfig::DEFLATE ) +elseif(NOT TARGET SDL2_image::SDL2_image) + add_library(SDL2_image::SDL2_image UNKNOWN IMPORTED) + set_property(TARGET SDL2_image::SDL2_image + PROPERTY IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} + ) endif() diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index f4f68c08d43d..3042b074c082 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -108,4 +108,10 @@ if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE PkgConfig::FLAC ) +elseif(NOT TARGET SDL2_mixer::SDL2_mixer) + add_library(SDL2_mixer::SDL2_mixer STATIC IMPORTED) + set_property(TARGET SDL2_mixer::SDL2_mixer + PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + ) + endif() \ No newline at end of file diff --git a/CMakeModules/Find/FindSDL2_ttf.cmake b/CMakeModules/Find/FindSDL2_ttf.cmake index 1dad88808be8..789db3b8df0e 100644 --- a/CMakeModules/Find/FindSDL2_ttf.cmake +++ b/CMakeModules/Find/FindSDL2_ttf.cmake @@ -113,4 +113,9 @@ if (NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) target_link_libraries(Freetype::Freetype INTERFACE PkgConfig::BROTLI ) +elseif(NOT TARGET SDL2_ttf::SDL2_ttf) + add_library(SDL2_ttf::SDL2_ttf UNKNOWN IMPORTED) + set_property(TARGET SDL2_ttf::SDL2_ttf + PROPERTY IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + ) endif() \ No newline at end of file From 03b27e4748f126d2d0bf4e700ad0eede193199bd Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 24 May 2023 20:17:24 +0200 Subject: [PATCH 137/188] Add more required libs to SDL2_image imported target --- CMakeModules/Find/FindSDL2_image.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index 095841d2e5df..61af122627aa 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -132,4 +132,9 @@ elseif(NOT TARGET SDL2_image::SDL2_image) set_property(TARGET SDL2_image::SDL2_image PROPERTY IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} ) + pkg_check_modules(ZIP REQUIRED IMPORTED_TARGET libzip) + target_link_libraries(SDL2_image::SDL2_image INTERFACE + PkgConfig::ZIP + z + ) endif() From 75b75518dd1b84628f676df6900990596ec263f6 Mon Sep 17 00:00:00 2001 From: alef Date: Wed, 24 May 2023 21:29:28 +0200 Subject: [PATCH 138/188] Removing libzip not required for dynamic linking --- CMakeModules/Find/FindSDL2_image.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index 61af122627aa..67e80b9f16e3 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -132,9 +132,7 @@ elseif(NOT TARGET SDL2_image::SDL2_image) set_property(TARGET SDL2_image::SDL2_image PROPERTY IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} ) - pkg_check_modules(ZIP REQUIRED IMPORTED_TARGET libzip) target_link_libraries(SDL2_image::SDL2_image INTERFACE - PkgConfig::ZIP z ) endif() From 7c2430a23a192d8cf20b0b3aad0e04f3edee6436 Mon Sep 17 00:00:00 2001 From: alef Date: Sun, 18 Jun 2023 21:33:03 +0200 Subject: [PATCH 139/188] Hotfix: Append a path delimiter for the 'dot' directory. --- src/filesystem.cpp | 6 +++++- src/main.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 9cc8c6548fdc..4595fdd2efb9 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -86,7 +86,11 @@ std::string as_norm_dir( const std::string &path ) { std::filesystem::path dir = std::filesystem::u8path( path ) / std::filesystem::path{}; std::filesystem::path norm = dir.lexically_normal(); - return norm.generic_u8string(); + std::string ret = norm.generic_u8string(); + if( "." == ret ) { + ret = "./"; // TODO Change the many places that use strings instead of paths + } + return ret; } #if defined(_WIN32) diff --git a/src/main.cpp b/src/main.cpp index 1402eaa4c79a..fd6fe53ae35b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -229,7 +229,7 @@ int main( int argc, char *argv[] ) # if defined(USE_HOME_DIR) || defined(USE_XDG_DIR) PATH_INFO::init_user_dir( "" ); # else - PATH_INFO::init_user_dir( "./" ); + PATH_INFO::init_user_dir( "." ); # endif #endif PATH_INFO::set_standard_filenames(); From 5a4ef868b01f8346874e513e3f0e94bdd33f75b2 Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Sat, 24 Jun 2023 21:48:15 -0400 Subject: [PATCH 140/188] Improve CMake behavior on Unix and macOS * Improve CMake behavior on Unix and macOS * Make USE_PREFIX_DATA_DIR on by default on unix --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62764caa15c9..031720bd229d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ 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." OFF + "Use UNIX system directories for game data in release build." ON "UNIX" OFF ) set(LANGUAGES @@ -203,6 +203,7 @@ else () # 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" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9891de4ab8c4..d7c6ca7b3c65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,6 +105,8 @@ if (TILES) target_link_libraries(cataclysm-tiles-common PUBLIC backtrace) endif () endif () + elseif (APPLE) + target_link_libraries(cataclysm-tiles-common PUBLIC "-framework CoreFoundation") endif () if (LIBBACKTRACE) @@ -162,6 +164,8 @@ if (CURSES) if (BACKTRACE) target_link_libraries(cataclysm-common PUBLIC dbghelp.lib) endif () + elseif (APPLE) + target_link_libraries(cataclysm-common PUBLIC "-framework CoreFoundation") endif () if (LIBBACKTRACE) From 1f2ee345ac85fc3b65299feb022639f63bb96948 Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 13:54:50 +0300 Subject: [PATCH 141/188] Disable lang install --- lang/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index a0148a65cfaf..b5ec789110f2 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -56,5 +56,5 @@ foreach (LANG ${LANGUAGES}) ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES/cataclysm-bn.mo WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) # FIXME: check if this works - install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${DATA_PREFIX}) + # install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${DATA_PREFIX}) endforeach () From a8e6c8b727dfde4d15f5c974d5a9483691633bc0 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:56:40 +0000 Subject: [PATCH 142/188] style(autofix.ci): automated formatting --- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 96 ++++++++++++++++---------- 1 file changed, 59 insertions(+), 37 deletions(-) diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md index d34eb77b0ff8..332794e137af 100644 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -1,9 +1,10 @@ # Disclaimer -**WARNING**: CMake build is **NOT** officially supported and should be used for *dev purposes ONLY*. +**WARNING**: CMake build is **NOT** officially supported and should be used for _dev purposes ONLY_. For the official way to build CataclysmDDA, see: - * [COMPILING.md](COMPILING.md) + +- [COMPILING.md](COMPILING.md) # Contents @@ -15,70 +16,91 @@ For the official way to build CataclysmDDA, see: # 1 Prerequisites -`cmake` >= 3.20.0
-`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) -`msgfmt` (optional) as part of Git Bash or msys2 in the default install paths. +`cmake` >= 3.20.0
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) `msgfmt` +(optional) as part of Git Bash or msys2 in the default install paths. + # 2 Configure ## Presets -The file `CMakePresets.json` contains all the presets.
-They will all build the code into the directory `out/build//`. + +The file `CMakePresets.json` contains all the presets.
They will all build the code into the +directory `out/build//`. ## vcpkg -If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one of the following: - * append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands - * set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout. - * edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path +If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one +of the following: + +- append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands +- set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout. +- edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path ## Visual Studio -The Standard toolbar shows the presets in the _Configuration_ drop-down box.
-From the main menu, select _Project -> Configure Cache_ -If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`. - * Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do not commit this change. +The Standard toolbar shows the presets in the _Configuration_ drop-down box.
From the main +menu, select _Project -> Configure Cache_ + +If you do not have `msgfmt` available, or do not want to include translations with the build, you +need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to +the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change +the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`. + +- Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do + not commit this change. ## Terminal + Run the command - * `cmake --list-presets`
-It will show the presets available to you. -The list changes based on the environment you are in. -If empty, the environment is not supported. + +- `cmake --list-presets`
It will show the presets available to you. The list changes based on + the environment you are in. If empty, the environment is not supported. Run the command - * `cmake --preset ` - - If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally pass `-DLOCALIZE=OFF`. - - * `cmake --preset -DLOCALIZE=OFF` - + +- `cmake --preset ` + +If you do not have `msgfmt` available, or do not want to include translations with the build, you +need to additionally pass `-DLOCALIZE=OFF`. + +- `cmake --preset -DLOCALIZE=OFF` + # 3 Build ## Visual Studio -From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.
-From the main menu, select _Build -> Build All_ + +From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.
From the +main menu, select _Build -> Build All_ ## Terminal + Run the command - * `cmake --build --preset ` + +- `cmake --build --preset ` # 4 Install ## Visual Studio + From the main menu, select _Build -> Install CataclysmDDA_ ## Terminal + Run the command - * `cmake --install out/build// --config RelWithDebInfo` + +- `cmake --install out/build// --config RelWithDebInfo` # 5 Run - ## Visual Studio -From the Standard toolbar's _Select Startup Item..._ drop-down menu select `cataclysm-tiles.exe (Install)`
-The _Project Configuration_ drop-down menu will show `RelWithDebInfo`.
-You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start Debugging_ (default F5). +## Visual Studio + +From the Standard toolbar's _Select Startup Item..._ drop-down menu select +`cataclysm-tiles.exe (Install)`
The _Project Configuration_ drop-down menu will show +`RelWithDebInfo`.
You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start +Debugging_ (default F5). + +## Terminal + +Run the commands - ## Terminal - Run the commands - * `cd out/install//` - * `cataclysm` or `cataclysm-tiles.exe` +- `cd out/install//` +- `cataclysm` or `cataclysm-tiles.exe` From 6b04e96f985df2231a0a89143236b91bf8cb8b0f Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 18:12:16 +0300 Subject: [PATCH 143/188] Enable Lua in presets --- CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index b60b8d7ccc64..a35e424b40af 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -20,7 +20,7 @@ "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", "CMAKE_INSTALL_MESSAGE": "NEVER" } }, @@ -33,7 +33,7 @@ "cacheVariables": { "CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold", "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "False", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", "CMAKE_INSTALL_MESSAGE": "NEVER" } }, From c060726f4814e97eff1545ee0d1f601bad423002 Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 14:15:54 +0300 Subject: [PATCH 144/188] Add CMake+MSVC build to CI --- .../workflows/msvc-full-features-cmake.yml | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/msvc-full-features-cmake.yml diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml new file mode 100644 index 000000000000..7591da96adc9 --- /dev/null +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -0,0 +1,100 @@ +name: Cataclysm Windows build (CMake + MSVC) + +on: + push: + branches: + - upload + paths-ignore: + - 'android/**' + - 'build-data/osx/**' + - 'doc/**' + - 'doxygen_doc/**' + - 'gfx/**' + - 'lang/**' + - 'lgtm/**' + - 'tools/**' + - '!tools/format/**' + - 'utilities/**' + - 'scripts/**' + pull_request: + branches: + - upload + paths-ignore: + - 'android/**' + - 'build-data/osx/**' + - 'doc/**' + - 'doxygen_doc/**' + - 'gfx/**' + - 'lang/**' + - 'lgtm/**' + - 'tools/**' + - '!tools/format/**' + - 'utilities/**' + - 'scripts/**' + +# We only care about the latest revision of a PR, so cancel previous instances. +concurrency: + group: msvc-cmake-build-${{ github.event.pull_request.number || github.ref_name }} + cancel-in-progress: true + +env: + # There's not enough disk space to build both release and debug versions of + # our dependencies, so we hack the triplet file to build only release versions + # Have to use github.workspace because runner namespace isn't available yet. + VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}\.github\vcpkg_triplets + ZSTD_CLEVEL: 17 + CMAKE_PRESET: windows-tiles-sounds-x64-msvc + +jobs: + build_catatclysm: + name: Build + runs-on: windows-2019 + if: github.event.pull_request.draft == false + + steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.3.1 + + - name: Install stable CMake + uses: lukka/get-cmake@latest + + - name: Install vcpkg + uses: lukka/run-vcpkg@v11 + id: runvcpkg + with: + vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' + vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' + + - name: Integrate vcpkg + run: | + vcpkg integrate install + + - uses: ammaraskar/msvc-problem-matcher@master + - name: Configure + run: | + cmake -DTESTS=ON --preset $env:CMAKE_PRESET + + - uses: ammaraskar/msvc-problem-matcher@master + - name: Build + run: | + cmake --build out/build/$env:CMAKE_PRESET + + - name: Dump logs if build failed + if: failure() + run: | + echo ================================================= + Get-ChildItem "${{ runner.workspace }}/Cataclysm-BN/out/build/$env:CMAKE_PRESET" -Recurse + echo ================================================= + + - name: Compile .mo files for localization + run: | + & "C:\msys64\mingw64\bin\mingw32-make" localization + + - name: Run tests + run: | + .\out\build\windows-tiles-sounds-x64-msvc\tests\Debug\cata_test-tiles.exe --rng-seed time From 2a036306f35a63cf45f45f444fbfe83a684d5bfb Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 15:07:00 +0300 Subject: [PATCH 145/188] Remove VCPKG_ROOT override --- CMakePresets.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index a35e424b40af..afffdf7651a2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,9 +12,6 @@ "displayName": "Windows Tiles Sounds x64 MSVC", "description": "Target Windows (64-bit) with the Visual Studio development environment.", "generator": "Visual Studio 16 2019", - "environment": { - "VCPKG_ROOT": "C:/vcpkg" - }, "cacheVariables": { "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake", "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", From a16d258029aa0c75498b2b5722a7928493f8fd99 Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 22:41:15 +0300 Subject: [PATCH 146/188] Remove Strawberry Pearl from PATH --- .github/workflows/msvc-full-features-cmake.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index 7591da96adc9..447cfd91ddc4 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -60,6 +60,17 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.3.1 + - name: Remove Strawberry Perl from PATH + run: | + echo $env:PATH + echo ========================= + $env:PATH = $env:PATH -replace "C:\\Strawberry\\c\\bin;", "" + $env:PATH = $env:PATH -replace "C:\\Strawberry\\perl\\site\\bin;", "" + $env:PATH = $env:PATH -replace "C:\\Strawberry\\perl\\bin;", "" + "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Append + echo ========================= + echo $env:PATH + - name: Install stable CMake uses: lukka/get-cmake@latest From 1aafdda149d6c90b8a2aed316de33d57d67d7b5c Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 26 Oct 2023 23:00:11 +0300 Subject: [PATCH 147/188] Add freetype overlay port --- .../vcpkg_ports/freetype/0003-Fix-UWP.patch | 65 ++++++++++++++ .../vcpkg_ports/freetype/brotli-static.patch | 25 ++++++ .github/vcpkg_ports/freetype/bzip2.patch | 13 +++ .../vcpkg_ports/freetype/error-strings.patch | 37 ++++++++ .../vcpkg_ports/freetype/fix-exports.patch | 40 +++++++++ .github/vcpkg_ports/freetype/portfile.cmake | 85 +++++++++++++++++++ .github/vcpkg_ports/freetype/usage | 4 + .../freetype/vcpkg-cmake-wrapper.cmake | 64 ++++++++++++++ .github/vcpkg_ports/freetype/vcpkg.json | 53 ++++++++++++ msvc-full-features/vcpkg.json | 7 +- 10 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 .github/vcpkg_ports/freetype/0003-Fix-UWP.patch create mode 100644 .github/vcpkg_ports/freetype/brotli-static.patch create mode 100644 .github/vcpkg_ports/freetype/bzip2.patch create mode 100644 .github/vcpkg_ports/freetype/error-strings.patch create mode 100644 .github/vcpkg_ports/freetype/fix-exports.patch create mode 100644 .github/vcpkg_ports/freetype/portfile.cmake create mode 100644 .github/vcpkg_ports/freetype/usage create mode 100644 .github/vcpkg_ports/freetype/vcpkg-cmake-wrapper.cmake create mode 100644 .github/vcpkg_ports/freetype/vcpkg.json diff --git a/.github/vcpkg_ports/freetype/0003-Fix-UWP.patch b/.github/vcpkg_ports/freetype/0003-Fix-UWP.patch new file mode 100644 index 000000000000..4beb8d5ec7ab --- /dev/null +++ b/.github/vcpkg_ports/freetype/0003-Fix-UWP.patch @@ -0,0 +1,65 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index db48e9f..5c35276 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -328,6 +328,10 @@ else () + list(APPEND BASE_SRCS src/base/ftdebug.c) + endif () + ++if(MSVC) ++ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) ++endif() ++ + if (BUILD_FRAMEWORK) + list(APPEND BASE_SRCS builds/mac/freetype-Info.plist) + endif () +diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h +index 4f2eaca..1e01fe4 100644 +--- a/include/freetype/freetype.h ++++ b/include/freetype/freetype.h +@@ -1038,6 +1038,11 @@ FT_BEGIN_HEADER + * Especially for TrueType fonts see also the documentation for + * @FT_Size_Metrics. + */ ++ ++#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) ++#define generic GenericFromFreeTypeLibrary ++#endif ++ + typedef struct FT_FaceRec_ + { + FT_Long num_faces; +@@ -1910,6 +1915,9 @@ FT_BEGIN_HEADER + + } FT_GlyphSlotRec; + ++#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) ++#undef generic ++#endif + + /*************************************************************************/ + /*************************************************************************/ +diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c +index 3f8619d..edf03b6 100644 +--- a/src/base/ftobjs.c ++++ b/src/base/ftobjs.c +@@ -528,6 +528,9 @@ + return error; + } + ++#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) ++#define generic GenericFromFreeTypeLibrary ++#endif + + static void + ft_glyphslot_clear( FT_GlyphSlot slot ) +@@ -1195,6 +1198,9 @@ + FT_FREE( face ); + } + ++#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) ++#undef generic ++#endif + + static void + Destroy_Driver( FT_Driver driver ) diff --git a/.github/vcpkg_ports/freetype/brotli-static.patch b/.github/vcpkg_ports/freetype/brotli-static.patch new file mode 100644 index 000000000000..3ab8624fb46a --- /dev/null +++ b/.github/vcpkg_ports/freetype/brotli-static.patch @@ -0,0 +1,25 @@ +diff --git a/builds/cmake/FindBrotliDec.cmake b/builds/cmake/FindBrotliDec.cmake +index 46356b1fd..ed4cc2409 100644 +--- a/builds/cmake/FindBrotliDec.cmake ++++ b/builds/cmake/FindBrotliDec.cmake +@@ -35,10 +35,19 @@ find_path(BROTLIDEC_INCLUDE_DIRS + PATH_SUFFIXES brotli) + + find_library(BROTLIDEC_LIBRARIES +- NAMES brotlidec ++ NAMES brotlidec brotlidec-static NAMES_PER_DIR + HINTS ${PC_BROTLIDEC_LIBDIR} + ${PC_BROTLIDEC_LIBRARY_DIRS}) + ++get_filename_component(z_vcpkg_freetype_brotlidec_name "${BROTLIDEC_LIBRARIES}" NAME) ++if(z_vcpkg_freetype_brotlidec_name MATCHES "-static") ++ find_library(BROTLICOMMON_LIBRARIES ++ NAMES brotlicommon-static ++ HINTS ${PC_BROTLIDEC_LIBDIR} ++ ${PC_BROTLIDEC_LIBRARY_DIRS}) ++ set(BROTLIDEC_LIBRARIES "${BROTLIDEC_LIBRARIES};${BROTLICOMMON_LIBRARIES}") ++endif() ++unset(z_vcpkg_freetype_brotlidec_name) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( diff --git a/.github/vcpkg_ports/freetype/bzip2.patch b/.github/vcpkg_ports/freetype/bzip2.patch new file mode 100644 index 000000000000..a73f5c122413 --- /dev/null +++ b/.github/vcpkg_ports/freetype/bzip2.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 469a141a2..eec19c7d0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -517,7 +517,7 @@ if (BZIP2_FOUND) + if (PC_BZIP2_FOUND) + list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2") + else () +- list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2") ++ list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2") + endif () + endif () + if (PNG_FOUND) diff --git a/.github/vcpkg_ports/freetype/error-strings.patch b/.github/vcpkg_ports/freetype/error-strings.patch new file mode 100644 index 000000000000..df1e51bdfef3 --- /dev/null +++ b/.github/vcpkg_ports/freetype/error-strings.patch @@ -0,0 +1,37 @@ +From 5672a353682a68cb76a03179739bdec0a2f5cf0e Mon Sep 17 00:00:00 2001 +From: Sean Farrell +Date: Fri, 19 Aug 2022 15:32:19 +0200 +Subject: [PATCH] Adds config support for error strings. + +--- + CMakeLists.txt | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index feb4be39a..4eea860e8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -215,6 +215,8 @@ cmake_dependent_option(FT_REQUIRE_BROTLI + "Require support of compressed WOFF2 fonts." OFF + "NOT FT_DISABLE_BROTLI" OFF) + ++option(FT_ENABLE_ERROR_STRINGS ++ "Enable support for meaningful error descriptions" OFF) + + # Disallow in-source builds + if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") +@@ -353,6 +355,11 @@ if (BROTLIDEC_FOUND) + "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1" + FTOPTION_H "${FTOPTION_H}") + endif () ++if (FT_ENABLE_ERROR_STRINGS) ++ string(REGEX REPLACE ++ "/\\* +(#define +FT_CONFIG_OPTION_ERROR_STRINGS) +\\*/" "\\1" ++ FTOPTION_H "${FTOPTION_H}") ++endif () + + set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") + if (EXISTS "${FTOPTION_H_NAME}") +-- +2.33.0.windows.2 + diff --git a/.github/vcpkg_ports/freetype/fix-exports.patch b/.github/vcpkg_ports/freetype/fix-exports.patch new file mode 100644 index 000000000000..ee55ec63e886 --- /dev/null +++ b/.github/vcpkg_ports/freetype/fix-exports.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cb1b9a0f2..edca5d579 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -508,7 +508,6 @@ set(PKG_CONFIG_REQUIRED_PRIVATE "") + set(PKGCONFIG_LIBS_PRIVATE "") + + if (ZLIB_FOUND) +- target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES}) ++ target_link_libraries(freetype PRIVATE ZLIB::ZLIB) +- target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS}) + list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib") + endif () +@@ -596,12 +596,25 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) + install( + EXPORT freetype-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype +- FILE freetype-config.cmake + COMPONENT headers) + install( + FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype + COMPONENT headers) ++ ++ if(ZLIB_FOUND) ++ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake" ++[[include(CMakeFindDependencyMacro) ++find_dependency(ZLIB) ++include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake") ++]]) ++ else() ++ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake" ++[[include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake") ++]]) ++ endif() ++ ++ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype) + endif () + + diff --git a/.github/vcpkg_ports/freetype/portfile.cmake b/.github/vcpkg_ports/freetype/portfile.cmake new file mode 100644 index 000000000000..6bba8eaf0bb0 --- /dev/null +++ b/.github/vcpkg_ports/freetype/portfile.cmake @@ -0,0 +1,85 @@ +set(FT_VERSION 2.12.1) + +vcpkg_from_sourceforge( + OUT_SOURCE_PATH SOURCE_PATH + REPO freetype/freetype2 + REF ${FT_VERSION} + FILENAME freetype-${FT_VERSION}.tar.xz + SHA512 6482de1748dc2cc01e033d21a3b492dadb1f039d13d9179685fdcf985e24d7f587cbca4c27ed8a7fdb7d9ad59612642ac5f4db062443154753295363f45c052f + PATCHES + 0003-Fix-UWP.patch + brotli-static.patch + bzip2.patch + fix-exports.patch + error-strings.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + zlib FT_REQUIRE_ZLIB + bzip2 FT_REQUIRE_BZIP2 + error-strings FT_ENABLE_ERROR_STRINGS + png FT_REQUIRE_PNG + brotli FT_REQUIRE_BROTLI + INVERTED_FEATURES + zlib FT_DISABLE_ZLIB + bzip2 FT_DISABLE_BZIP2 + png FT_DISABLE_PNG + brotli FT_DISABLE_BROTLI +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DFT_DISABLE_HARFBUZZ=ON + ${FEATURE_OPTIONS} +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/freetype) + +# Rename for easy usage (VS integration; CMake and autotools will not care) +file(RENAME "${CURRENT_PACKAGES_DIR}/include/freetype2/freetype" "${CURRENT_PACKAGES_DIR}/include/freetype") +file(RENAME "${CURRENT_PACKAGES_DIR}/include/freetype2/ft2build.h" "${CURRENT_PACKAGES_DIR}/include/ft2build.h") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/freetype2") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +# Fix the include dir [freetype2 -> freetype] +file(READ "${CURRENT_PACKAGES_DIR}/share/freetype/freetype-targets.cmake" CONFIG_MODULE) +string(REPLACE "\${_IMPORT_PREFIX}/include/freetype2" "\${_IMPORT_PREFIX}/include" CONFIG_MODULE "${CONFIG_MODULE}") +string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlicommon-static.lib" [[\$<\$>:${_IMPORT_PREFIX}/lib/brotlicommon-static.lib>;\$<\$:${_IMPORT_PREFIX}/debug/lib/brotlicommon-static.lib>]] CONFIG_MODULE "${CONFIG_MODULE}") +string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec-static.lib" [[\$<\$>:${_IMPORT_PREFIX}/lib/brotlidec-static.lib>;\$<\$:${_IMPORT_PREFIX}/debug/lib/brotlidec-static.lib>]] CONFIG_MODULE "${CONFIG_MODULE}") +string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec.lib" [[\$<\$>:${_IMPORT_PREFIX}/lib/brotlidec.lib>;\$<\$:${_IMPORT_PREFIX}/debug/lib/brotlidec.lib>]] CONFIG_MODULE "${CONFIG_MODULE}") +string(REPLACE "\${_IMPORT_PREFIX}/lib/brotlidec.lib" [[\$<\$>:${_IMPORT_PREFIX}/lib/brotlidec.lib>;\$<\$:${_IMPORT_PREFIX}/debug/lib/brotlidec.lib>]] CONFIG_MODULE "${CONFIG_MODULE}") +file(WRITE ${CURRENT_PACKAGES_DIR}/share/freetype/freetype-targets.cmake "${CONFIG_MODULE}") + +find_library(FREETYPE_DEBUG NAMES freetyped PATHS "${CURRENT_PACKAGES_DIR}/debug/lib/" NO_DEFAULT_PATH) +if(NOT VCPKG_BUILD_TYPE) + file(READ "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/freetype2.pc" _contents) + if(FREETYPE_DEBUG) + string(REPLACE "-lfreetype" "-lfreetyped" _contents "${_contents}") + endif() + string(REPLACE "-I\${includedir}/freetype2" "-I\${includedir}" _contents "${_contents}") + file(WRITE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/freetype2.pc" "${_contents}") +endif() + +file(READ "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/freetype2.pc" _contents) +string(REPLACE "-I\${includedir}/freetype2" "-I\${includedir}" _contents "${_contents}") +file(WRITE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/freetype2.pc" "${_contents}") + + +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" + "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright( + FILE_LIST + "${SOURCE_PATH}/LICENSE.TXT" + "${SOURCE_PATH}/docs/FTL.TXT" + "${SOURCE_PATH}/docs/GPLv2.TXT" +) diff --git a/.github/vcpkg_ports/freetype/usage b/.github/vcpkg_ports/freetype/usage new file mode 100644 index 000000000000..00cf65d30eaa --- /dev/null +++ b/.github/vcpkg_ports/freetype/usage @@ -0,0 +1,4 @@ +freetype is compatible with built-in CMake targets: + + find_package(Freetype REQUIRED) + target_link_libraries(main PRIVATE Freetype::Freetype) # since CMake 3.10 diff --git a/.github/vcpkg_ports/freetype/vcpkg-cmake-wrapper.cmake b/.github/vcpkg_ports/freetype/vcpkg-cmake-wrapper.cmake new file mode 100644 index 000000000000..ee332c3c6f29 --- /dev/null +++ b/.github/vcpkg_ports/freetype/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,64 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0054 NEW) + +_find_package(${ARGS}) + +if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + if("@FT_REQUIRE_ZLIB@") + find_package(ZLIB) + endif() + if("@FT_REQUIRE_BZIP2@") + find_package(BZip2) + endif() + if("@FT_REQUIRE_PNG@") + find_package(PNG) + endif() + if("@FT_REQUIRE_BROTLI@") + find_library(BROTLIDEC_LIBRARY_RELEASE NAMES brotlidec brotlidec-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH) + find_library(BROTLIDEC_LIBRARY_DEBUG NAMES brotlidec brotlidec-static brotlidecd brotlidec-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH) + find_library(BROTLICOMMON_LIBRARY_RELEASE NAMES brotlicommon brotlicommon-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH) + find_library(BROTLICOMMON_LIBRARY_DEBUG NAMES brotlicommon brotlicommon-static brotlicommond brotlicommon-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH) + include(SelectLibraryConfigurations) + select_library_configurations(BROTLIDEC) + select_library_configurations(BROTLICOMMON) + endif("@FT_REQUIRE_BROTLI@") + + if(TARGET Freetype::Freetype) + if("@FT_REQUIRE_ZLIB@") + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) + endif() + if("@FT_REQUIRE_BZIP2@") + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2) + endif() + if("@FT_REQUIRE_PNG@") + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES PNG::PNG) + endif() + if("@FT_REQUIRE_BROTLI@") + if(BROTLIDEC_LIBRARY_DEBUG) + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$:${BROTLIDEC_LIBRARY_DEBUG}>") + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$:${BROTLICOMMON_LIBRARY_DEBUG}>") + endif() + if(BROTLIDEC_LIBRARY_RELEASE) + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$>:${BROTLIDEC_LIBRARY_RELEASE}>") + set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES "\$<\$>:${BROTLICOMMON_LIBRARY_RELEASE}>") + endif() + endif() + endif() + + if(FREETYPE_LIBRARIES) + if("@FT_REQUIRE_ZLIB@") + list(APPEND FREETYPE_LIBRARIES ${ZLIB_LIBRARIES}) + endif() + if("@FT_REQUIRE_BZIP2@") + list(APPEND FREETYPE_LIBRARIES ${BZIP2_LIBRARIES}) + endif() + if("@FT_REQUIRE_PNG@") + list(APPEND FREETYPE_LIBRARIES ${PNG_LIBRARIES}) + endif() + if("@FT_REQUIRE_BROTLI@") + list(APPEND FREETYPE_LIBRARIES ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES}) + endif() + endif() +endif() +cmake_policy(POP) diff --git a/.github/vcpkg_ports/freetype/vcpkg.json b/.github/vcpkg_ports/freetype/vcpkg.json new file mode 100644 index 000000000000..42639756f952 --- /dev/null +++ b/.github/vcpkg_ports/freetype/vcpkg.json @@ -0,0 +1,53 @@ +{ + "name": "freetype", + "version": "2.12.1", + "port-version": 3, + "description": "A library to render fonts.", + "homepage": "https://www.freetype.org/", + "license": "FTL OR GPL-2.0-or-later", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "brotli", + "bzip2", + "png", + "zlib" + ], + "features": { + "brotli": { + "description": "Support decompression of WOFF2 streams", + "dependencies": [ + "brotli" + ] + }, + "bzip2": { + "description": "Support bzip2 compressed fonts.", + "dependencies": [ + "bzip2" + ] + }, + "error-strings": { + "description": "Enable support for meaningful error descriptions." + }, + "png": { + "description": "Support PNG compressed OpenType embedded bitmaps.", + "dependencies": [ + "libpng" + ] + }, + "zlib": { + "description": "Use zlib instead of internal library for DEFLATE", + "dependencies": [ + "zlib" + ] + } + } +} diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index 2423d8406eac..7cc2bbae92b1 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -13,5 +13,10 @@ }, "sdl2-ttf" ], - "builtin-baseline": "5b1214315250939257ef5d62ecdcbca18cf4fb1c" + "builtin-baseline": "5b1214315250939257ef5d62ecdcbca18cf4fb1c", + "vcpkg-configuration": { + "overlay-ports": [ + "../.github/vcpkg_ports" + ] + } } From 850a4112e3f60b741db3f453f09ba4fcc72c5791 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 13:13:41 +0300 Subject: [PATCH 148/188] Remove brotli feature from freetype --- .github/vcpkg_ports/freetype/vcpkg.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/vcpkg_ports/freetype/vcpkg.json b/.github/vcpkg_ports/freetype/vcpkg.json index 42639756f952..17ec99ece521 100644 --- a/.github/vcpkg_ports/freetype/vcpkg.json +++ b/.github/vcpkg_ports/freetype/vcpkg.json @@ -16,7 +16,6 @@ } ], "default-features": [ - "brotli", "bzip2", "png", "zlib" From 82eaf9d87a044f6bf7b64400d32ddc2320e84b60 Mon Sep 17 00:00:00 2001 From: alef Date: Mon, 25 Sep 2023 06:41:19 +0200 Subject: [PATCH 149/188] Small fixes in CMake build in Linux * Resolve more dependencies * Use dynamic linking for non-VCPKG configuration * Fix typo for pkg-config * Link FLAC libraries for dynamic linking too --- CMakeModules/Find/FindSDL2_image.cmake | 2 +- CMakeModules/Find/FindSDL2_mixer.cmake | 22 +++++++++++++++------- CMakeModules/Find/FindSDL2_ttf.cmake | 2 +- CMakePresets.json | 1 - 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index 67e80b9f16e3..e85855075482 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -96,7 +96,7 @@ set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND}) mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR) -if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) +if(NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND) if (NOT TARGET SDL2_image:SDL2_image-static) add_library(SDL2_image::SDL2_image-static STATIC IMPORTED) set_property(TARGET SDL2_image::SDL2_image-static diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index 3042b074c082..469c7ea4591b 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -96,22 +96,30 @@ set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND}) mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) -if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) +if(NOT DYNAMIC_LINKING) if (NOT TARGET SDL2_mixer::SDL2_mixer-static) add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) set_property(TARGET SDL2_mixer::SDL2_mixer-static PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} ) endif() - message(STATUS "Searching for SDL_mixer deps libraries --") - pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) - target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE - PkgConfig::FLAC - ) elseif(NOT TARGET SDL2_mixer::SDL2_mixer) add_library(SDL2_mixer::SDL2_mixer STATIC IMPORTED) set_property(TARGET SDL2_mixer::SDL2_mixer PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} ) +endif() -endif() \ No newline at end of file +if(PKG_CONFIG_FOUND) + message(STATUS "Searching for SDL_mixer deps libraries --") + pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) + if(TARGET SDL2_mixer::SDL2_mixer-static) + target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE + PkgConfig::FLAC + ) + elseif(TARGET SDL2_mixer::SDL2_mixer) + target_link_libraries(SDL2_mixer::SDL2_mixer INTERFACE + PkgConfig::FLAC + ) + endif() +endif() diff --git a/CMakeModules/Find/FindSDL2_ttf.cmake b/CMakeModules/Find/FindSDL2_ttf.cmake index 789db3b8df0e..7e9e88407323 100644 --- a/CMakeModules/Find/FindSDL2_ttf.cmake +++ b/CMakeModules/Find/FindSDL2_ttf.cmake @@ -95,7 +95,7 @@ set(SDL2TTF_FOUND ${SDL2_TTF_FOUND}) mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR) -if (NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) +if (NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND) if (NOT TARGET SDL2_ttf::SDL2_ttf-static) add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) set_property(TARGET SDL2_ttf::SDL2_ttf-static diff --git a/CMakePresets.json b/CMakePresets.json index afffdf7651a2..a6b4d2c21d44 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -28,7 +28,6 @@ "description": "Target Linux (64-bit) with the GCC development environment.", "generator": "Ninja Multi-Config", "cacheVariables": { - "CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold", "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", "CMAKE_INSTALL_MESSAGE": "NEVER" From f6027de1bcf9d918bdf41070c1c2fb2030ce26e3 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 28 Sep 2023 23:08:31 +0200 Subject: [PATCH 150/188] Add INTERFACE_INCLUDE_DIRECTORIES to SDL2 targets --- CMakeModules/Find/FindSDL2_image.cmake | 5 +++-- CMakeModules/Find/FindSDL2_mixer.cmake | 10 ++++++---- CMakeModules/Find/FindSDL2_ttf.cmake | 10 ++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeModules/Find/FindSDL2_image.cmake b/CMakeModules/Find/FindSDL2_image.cmake index e85855075482..f42a15176c03 100644 --- a/CMakeModules/Find/FindSDL2_image.cmake +++ b/CMakeModules/Find/FindSDL2_image.cmake @@ -129,8 +129,9 @@ if(NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND) ) elseif(NOT TARGET SDL2_image::SDL2_image) add_library(SDL2_image::SDL2_image UNKNOWN IMPORTED) - set_property(TARGET SDL2_image::SDL2_image - PROPERTY IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} + set_target_properties(SDL2_image::SDL2_image PROPERTIES + IMPORTED_LOCATION ${SDL2_IMAGE_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_IMAGE_INCLUDE_DIRS} ) target_link_libraries(SDL2_image::SDL2_image INTERFACE z diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index 469c7ea4591b..f75c50da6442 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -99,14 +99,16 @@ mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) if(NOT DYNAMIC_LINKING) if (NOT TARGET SDL2_mixer::SDL2_mixer-static) add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) - set_property(TARGET SDL2_mixer::SDL2_mixer-static - PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + set_target_properties(SDL2_mixer::SDL2_mixer-static PROPERTIES + IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_MIXER_INCLUDE_DIRS} ) endif() elseif(NOT TARGET SDL2_mixer::SDL2_mixer) add_library(SDL2_mixer::SDL2_mixer STATIC IMPORTED) - set_property(TARGET SDL2_mixer::SDL2_mixer - PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + set_target_properties(SDL2_mixer::SDL2_mixer PROPERTIES + IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_MIXER_INCLUDE_DIRS} ) endif() diff --git a/CMakeModules/Find/FindSDL2_ttf.cmake b/CMakeModules/Find/FindSDL2_ttf.cmake index 7e9e88407323..1bddc196f486 100644 --- a/CMakeModules/Find/FindSDL2_ttf.cmake +++ b/CMakeModules/Find/FindSDL2_ttf.cmake @@ -98,8 +98,9 @@ mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR) if (NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND) if (NOT TARGET SDL2_ttf::SDL2_ttf-static) add_library(SDL2_ttf::SDL2_ttf-static STATIC IMPORTED) - set_property(TARGET SDL2_ttf::SDL2_ttf-static - PROPERTY IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + set_target_properties(SDL2_ttf::SDL2_ttf-static PROPERTIES + IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_TTF_INCLUDE_DIRS} ) endif() message(STATUS "Searching for SDL_ttf deps libraries --") @@ -115,7 +116,8 @@ if (NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND) ) elseif(NOT TARGET SDL2_ttf::SDL2_ttf) add_library(SDL2_ttf::SDL2_ttf UNKNOWN IMPORTED) - set_property(TARGET SDL2_ttf::SDL2_ttf - PROPERTY IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + set_target_properties(SDL2_ttf::SDL2_ttf PROPERTIES + IMPORTED_LOCATION ${SDL2_TTF_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_TTF_INCLUDE_DIRS} ) endif() \ No newline at end of file From c7bc48166d1d2b7382f29c5896321dff90a19e98 Mon Sep 17 00:00:00 2001 From: alef Date: Thu, 28 Sep 2023 23:09:07 +0200 Subject: [PATCH 151/188] Move pkg-config required FLAC dependency inside conditions --- CMakeModules/Find/FindSDL2_mixer.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index f75c50da6442..e14a1557f42b 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -114,12 +114,13 @@ endif() if(PKG_CONFIG_FOUND) message(STATUS "Searching for SDL_mixer deps libraries --") - pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) if(TARGET SDL2_mixer::SDL2_mixer-static) + pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE PkgConfig::FLAC ) elseif(TARGET SDL2_mixer::SDL2_mixer) + pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) target_link_libraries(SDL2_mixer::SDL2_mixer INTERFACE PkgConfig::FLAC ) From 4f9fea5b232cf6854893376c07d0599c1153d31f Mon Sep 17 00:00:00 2001 From: akrieger Date: Mon, 25 Sep 2023 19:40:18 -0700 Subject: [PATCH 152/188] Fix clang-tidy workflow by installing 'required' libflac-dev --- .github/workflows/clang-tidy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 0bee8ce9fdb3..9265de0c9ae5 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -51,7 +51,7 @@ jobs: sudo apt-get update sudo apt-get install libncursesw5-dev clang-12 libclang-12-dev llvm-12-dev llvm-12-tools \ libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev ccache \ - gettext + libflac-dev gettext - name: prepare run: bash ./build-scripts/requirements.sh From 47902ee6842c5b1502e748b899709991ef3b2aa6 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 13:52:05 +0300 Subject: [PATCH 153/188] Add libflac to matrix --- .github/workflows/matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml index 21108d416695..d7b7c08f4c46 100644 --- a/.github/workflows/matrix.yml +++ b/.github/workflows/matrix.yml @@ -190,7 +190,7 @@ jobs: - name: install SDL2 dependencies (ubuntu) if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && matrix.tiles == 1 }} run: | - sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev + sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev libflac-dev - name: check compiler (mac) if: ${{ env.SKIP == 'false' && runner.os == 'macOS' }} From 831b37186793301da847a3ceb712084d109bccb1 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 15:59:35 +0300 Subject: [PATCH 154/188] Fix merge mistakes and style differences --- CMakeLists.txt | 129 ++++++++++++++++++--------------------------- src/CMakeLists.txt | 115 +++++++++++++++++++++++----------------- 2 files changed, 119 insertions(+), 125 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 031720bd229d..5d7a8f7dcb65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,56 +27,30 @@ cmake_dependent_option(USE_PREFIX_DATA_DIR "Use UNIX system directories for game data in release build." ON "UNIX" OFF ) -set(LANGUAGES - "" - CACHE STRING "Compile localization files for specified languages. \ +set(LANGUAGES "" CACHE STRING + "Compile localization files for specified languages. \ List of language ids separated by semicolon. \ Set to 'all' or leave empty to compile all, set to 'none' to compile none.") -option(DYNAMIC_LINKING "Use dynamic linking. Or use static to remove MinGW dependency instead." - "ON") +option(DYNAMIC_LINKING + "Use dynamic linking. Or use static to remove MinGW dependency instead." "ON") option(USE_UNITY_BUILD "Use unity build." "OFF") option(JSON_FORMAT "Build JSON formatter" "OFF") option(CATA_CCACHE "Try to find and build with ccache" "ON") option(TESTS "Compile Cata's tests" "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") -set(GIT_BINARY - "" - CACHE STRING "Git binary name or path.") -set(LINKER - "" - CACHE STRING "Custom Linker to use") +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(LINKER "" CACHE STRING "Custom Linker to use") set(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.") if (TESTS) include(CTest) endif() -include(GetGitRevisionDescription) -git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*") - -message("\n * Cataclysm: Bright Nights is a roguelike set in a post-apocalyptic world.") -message(" _________ __ .__ ") -message(" \\_ ___ \\ _____ _/ |_ _____ ____ | | ___.__ ______ _____ ") -message( - " / \\ \\/ \\__ \\ \\ __\\\\__ \\ _/ ___\\ | | < | | / ___/ / \\ ") -message( - " \\ \\____ / __ \\_ | | / __ \\_\\ \\___ | |__ \\___ | \\___ \\ | Y Y \\ ") -message(" \\______ /\(____ / |__| \(____ / \\___ >|____/ / ____|/____ >|__|_| / ") -message(" \\/ \\/ \\/ \\/ \\/ \\/ \\/ ") -message(" --= Bright Nights =--") - -message("\n * https://github.com/cataclysmbnteam/Cataclysm-BN\n") - -message(STATUS "${PROJECT_NAME} build environment -- \n") - -message( - STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}") +message(STATUS "${PROJECT_NAME} build environment --") +message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}") if (LINKER) add_link_options("-fuse-ld=${LINKER}") @@ -88,11 +62,13 @@ endif () add_definitions(-DCMAKE) +include(GetGitRevisionDescription) +git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*") if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND") string(REPLACE "-NOTFOUND" "" GIT_VERSION ${GIT_VERSION}) file(WRITE ${CMAKE_SOURCE_DIR}/src/version.h "// NOLINT(cata-header-guard)\n\#define VERSION \"${GIT_VERSION}\"\n") - message(STATUS "${PROJECT_NAME} build version is : ${GIT_VERSION}\n") + message(STATUS "${PROJECT_NAME} build version is: ${GIT_VERSION}") add_definitions(-DGIT_VERSION) # get_git_head_revision() does not work with worktrees in Windows @@ -105,7 +81,8 @@ if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND") build type: ${BUILD_PRESET_NAME}\n\ build number: ${_timestamp}\n\ commit sha: ${_sha1}\n\ -commit url: https://github.com/cataclysmbnteam/Cataclysm-BN/commit/${_sha1}") +commit url: https://github.com/cataclysmbnteam/Cataclysm-BN/commit/${_sha1}" + ) endif () #OS Check Placeholders. Will be used for BINDIST @@ -140,16 +117,16 @@ if (NOT DYNAMIC_LINKING) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a") endif() set(BUILD_SHARED_LIBRARIES OFF) - check_cxx_compiler_flag(-static HAVE_STATIC_FLAG) + 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_C_FLAGS) # remove -Wl,-Bdynamic set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS) - set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC + 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_C_FLAGS) # remove -rdynamic set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) else () if (MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -170,8 +147,9 @@ if (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.") + 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 () @@ -227,24 +205,21 @@ 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 "LUA : ${LUA}") message(STATUS "BACKTRACE : ${BACKTRACE}") message(STATUS "LIBBACKTRACE : ${LIBBACKTRACE}") -message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}\n") message(STATUS "USE_XDG_DIR : ${USE_XDG_DIR}") - +message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}") message(STATUS "UNITY_BUILD : ${USE_UNITY_BUILD}") -message(STATUS "LANGUAGES : ${LANGUAGES}\n") - +message(STATUS "LANGUAGES : ${LANGUAGES}") if (LINKER) - message(STATUS "LINKER : ${LINKER}\n") + message(STATUS "LINKER : ${LINKER}") endif () -message(STATUS "See CMake compiling guide for details and more info --\n") +message(STATUS "See CMake compiling guide for details and more info --") if (NOT MSVC) set(CATA_WARNINGS @@ -282,15 +257,14 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Force out-of-source build if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - message( - FATAL_ERROR + message(FATAL_ERROR "This project requires an out of source build. \ - Remove the file 'CMakeCache.txt' found in this directory before continuing, \ + Remove the file 'CMakeCache.txt' found in this directory before continuing; \ create a separate build directory and run 'cmake [options] ' from there. \ See CMake compiling guide for details and more info.") endif () -#SET(THREADS_USE_PTHREADS_WIN32 True) +#set(THREADS_USE_PTHREADS_WIN32 True) set(CMAKE_THREAD_PREFER_PTHREAD True) find_package(Threads REQUIRED) @@ -320,11 +294,10 @@ if (TILES) message(STATUS "Searching for SDL2_TTF library --") find_package(SDL2_ttf) if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) - 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. \ + message(FATAL_ERROR + "This project requires SDL2_ttf to be installed to compile in graphical mode. \ + Please install the SDL2_ttf development libraries, \ + or try compiling without -DTILES=1 for a text-only compilation. \ See CMake compiling guide for details and more info.") endif () @@ -342,16 +315,15 @@ endif () if (CURSES) # Find the ncurses library for a text based compile - message(STATUS "Searching for Curses library --\n") + message(STATUS "Searching for Curses library --") 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. \ + 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 CMake compiling guide for details and more info.") endif () if (NOT DYNAMIC_LINKING) @@ -362,9 +334,9 @@ endif () 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. \ + message(FATAL_ERROR + "You must enable graphical support with -DTILES=1 \ + to be able to enable sound support. \ See CMake compiling guide for details and more info.") endif () @@ -399,6 +371,8 @@ if (NOT GETTEXT_MSGFMT_EXECUTABLE ) endif() # Ok. Now create build and install recipes +add_subdirectory(lang) + if (USE_HOME_DIR) add_definitions(-DUSE_HOME_DIR) endif () @@ -417,17 +391,17 @@ endif () add_subdirectory(src) add_subdirectory(data) -add_subdirectory(lang) if(TESTS) add_subdirectory(tests) endif() + if (JSON_FORMAT) add_subdirectory(tools/format) -endif () +endif() if (CATA_CLANG_TIDY_PLUGIN) add_subdirectory(tools/clang-tidy-plugin) -endif () +endif() install(DIRECTORY doc TYPE DOC) @@ -446,16 +420,17 @@ if (RELEASE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION .) endif() - endif () -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") +add_custom_target(uninstall + "${CMAKE_COMMAND}" + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") if (USE_UNITY_BUILD) set_property(GLOBAL PROPERTY UNITY_BUILD ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d7c6ca7b3c65..802d8815da7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,27 +21,32 @@ add_custom_target( 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 + 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(cataclysm-tiles-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS}) + add_library( + cataclysm-tiles-common OBJECT + ${CATACLYSM_BN_SOURCES} + ${CATACLYSM_BN_HEADERS}) target_include_directories(cataclysm-tiles-common INTERFACE ${CMAKE_SOURCE_DIR}/src) - if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") - target_precompile_headers(cataclysm-tiles-common PRIVATE - ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) - endif () - if (WIN32) add_definitions(-DUSE_WINMAIN) - add_executable(cataclysm-tiles WIN32 ${MAIN_CPP} ${MESSAGES_CPP} ${RESOURCE_RC}) + add_executable( + cataclysm-tiles WIN32 + ${MAIN_CPP} + ${MESSAGES_CPP} + ${RESOURCE_RC}) else () - add_executable(cataclysm-tiles ${MAIN_CPP} ${MESSAGES_CPP}) + add_executable(cataclysm-tiles + ${MAIN_CPP} + ${MESSAGES_CPP}) endif () if (LUA) @@ -52,7 +57,12 @@ if (TILES) add_dependencies(cataclysm-tiles-common get_version) target_link_libraries(cataclysm-tiles PRIVATE cataclysm-tiles-common) - target_compile_definitions(cataclysm-tiles-common PUBLIC TILES) + target_compile_definitions(cataclysm-tiles-common PUBLIC TILES ) + + if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") + target_precompile_headers(cataclysm-tiles-common PRIVATE + ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + endif () if (CMAKE_USE_PTHREADS_INIT) target_compile_options(cataclysm-tiles-common PUBLIC "-pthread") @@ -85,6 +95,7 @@ if (TILES) SDL2_mixer::SDL2_mixer ) endif() + add_definitions(-DSDL_SOUND) endif () if (WIN32) @@ -120,7 +131,9 @@ endif () # Build curses version if requested if (CURSES) - add_library(cataclysm-common OBJECT ${CATACLYSM_BN_SOURCES} ${CATACLYSM_BN_HEADERS}) + add_library(cataclysm-common OBJECT + ${CATACLYSM_BN_SOURCES} + ${CATACLYSM_BN_HEADERS}) target_include_directories(cataclysm-common INTERFACE ${CMAKE_SOURCE_DIR}/src) if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") @@ -129,9 +142,14 @@ if (CURSES) endif () if (WIN32) - add_executable(cataclysm ${MAIN_CPP} ${MESSAGES_CPP} ${RESOURCE_RC}) + add_executable(cataclysm + ${MAIN_CPP} + ${MESSAGES_CPP} + ${RESOURCE_RC}) else () - add_executable(cataclysm ${MAIN_CPP} ${MESSAGES_CPP}) + add_executable(cataclysm + ${MAIN_CPP} + ${MESSAGES_CPP}) endif () if (LUA) @@ -183,28 +201,31 @@ if (MINGW AND NOT RELEASE) # 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_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}) + + set(RuntimeLib_GCC_ALL + ${RuntimeLib_GCC_S_DW2_1} + ${RuntimeLib_STDC_PP_6} + ${RuntimeLib_WINPTHREAD_1}) 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") + 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} @@ -222,20 +243,20 @@ if (MINGW AND NOT RELEASE) ${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") + find_library(RuntimeLib_SDL_SND "SDL2_mixer") + find_library(RuntimeLib_flac "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_flac} ${RuntimeLib_ogg} ${RuntimeLib_flu} ${RuntimeLib_port} @@ -252,5 +273,3 @@ if (MINGW AND NOT RELEASE) ${RuntimeLib_SDL_SOUND} TYPE BIN) endif () - -# vim:noet From 5d5ecfe792d6d6710743ab8d7c6dc071fe36a0b0 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 17:13:31 +0300 Subject: [PATCH 155/188] Don't re-define LUA --- tests/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 35c56dfe262a..a634386ba7c6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,9 +8,6 @@ if (BUILD_TESTING) if (TILES) add_executable(cata_test-tiles ${CATACLYSM_BN_TEST_SOURCES}) - if (LUA) - target_compile_definitions(cata_test-tiles PUBLIC LUA) - endif () target_link_libraries(cata_test-tiles PRIVATE cataclysm-tiles-common) add_test( NAME test-tiles @@ -20,9 +17,6 @@ if (BUILD_TESTING) if (CURSES) add_executable(cata_test ${CATACLYSM_BN_TEST_SOURCES}) - if (LUA) - target_compile_definitions(cata_test PUBLIC LUA) - endif () target_link_libraries(cata_test PRIVATE cataclysm-common) add_test( NAME test From 69d184ce57545b037f71ba9d11c0ff52d3ee789d Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 17:13:37 +0300 Subject: [PATCH 156/188] Style fixes --- tests/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a634386ba7c6..1011b499a1b2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,6 @@ if (BUILD_TESTING) - file(GLOB CATACLYSM_BN_TEST_SOURCES ${CMAKE_SOURCE_DIR}/tests/*.cpp) + file(GLOB CATACLYSM_BN_TEST_SOURCES + ${CMAKE_SOURCE_DIR}/tests/*.cpp) # Enabling benchmarks add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) @@ -24,5 +25,3 @@ if (BUILD_TESTING) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endif () endif () - -# vim:noet From 4fad25b267b0bc9f09c9c0da2ff42c02b21f7a4a Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 17:13:57 +0300 Subject: [PATCH 157/188] Fix wrong merge --- CMakePresets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index a6b4d2c21d44..3d0cf67ebb1e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -28,7 +28,7 @@ "description": "Target Linux (64-bit) with the GCC development environment.", "generator": "Ninja Multi-Config", "cacheVariables": { - "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "DYNAMIC_LINKING": "True", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", "CMAKE_INSTALL_MESSAGE": "NEVER" } From b0762c82960ff43fa83247661cd664e15d13af1f Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 18:50:25 +0300 Subject: [PATCH 158/188] Add CMake + MSYS2 build to matrix --- .github/workflows/msys2-cmake.yml | 95 +++++++++++++++++++++++++++++++ src/string_id.h | 1 + 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/msys2-cmake.yml diff --git a/.github/workflows/msys2-cmake.yml b/.github/workflows/msys2-cmake.yml new file mode 100644 index 000000000000..eb3d69c1d5db --- /dev/null +++ b/.github/workflows/msys2-cmake.yml @@ -0,0 +1,95 @@ +name: Cataclysm Windows build (CMake + MSYS2) + +on: + push: + branches: + - upload + paths-ignore: + - 'android/**' + - 'build-data/osx/**' + - 'doc/**' + - 'doxygen_doc/**' + - 'gfx/**' + - 'lang/**' + - 'tools/**' + - '!tools/format/**' + - 'utilities/**' + - 'scripts/**' + pull_request: + branches: + - upload + paths-ignore: + - 'android/**' + - 'build-data/osx/**' + - 'doc/**' + - 'doxygen_doc/**' + - 'gfx/**' + - 'lang/**' + - 'tools/**' + - '!tools/format/**' + - 'utilities/**' + - 'scripts/**' + +# We only care about the latest revision of a PR, so cancel previous instances. +concurrency: + group: msys2-cmake-build-${{ github.event.pull_request.number || github.ref_name }} + cancel-in-progress: true + +jobs: + build_catatclysm: + name: Build + runs-on: windows-2019 + if: github.event.pull_request.draft == false + + defaults: + run: + shell: msys2 {0} + + steps: + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Setup MSYS2 + # Will by default install MINGW64 + uses: msys2/setup-msys2@v2 + with: + update: true + install: | + git + make + gettext + mingw-w64-x86_64-libmad + mingw-w64-x86_64-libwebp + mingw-w64-x86_64-pkg-config + mingw-w64-x86_64-SDL2 + mingw-w64-x86_64-SDL2_image + mingw-w64-x86_64-SDL2_mixer + mingw-w64-x86_64-SDL2_ttf + mingw-w64-x86_64-toolchain + mingw-w64-x86_64-cmake + + - name: Create build directory + run: mkdir build + + - name: Configure + run: | + cd build + cmake.exe \ + -DTILES=ON \ + -DSOUND=ON \ + -DLUA=ON \ + -DTESTS=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_FLAGS="-w" \ + -G "MSYS Makefiles" \ + .. + + - name: Build + run: | + cmake.exe --build build -j$((`nproc`+0)) + + - name: Run tests + run: | + ./build/tests/cata_test-tiles.exe --rng-seed time diff --git a/src/string_id.h b/src/string_id.h index 096145f277bc..01b3fd8e693d 100644 --- a/src/string_id.h +++ b/src/string_id.h @@ -2,6 +2,7 @@ #ifndef CATA_SRC_STRING_ID_H #define CATA_SRC_STRING_ID_H +#include #include #include #include From 2e079bf0219f09d194db79e8fda904769df9caeb Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 20:37:41 +0300 Subject: [PATCH 159/188] Update vcpkg --- .github/workflows/msvc-full-features-cmake.yml | 2 +- .github/workflows/msvc-full-features.yml | 2 +- .github/workflows/release.yml | 2 +- msvc-full-features/vcpkg.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index 447cfd91ddc4..24c18d904107 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -79,7 +79,7 @@ jobs: id: runvcpkg with: vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' - vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' + vcpkgGitCommitId: 'c9aba300923c8ec0ab190e2bff23085209925c97' - name: Integrate vcpkg run: | diff --git a/.github/workflows/msvc-full-features.yml b/.github/workflows/msvc-full-features.yml index ef971269b40a..753daef2fe3f 100644 --- a/.github/workflows/msvc-full-features.yml +++ b/.github/workflows/msvc-full-features.yml @@ -67,7 +67,7 @@ jobs: id: runvcpkg with: vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' - vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' + vcpkgGitCommitId: 'c9aba300923c8ec0ab190e2bff23085209925c97' - name: Integrate vcpkg run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c49462efaab2..cfa561f72db9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -192,7 +192,7 @@ jobs: id: runvcpkg with: vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' - vcpkgGitCommitId: '5b1214315250939257ef5d62ecdcbca18cf4fb1c' + vcpkgGitCommitId: 'c9aba300923c8ec0ab190e2bff23085209925c97' - name: Integrate vcpkg if: runner.os == 'Windows' run: | diff --git a/msvc-full-features/vcpkg.json b/msvc-full-features/vcpkg.json index 7cc2bbae92b1..da73cbcffe94 100644 --- a/msvc-full-features/vcpkg.json +++ b/msvc-full-features/vcpkg.json @@ -13,7 +13,7 @@ }, "sdl2-ttf" ], - "builtin-baseline": "5b1214315250939257ef5d62ecdcbca18cf4fb1c", + "builtin-baseline": "c9aba300923c8ec0ab190e2bff23085209925c97", "vcpkg-configuration": { "overlay-ports": [ "../.github/vcpkg_ports" From e3038853e5ad74b301b34ae0bb252e260267fa61 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 21:26:22 +0300 Subject: [PATCH 160/188] BNify install dir --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d7a8f7dcb65..ef575bd9b456 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,7 +181,7 @@ else () # 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") + set(CMAKE_INSTALL_DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share/cataclysm-bn") add_definitions(-DPREFIX=${CMAKE_INSTALL_PREFIX}) configure_file( "${CMAKE_SOURCE_DIR}/src/prefix.h.in" From abd783eb65765c24043a8e48b4197b3951a20bca Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 21:29:44 +0300 Subject: [PATCH 161/188] Use CMake to build translations in CI --- .github/workflows/msvc-full-features-cmake.yml | 2 +- .github/workflows/msys2-cmake.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index 24c18d904107..f78ca78aa6c2 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -104,7 +104,7 @@ jobs: - name: Compile .mo files for localization run: | - & "C:\msys64\mingw64\bin\mingw32-make" localization + cmake --build out/build/$env:CMAKE_PRESET --target translations_compile - name: Run tests run: | diff --git a/.github/workflows/msys2-cmake.yml b/.github/workflows/msys2-cmake.yml index eb3d69c1d5db..53a23bd71a42 100644 --- a/.github/workflows/msys2-cmake.yml +++ b/.github/workflows/msys2-cmake.yml @@ -90,6 +90,10 @@ jobs: run: | cmake.exe --build build -j$((`nproc`+0)) + - name: Compile translations + run: | + cmake.exe --build build --target translations_compile + - name: Run tests run: | ./build/tests/cata_test-tiles.exe --rng-seed time From 4063a843fc6c9a6b81adeb46786d1edd9ddfc122 Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 23:20:42 +0300 Subject: [PATCH 162/188] Update documentation --- doc/COMPILING/COMPILING-CMAKE-VCPKG.md | 106 -------------- .../docs/en/dev/guides/building/cmake.md | 20 ++- .../docs/en/dev/guides/building/vs_cmake.md | 136 ++++++++++++++++++ 3 files changed, 150 insertions(+), 112 deletions(-) delete mode 100644 doc/COMPILING/COMPILING-CMAKE-VCPKG.md create mode 100644 doc/src/content/docs/en/dev/guides/building/vs_cmake.md diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md deleted file mode 100644 index 332794e137af..000000000000 --- a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md +++ /dev/null @@ -1,106 +0,0 @@ -# Disclaimer - -**WARNING**: CMake build is **NOT** officially supported and should be used for _dev purposes ONLY_. - -For the official way to build CataclysmDDA, see: - -- [COMPILING.md](COMPILING.md) - -# Contents - -1. Prerequisites -2. Configure -3. Build -4. Install -5. Run - -# 1 Prerequisites - -`cmake` >= 3.20.0
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) `msgfmt` -(optional) as part of Git Bash or msys2 in the default install paths. - -# 2 Configure - -## Presets - -The file `CMakePresets.json` contains all the presets.
They will all build the code into the -directory `out/build//`. - -## vcpkg - -If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one -of the following: - -- append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands -- set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout. -- edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path - -## Visual Studio - -The Standard toolbar shows the presets in the _Configuration_ drop-down box.
From the main -menu, select _Project -> Configure Cache_ - -If you do not have `msgfmt` available, or do not want to include translations with the build, you -need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to -the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change -the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`. - -- Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do - not commit this change. - -## Terminal - -Run the command - -- `cmake --list-presets`
It will show the presets available to you. The list changes based on - the environment you are in. If empty, the environment is not supported. - -Run the command - -- `cmake --preset ` - -If you do not have `msgfmt` available, or do not want to include translations with the build, you -need to additionally pass `-DLOCALIZE=OFF`. - -- `cmake --preset -DLOCALIZE=OFF` - -# 3 Build - -## Visual Studio - -From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.
From the -main menu, select _Build -> Build All_ - -## Terminal - -Run the command - -- `cmake --build --preset ` - -# 4 Install - -## Visual Studio - -From the main menu, select _Build -> Install CataclysmDDA_ - -## Terminal - -Run the command - -- `cmake --install out/build// --config RelWithDebInfo` - -# 5 Run - -## Visual Studio - -From the Standard toolbar's _Select Startup Item..._ drop-down menu select -`cataclysm-tiles.exe (Install)`
The _Project Configuration_ drop-down menu will show -`RelWithDebInfo`.
You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start -Debugging_ (default F5). - -## Terminal - -Run the commands - -- `cd out/install//` -- `cataclysm` or `cataclysm-tiles.exe` diff --git a/doc/src/content/docs/en/dev/guides/building/cmake.md b/doc/src/content/docs/en/dev/guides/building/cmake.md index 5907f9519a6a..863139a277d9 100644 --- a/doc/src/content/docs/en/dev/guides/building/cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/cmake.md @@ -4,7 +4,7 @@ title: CMake :::caution -CMake build is unofficial. +CMake build is work-in-progress. ::: @@ -128,7 +128,7 @@ $ ccmake .. $ cmake-gui .. ``` -## build for MSYS2 (MinGW) +## Build for MSYS2 (MinGW) **NOTE**: For development purposes it is preferred to use `MinGW Win64 Shell` or `MinGW Win32 Shell` instead of `MSYS2 Shell`. In other case, you will need to set `PATH` variable manually. @@ -199,7 +199,15 @@ Currently known depends (Maybe outdated use ldd.exe to correct it for Your syste - `smpeg2.dll` - `libvorbisfile-3.dll` -## build for Visual Studio / MSBuild +## Build for Visual Studio / MSBuild + +:::caution + +This guide is quite old and requires manual dependency management. + +For modern alternative, see [CMake Visual Studio build with vcpkg](./vs_cmake.md) + +::: CMake can generate `.sln` and `.vcxproj` files used either by Visual Studio itself or by MSBuild command line compiler (if you don't want a full fledged IDE) and have more "native" binaries than @@ -273,7 +281,7 @@ destination directory with `-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=` option (a Run the game. Should work. -# Build Options +## Build Options A full list of options supported by CMake, you may either run the `ccmake` or `cmake-gui` front-ends, or run `cmake` and open the generated CMakeCache.txt from the build directory in a text @@ -283,7 +291,7 @@ editor. $ cmake -DOPTION_NAME1=option_value1 [-DOPTION_NAME2=option_value2 [...]] ``` -## CMake specific options +### CMake specific options - CMAKE_BUILD_TYPE=`` @@ -298,7 +306,7 @@ passed in the command line. Installation prefix for binaries, resources, and documentation files. -## CataclysmBN specific options +### CataclysmBN specific options - CURSES=`` diff --git a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md new file mode 100644 index 000000000000..98cb90d5963a --- /dev/null +++ b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md @@ -0,0 +1,136 @@ +--- +title: CMake + Visual Studio + Vcpkg +--- + +:::caution + +CMake build is work-in-progress. + +::: + +For official way to build CataclysmBN see [Compiler Support](../../reference/compiler_support.md). + +## Prerequisites + +- `cmake` >= 3.20.0 +- `vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) + +Note that starting from Visual Studio 2022 version 17.6, `vcpkg` is included with the distribution +and is available in the VS developer command prompt, so you don't have to install it separately. + +## Configure + +Configuration can be done using one of the presets in `CMakePresets.json`. They will all build the +code into the directory `out/build//`. + +### Terminal + +Ensure that `cmake` can find `vcpkg`. If it can't, it will complain about missing packages. You can +do this in one of the following ways: + +- For VS2022 users with preinstalled `vcpkg`, `vcpkg` should already be available if you're running + the VS developer command prompt and not the plain terminal +- Append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands +- Set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout +- Add the `VCPKG_ROOT` cache variable in `CMakePresets.json` with the appropriate path (not + recommended if you plan to work with the code later, git tracks this file) + +Run the command + +```sh +cmake --list-presets +``` + +It will show the presets available to you. The list changes based on the environment you are in. If +empty, the environment is not supported. + +Run the command + +```sh +cmake --preset +``` + +It will download all dependencies and generate build files, as long as `vcpkg` installation is +available. + +If you're using VS2022, you may need to tell CMake to generate VS2022-compatible project files with +`-G "Visual Studio 17 2022"`, as by default it will try to generate for VS2019. + +You can override any option by appending `-Doption=value` to this command, see +[Build options](./cmake.md/#build-options) in CMake guide. + +### Visual Studio + +Open the game source folder in Visual Studio. + +Visual Studio should be able to recognize the folder as a CMake project, and may attempt to start +configuring it, which will most likely fail because it didn't use the proper preset. + +The Standard toolbar shows the presets in the `Configuration` drop-down box. Choose the proper one +(should contain `windows` and `msvc`), then from the main menu, select `Project` -> +`Configure Cache`. + +## Build + +### Terminal + +Run the command + +- `cmake --build --preset ` + +### Visual Studio + +From the Standard toolbar's `Build Preset` drop-down menu select the build preset. From the main +menu, select `Build` -> `Build All`. + +## Translations + +Translations are optional and require `msgfmt` binary from `gettext` package, but `vcpkg` should +install it automatically. + +### Terminal + +Run the command + +- `cmake --build --preset --target translations_compile` + +### Visual Studio + +Visual Studio should have built the translations in the previous step. If it did not, refer to the +terminal guide. + +## Install + +:::caution + +Install is still considered WIP and has not been tested much. + +::: + +### Visual Studio + +From the main menu, select `Build` -> `Install CataclysmBN` + +### Terminal + +Run the command + +- `cmake --install out/build// --config RelWithDebInfo` + +## Run + +### Visual Studio + +TBD + +The game executable is available at `.\out\build\\src\Debug\cataclysm-tiles.exe`. + +If you run with `TESTS=ON`, the test executable is available at +`.\out\build\\tests\Debug\cata_test-tiles.exe`. + +### Terminal + +Run the commands + +- `cd out/install//` +- `cataclysm` or `cataclysm-tiles.exe` From e921836395111632ebd19cd47ed610999c22673b Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 23:22:05 +0300 Subject: [PATCH 163/188] Add separate preset for VS 2022 --- CMakePresets.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 3d0cf67ebb1e..692b97047067 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -10,7 +10,7 @@ "name": "windows-tiles-sounds-x64-msvc", "binaryDir": "${sourceDir}/out/build/${presetName}", "displayName": "Windows Tiles Sounds x64 MSVC", - "description": "Target Windows (64-bit) with the Visual Studio development environment.", + "description": "Target Windows (64-bit) with the Visual Studio 2019 development environment.", "generator": "Visual Studio 16 2019", "cacheVariables": { "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake", @@ -21,6 +21,17 @@ "CMAKE_INSTALL_MESSAGE": "NEVER" } }, + { + "name": "windows-tiles-sounds-x64-msvc-2022", + "inherits": ["windows-tiles-sounds-x64-msvc"], + "binaryDir": "${sourceDir}/out/build/${presetName}", + "displayName": "Windows Tiles Sounds x64 MSVC 2022", + "description": "Target Windows (64-bit) with the Visual Studio 2022 development environment.", + "generator": "Visual Studio 17 2022", + "cacheVariables": { + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake" + } + }, { "name": "linux-tiles-sounds-x64", "binaryDir": "${sourceDir}/out/build/${presetName}", From fb115a587bf33c63df42cc7d9b074c6f42524dd9 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 14:51:48 +0300 Subject: [PATCH 164/188] Implement missing members of vpart iterators --- src/vpart_range.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vpart_range.h b/src/vpart_range.h index 718b50038ef4..14911f0eeb94 100644 --- a/src/vpart_range.h +++ b/src/vpart_range.h @@ -85,6 +85,8 @@ namespace std template struct iterator_traits> { using difference_type = size_t; using value_type = vpart_reference; + using pointer = vpart_reference*; + using reference = vpart_reference&; // TODO: maybe change into random access iterator? This requires adding // more operators to the iterator, which may not be efficient. using iterator_category = std::forward_iterator_tag; From b1d105349915550cd32c5b974f569e23f62daae2 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 16:34:54 +0300 Subject: [PATCH 165/188] Remove deprecated headers from stdafx.h --- msvc-full-features/stdafx.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/msvc-full-features/stdafx.h b/msvc-full-features/stdafx.h index e6eff8ed2115..dadbfff9273b 100644 --- a/msvc-full-features/stdafx.h +++ b/msvc-full-features/stdafx.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,13 +18,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include From 2159cbbef10968bc4e1621e2155616e1d8a4340d Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 16:53:41 +0300 Subject: [PATCH 166/188] Fix float conversion warnings C4244 --- tests/creature_test.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/creature_test.cpp b/tests/creature_test.cpp index 3d11cb3708e6..4700b7600003 100644 --- a/tests/creature_test.cpp +++ b/tests/creature_test.cpp @@ -14,7 +14,7 @@ namespace { -using Weights = std::map; +using Weights = std::map; struct Expected { Weights base, max; }; @@ -23,12 +23,12 @@ struct Expected { const auto expected_smaller = Expected { Weights{ - { bp_torso, 20 }, { bp_head, 0 }, { bp_eyes, 0 }, { bp_mouth, 0 }, { bp_arm_l, 15 }, { bp_arm_r, 15 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 25 }, { bp_leg_r, 25 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 20.0 }, { bp_head, 0.0 }, { bp_eyes, 0.0 }, { bp_mouth, 0.0 }, { bp_arm_l, 15.0 }, { bp_arm_r, 15.0 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 25.0 }, { bp_leg_r, 25.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } }, Weights{ - { bp_torso, 4960 }, { bp_head, 0 }, { bp_eyes, 0 }, { bp_mouth, 0 }, { bp_arm_l, 1143 }, { bp_arm_r, 1186 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 3844 }, { bp_leg_r, 3867 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 4960.0 }, { bp_head, 0.0 }, { bp_eyes, 0.0 }, { bp_mouth, 0.0 }, { bp_arm_l, 1143.0 }, { bp_arm_r, 1186.0 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 3844.0 }, { bp_leg_r, 3867.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } } }; @@ -36,24 +36,24 @@ const auto expected_smaller = Expected const auto expected_same = Expected { Weights{ - { bp_torso, 33.33 }, { bp_head, 2.33 }, { bp_eyes, 0.33 }, { bp_mouth, 0 }, { bp_arm_l, 20 }, { bp_arm_r, 20 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 12 }, { bp_leg_r, 12 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 33.33 }, { bp_head, 2.33 }, { bp_eyes, 0.33 }, { bp_mouth, 0.0 }, { bp_arm_l, 20.0 }, { bp_arm_r, 20.0 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 12.0 }, { bp_leg_r, 12.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } }, Weights{ { bp_torso, 6513 }, { bp_head, 2928 }, { bp_eyes, 150 }, { bp_mouth, 0 }, { bp_arm_l, 1224 }, { bp_arm_r, 1235 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 1458 }, { bp_leg_r, 1492 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 1458.0 }, { bp_leg_r, 1492.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } } }; const auto expected_larger = Expected { Weights{ - { bp_torso, 36.57 }, { bp_head, 5.71 }, { bp_eyes, 0.57 }, { bp_mouth, 0 }, { bp_arm_l, 22.86 }, { bp_arm_r, 22.86 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 5.71 }, { bp_leg_r, 5.71 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 36.57 }, { bp_head, 5.71 }, { bp_eyes, 0.57 }, { bp_mouth, 0.0 }, { bp_arm_l, 22.86 }, { bp_arm_r, 22.86 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 5.71 }, { bp_leg_r, 5.71 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } }, Weights{ - { bp_torso, 5689 }, { bp_head, 5682 }, { bp_eyes, 221 }, { bp_mouth, 0 }, { bp_arm_l, 1185 }, { bp_arm_r, 1089 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 578 }, { bp_leg_r, 556 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 5689.0 }, { bp_head, 5682.0 }, { bp_eyes, 221.0 }, { bp_mouth, 0.0 }, { bp_arm_l, 1185.0 }, { bp_arm_r, 1089.0 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 578.0 }, { bp_leg_r, 556.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } } }; @@ -64,8 +64,8 @@ void calculate_bodypart_distribution( const enum m_size attacker_size, { INFO( "hit roll = " << hit_roll ); auto selected_part_histogram = Weights{ - { bp_torso, 0 }, { bp_head, 0 }, { bp_eyes, 0 }, { bp_mouth, 0 }, { bp_arm_l, 0 }, { bp_arm_r, 0 }, - { bp_hand_l, 0 }, { bp_hand_r, 0 }, { bp_leg_l, 0 }, { bp_leg_r, 0 }, { bp_foot_l, 0 }, { bp_foot_r, 0 } + { bp_torso, 0.0 }, { bp_head, 0.0 }, { bp_eyes, 0.0 }, { bp_mouth, 0.0 }, { bp_arm_l, 0.0 }, { bp_arm_r, 0.0 }, + { bp_hand_l, 0.0 }, { bp_hand_r, 0.0 }, { bp_leg_l, 0.0 }, { bp_leg_r, 0.0 }, { bp_foot_l, 0.0 }, { bp_foot_r, 0.0 } }; mtype atype; @@ -84,8 +84,8 @@ void calculate_bodypart_distribution( const enum m_size attacker_size, selected_part_histogram.at( bp )++; } - const float total_weight = std::accumulate( expected.begin(), expected.end(), 0.0f, - []( float acc, const auto & p ) { + const double total_weight = std::accumulate( expected.begin(), expected.end(), 0.0, + []( double acc, const auto & p ) { return acc + p.second; } ); From 24766ed8c6550ce56302f967627cb0ffb5e0b852 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 18:09:32 +0300 Subject: [PATCH 167/188] Show current path if failed to find data dir --- src/main.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fd6fe53ae35b..9ff6c64d59c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #if defined(_WIN32) # include "platform_win.h" @@ -600,23 +601,29 @@ int main( int argc, char *argv[] ) } } + std::string current_path = std::filesystem::current_path().string(); + if( !dir_exist( PATH_INFO::datadir() ) ) { std::string msg = string_format( "Can't find directory \"%s\"\n" + "Current path: \"%s\"\n" "Please ensure the current working directory is correct.\n" "Perhaps you meant to start \"cataclysm-launcher\"?\n", - PATH_INFO::datadir().c_str() + PATH_INFO::datadir(), + current_path ); report_fatal_error( msg ); exit( 1 ); } - const auto check_dir_good = []( const std::string & dir ) { + const auto check_dir_good = [¤t_path]( const std::string & dir ) { if( !assure_dir_exist( dir ) ) { std::string msg = string_format( "Can't open or create \"%s\"\n" + "Current path: \"%s\"\n" "Please ensure you have write permission.\n", - dir.c_str() + dir.c_str(), + current_path ); report_fatal_error( msg ); exit( 1 ); @@ -624,8 +631,10 @@ int main( int argc, char *argv[] ) if( !can_write_to_dir( dir ) ) { std::string msg = string_format( "Can't write to \"%s\"\n" + "Current path: \"%s\"\n" "Please ensure you have write permission and free storage space.\n", - dir.c_str() + dir.c_str(), + current_path ); report_fatal_error( msg ); exit( 1 ); From d23d01d9abb61a3280f28e4e2c563e62b8a6fb62 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 21:33:04 +0300 Subject: [PATCH 168/188] Force translation tests to end up on english --- tests/translations_test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/translations_test.cpp b/tests/translations_test.cpp index f22b49656c24..7ddd33393e74 100644 --- a/tests/translations_test.cpp +++ b/tests/translations_test.cpp @@ -168,9 +168,7 @@ TEST_CASE( "translations_actually_translate", "[translations][i18n]" ) } } - // Back up current language (should be 'en') const static std::string USE_LANG( "USE_LANG" ); - std::string lang_default = get_option( USE_LANG ); for( const auto &test : test_cases ) { CAPTURE( test.id ); @@ -187,7 +185,7 @@ TEST_CASE( "translations_actually_translate", "[translations][i18n]" ) } // Restore language - get_options().get_option( USE_LANG ).setValue( lang_default ); + get_options().get_option(USE_LANG).setValue("en_US"); get_options().save(); set_language(); } From 9295642437b1844e9dbd6496048f3c06b7b9252d Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 17:25:06 +0300 Subject: [PATCH 169/188] Fix build config setup in msvc Cmake preset --- .github/workflows/msvc-full-features-cmake.yml | 4 ++-- CMakePresets.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index f78ca78aa6c2..c635074472f0 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -93,7 +93,7 @@ jobs: - uses: ammaraskar/msvc-problem-matcher@master - name: Build run: | - cmake --build out/build/$env:CMAKE_PRESET + cmake --build out/build/$env:CMAKE_PRESET --config RelWithDebInfo - name: Dump logs if build failed if: failure() @@ -104,7 +104,7 @@ jobs: - name: Compile .mo files for localization run: | - cmake --build out/build/$env:CMAKE_PRESET --target translations_compile + cmake --build out/build/$env:CMAKE_PRESET --target translations_compile --config RelWithDebInfo - name: Run tests run: | diff --git a/CMakePresets.json b/CMakePresets.json index 692b97047067..de219b785620 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,7 +16,8 @@ "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake", "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", - "DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "DYNAMIC_LINKING": "False", + "CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo", "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", "CMAKE_INSTALL_MESSAGE": "NEVER" } From 8cd0326d20ca84e77cbfb40738bad87fa5461731 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 17:30:50 +0300 Subject: [PATCH 170/188] Fix path to tests --- .github/workflows/msvc-full-features-cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index c635074472f0..1bd8cbfaaeb3 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -108,4 +108,4 @@ jobs: - name: Run tests run: | - .\out\build\windows-tiles-sounds-x64-msvc\tests\Debug\cata_test-tiles.exe --rng-seed time + .\RelWithDebInfo\cata_test-tiles.exe --rng-seed time From af73a1a101af48eca207e04823bf1500036f9bb0 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 21:08:41 +0300 Subject: [PATCH 171/188] Add RelWithDebInfo to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 68a116e8c6a5..447d480e1c01 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ Release*/ # Temporary CMakeFiles CMakeUserPresets.json out/ +RelWithDebInfo*/ # Visual Studio 2015 /msvc-full-features/*db From d5c13acf5fb5f9998e8368134b9baff63720a8a8 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 21:32:40 +0300 Subject: [PATCH 172/188] Set cwd for debugging in VS --- src/CMakeLists.txt | 2 ++ tests/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 802d8815da7e..fb1617b8938d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -127,6 +127,8 @@ if (TILES) if (RELEASE) install(TARGETS cataclysm-tiles RUNTIME) endif () + + set_target_properties( cataclysm-tiles PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) endif () # Build curses version if requested diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1011b499a1b2..642dc519d1b5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,6 +14,8 @@ if (BUILD_TESTING) NAME test-tiles COMMAND sh -c "$ --rng-seed time" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + set_target_properties( cata_test-tiles PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) endif () if (CURSES) From 7b56192aa660fdc0d520db516859723522f5286a Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 21:33:49 +0300 Subject: [PATCH 173/188] Add Debug configuration, enable tests --- CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index de219b785620..caf09c2cebee 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -17,8 +17,8 @@ "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", "DYNAMIC_LINKING": "False", - "CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo", - "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "False", + "CMAKE_CONFIGURATION_TYPES": "Debug;RelWithDebInfo", + "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "True", "CMAKE_INSTALL_MESSAGE": "NEVER" } }, From 17711748b794589201de4f3cb9a26d2a1a17be44 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 21:35:30 +0300 Subject: [PATCH 174/188] Add docs on running from VS --- .../docs/en/dev/guides/building/vs_cmake.md | 76 +++++++++++++++---- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md index 98cb90d5963a..cfe8056a637e 100644 --- a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md @@ -53,11 +53,9 @@ cmake --preset It will download all dependencies and generate build files, as long as `vcpkg` installation is available. -If you're using VS2022, you may need to tell CMake to generate VS2022-compatible project files with -`-G "Visual Studio 17 2022"`, as by default it will try to generate for VS2019. +If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that suffix will target VS2019. -You can override any option by appending `-Doption=value` to this command, see -[Build options](./cmake.md/#build-options) in CMake guide. +You can override any option by appending `-Doption=value` to this command, see [Build options](./cmake.md/#build-options) in CMake guide. For example, you can disable building of tests with `-DTESTS=OFF` if you don't care about them. ### Visual Studio @@ -70,19 +68,26 @@ The Standard toolbar shows the presets in the `Configuration` drop-down box. Cho (should contain `windows` and `msvc`), then from the main menu, select `Project` -> `Configure Cache`. +If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that suffix are targeting VS2019. + ## Build ### Terminal Run the command -- `cmake --build --preset ` +- `cmake --build --preset --config RelWithDebInfo` + +You can replace `RelWithDebInfo` with `Debug` to get a debug build. ### Visual Studio From the Standard toolbar's `Build Preset` drop-down menu select the build preset. From the main menu, select `Build` -> `Build All`. +You can also select between `RelWithDebInfo` and `Debug` builds, though depending on UI layout +the drop-down menu for this may be hidden behind the overflow button. + ## Translations Translations are optional and require `msgfmt` binary from `gettext` package, but `vcpkg` should @@ -96,8 +101,7 @@ Run the command ### Visual Studio -Visual Studio should have built the translations in the previous step. If it did not, refer to the -terminal guide. +Visual Studio should have built the translations in the previous step. If it did not, open Solution Explorer, switch it into CMake Targets mode (can be done with a right click), then right click on `translations_compile` target -> `Build translations_compile`. ## Install @@ -117,20 +121,60 @@ Run the command - `cmake --install out/build// --config RelWithDebInfo` -## Run +Replace `RelWithDebInfo` with your chosen build type. -### Visual Studio +## Run -TBD +The game and test executables will both be available in `.\RelWithDebInfo\` folder (or `.\Debug`, if you've chosen `Debug` build; folder name matches build type). -The game executable is available at `.\out\build\\src\Debug\cataclysm-tiles.exe`. +You can run them manually from the terminal, as long as you do it from the project's top directory as by default the game expects data files to be in current path. -If you run with `TESTS=ON`, the test executable is available at -`.\out\build\\tests\Debug\cata_test-tiles.exe`. +For running and debugging from Visual Studio, it's recommended to open the generated VS solution located at `out\build\\CataclysmBN.sln` (should be there regardless of whether you've completed the previous steps in VS or terminal) and work with it instead. Alternatively, it's possible to stay in the "Open Folder" mode, but then you'll have to customize launch configuration for the game executable (and tests). ### Terminal -Run the commands +To start the game, run + +- `.\RelWithDebInfo\cataclysm-tiles.exe` + +To execute tests, run + +- `.\RelWithDebInfo\cata_test-tiles.exe` + +### Visual Studio (Option 1, Recommended) + +Close Visual Studio, then navigate to `out\build\\` and open `CataclysmBN.sln`. Set `cataclysm-tiles` as Startup Project (can be done with a right click from Solution Explorer), and you'll be able to run and debug the game executable and tests without additional issues. It will already be preconfigured to look for the data files in the top project directory. + +### Visual Studio (Option 2) + +Due to how Visual Studio handles CMake projects, it's impossible to specify the working directory for the executable while VS is in the "Open Folder" mode. This StackOverflow answer explains it nicely: https://stackoverflow.com/a/62309569 Fortunately, VS allows customizing exe launch options on individual basis. + +Open solution explorer and switch it into CMake Targets mode if you haven't already (can be done with a right click). There, right click on the `cataclysm-tiles` target -> `Add Debug Configuration`. Visual Studio will open launch configurations file for this project, with new configuration for the `cataclysm-tiles` target. Add the following line: + +``` +"currentDir": "${workspaceRoot}", +``` + +to the config and save the file. + +The final result should look something like this: + +```json +{ + "version": "0.2.1", + "defaults": {}, + "configurations": [ + { + "currentDir": "${workspaceRoot}", + "type": "default", + "project": "CMakeLists.txt", + "projectTarget": "cataclysm-tiles.exe (\\Debug\\cataclysm-tiles.exe)", + "name": "cataclysm-tiles.exe (\\Debug\\cataclysm-tiles.exe)" + } + ] +} +``` + +Now, you should be able to run and debug the game executable from inside Visual Studio. -- `cd out/install//` -- `cataclysm` or `cataclysm-tiles.exe` +If you'd like to run tests, repeat this process for the `cata_test-tiles` target. From e419d52da76e522ca335c32768147cd214491fb1 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:40:18 +0000 Subject: [PATCH 175/188] style(autofix.ci): automated formatting --- .../docs/en/dev/guides/building/vs_cmake.md | 45 ++++++++++++++----- tests/translations_test.cpp | 2 +- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md index cfe8056a637e..07803b2f27af 100644 --- a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md @@ -53,9 +53,12 @@ cmake --preset It will download all dependencies and generate build files, as long as `vcpkg` installation is available. -If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that suffix will target VS2019. +If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that +suffix will target VS2019. -You can override any option by appending `-Doption=value` to this command, see [Build options](./cmake.md/#build-options) in CMake guide. For example, you can disable building of tests with `-DTESTS=OFF` if you don't care about them. +You can override any option by appending `-Doption=value` to this command, see +[Build options](./cmake.md/#build-options) in CMake guide. For example, you can disable building of +tests with `-DTESTS=OFF` if you don't care about them. ### Visual Studio @@ -68,7 +71,8 @@ The Standard toolbar shows the presets in the `Configuration` drop-down box. Cho (should contain `windows` and `msvc`), then from the main menu, select `Project` -> `Configure Cache`. -If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that suffix are targeting VS2019. +If you're using VS2022, be sure to select a preset with `2022` in its name, as presets without that +suffix are targeting VS2019. ## Build @@ -85,8 +89,8 @@ You can replace `RelWithDebInfo` with `Debug` to get a debug build. From the Standard toolbar's `Build Preset` drop-down menu select the build preset. From the main menu, select `Build` -> `Build All`. -You can also select between `RelWithDebInfo` and `Debug` builds, though depending on UI layout -the drop-down menu for this may be hidden behind the overflow button. +You can also select between `RelWithDebInfo` and `Debug` builds, though depending on UI layout the +drop-down menu for this may be hidden behind the overflow button. ## Translations @@ -101,7 +105,9 @@ Run the command ### Visual Studio -Visual Studio should have built the translations in the previous step. If it did not, open Solution Explorer, switch it into CMake Targets mode (can be done with a right click), then right click on `translations_compile` target -> `Build translations_compile`. +Visual Studio should have built the translations in the previous step. If it did not, open Solution +Explorer, switch it into CMake Targets mode (can be done with a right click), then right click on +`translations_compile` target -> `Build translations_compile`. ## Install @@ -125,11 +131,17 @@ Replace `RelWithDebInfo` with your chosen build type. ## Run -The game and test executables will both be available in `.\RelWithDebInfo\` folder (or `.\Debug`, if you've chosen `Debug` build; folder name matches build type). +The game and test executables will both be available in `.\RelWithDebInfo\` folder (or `.\Debug`, if +you've chosen `Debug` build; folder name matches build type). -You can run them manually from the terminal, as long as you do it from the project's top directory as by default the game expects data files to be in current path. +You can run them manually from the terminal, as long as you do it from the project's top directory +as by default the game expects data files to be in current path. -For running and debugging from Visual Studio, it's recommended to open the generated VS solution located at `out\build\\CataclysmBN.sln` (should be there regardless of whether you've completed the previous steps in VS or terminal) and work with it instead. Alternatively, it's possible to stay in the "Open Folder" mode, but then you'll have to customize launch configuration for the game executable (and tests). +For running and debugging from Visual Studio, it's recommended to open the generated VS solution +located at `out\build\\CataclysmBN.sln` (should be there regardless of whether you've +completed the previous steps in VS or terminal) and work with it instead. Alternatively, it's +possible to stay in the "Open Folder" mode, but then you'll have to customize launch configuration +for the game executable (and tests). ### Terminal @@ -143,13 +155,22 @@ To execute tests, run ### Visual Studio (Option 1, Recommended) -Close Visual Studio, then navigate to `out\build\\` and open `CataclysmBN.sln`. Set `cataclysm-tiles` as Startup Project (can be done with a right click from Solution Explorer), and you'll be able to run and debug the game executable and tests without additional issues. It will already be preconfigured to look for the data files in the top project directory. +Close Visual Studio, then navigate to `out\build\\` and open `CataclysmBN.sln`. Set +`cataclysm-tiles` as Startup Project (can be done with a right click from Solution Explorer), and +you'll be able to run and debug the game executable and tests without additional issues. It will +already be preconfigured to look for the data files in the top project directory. ### Visual Studio (Option 2) -Due to how Visual Studio handles CMake projects, it's impossible to specify the working directory for the executable while VS is in the "Open Folder" mode. This StackOverflow answer explains it nicely: https://stackoverflow.com/a/62309569 Fortunately, VS allows customizing exe launch options on individual basis. +Due to how Visual Studio handles CMake projects, it's impossible to specify the working directory +for the executable while VS is in the "Open Folder" mode. This StackOverflow answer explains it +nicely: https://stackoverflow.com/a/62309569 Fortunately, VS allows customizing exe launch options +on individual basis. -Open solution explorer and switch it into CMake Targets mode if you haven't already (can be done with a right click). There, right click on the `cataclysm-tiles` target -> `Add Debug Configuration`. Visual Studio will open launch configurations file for this project, with new configuration for the `cataclysm-tiles` target. Add the following line: +Open solution explorer and switch it into CMake Targets mode if you haven't already (can be done +with a right click). There, right click on the `cataclysm-tiles` target -> +`Add Debug Configuration`. Visual Studio will open launch configurations file for this project, with +new configuration for the `cataclysm-tiles` target. Add the following line: ``` "currentDir": "${workspaceRoot}", diff --git a/tests/translations_test.cpp b/tests/translations_test.cpp index 7ddd33393e74..5abdcf74054e 100644 --- a/tests/translations_test.cpp +++ b/tests/translations_test.cpp @@ -185,7 +185,7 @@ TEST_CASE( "translations_actually_translate", "[translations][i18n]" ) } // Restore language - get_options().get_option(USE_LANG).setValue("en_US"); + get_options().get_option( USE_LANG ).setValue( "en_US" ); get_options().save(); set_language(); } From 2f8c9091651d9fd998fce042ed3db7093fc13464 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 31 Oct 2023 23:20:40 +0300 Subject: [PATCH 176/188] Add Release configuration style(autofix.ci): automated formatting --- CMakePresets.json | 2 +- .../docs/en/dev/guides/building/vs_cmake.md | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index caf09c2cebee..9dc2ac90dc8e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -17,7 +17,7 @@ "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake", "VCPKG_TARGET_TRIPLET": "x64-windows-static", "DYNAMIC_LINKING": "False", - "CMAKE_CONFIGURATION_TYPES": "Debug;RelWithDebInfo", + "CMAKE_CONFIGURATION_TYPES": "Debug;RelWithDebInfo;Release", "CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "LUA": "True", "TESTS": "True", "CMAKE_INSTALL_MESSAGE": "NEVER" } diff --git a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md index 07803b2f27af..9c71186aeb8e 100644 --- a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md @@ -80,17 +80,18 @@ suffix are targeting VS2019. Run the command -- `cmake --build --preset --config RelWithDebInfo` +- `cmake --build --preset --config Release` -You can replace `RelWithDebInfo` with `Debug` to get a debug build. +You can replace `Release` with `Debug` to get a debug build, or `RelWithDebInfo` for a release build +with less optimizations but more debug information. ### Visual Studio From the Standard toolbar's `Build Preset` drop-down menu select the build preset. From the main menu, select `Build` -> `Build All`. -You can also select between `RelWithDebInfo` and `Debug` builds, though depending on UI layout the -drop-down menu for this may be hidden behind the overflow button. +You can also select between `Release`, `Debug` and `RelWithDebInfo` builds, though depending on UI +layout the drop-down menu for this may be hidden behind the overflow button. ## Translations @@ -125,14 +126,14 @@ From the main menu, select `Build` -> `Install CataclysmBN` Run the command -- `cmake --install out/build// --config RelWithDebInfo` +- `cmake --install out/build// --config Release` -Replace `RelWithDebInfo` with your chosen build type. +Replace `Release` with your chosen build type. ## Run -The game and test executables will both be available in `.\RelWithDebInfo\` folder (or `.\Debug`, if -you've chosen `Debug` build; folder name matches build type). +The game and test executables will both be available in `.\Release\` folder (folder name matches +build type, so for other build types you'll get other folder names). You can run them manually from the terminal, as long as you do it from the project's top directory as by default the game expects data files to be in current path. @@ -147,11 +148,11 @@ for the game executable (and tests). To start the game, run -- `.\RelWithDebInfo\cataclysm-tiles.exe` +- `.\Release\cataclysm-tiles.exe` To execute tests, run -- `.\RelWithDebInfo\cata_test-tiles.exe` +- `.\Release\cata_test-tiles.exe` ### Visual Studio (Option 1, Recommended) From ab845e4acaa4e4bc12a38fb163137ec5ef665fd1 Mon Sep 17 00:00:00 2001 From: Olanti Date: Thu, 2 Nov 2023 12:02:54 +0300 Subject: [PATCH 177/188] ci: run MSYS on upload only --- .github/workflows/msys2-cmake.yml | 20 +++----------------- .github/workflows/msys2.yml | 20 +++----------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/msys2-cmake.yml b/.github/workflows/msys2-cmake.yml index 53a23bd71a42..3fb048598c58 100644 --- a/.github/workflows/msys2-cmake.yml +++ b/.github/workflows/msys2-cmake.yml @@ -1,4 +1,4 @@ -name: Cataclysm Windows build (CMake + MSYS2) +name: Windows build (CMake + MSYS2) on: push: @@ -15,24 +15,10 @@ on: - '!tools/format/**' - 'utilities/**' - 'scripts/**' - pull_request: - branches: - - upload - paths-ignore: - - 'android/**' - - 'build-data/osx/**' - - 'doc/**' - - 'doxygen_doc/**' - - 'gfx/**' - - 'lang/**' - - 'tools/**' - - '!tools/format/**' - - 'utilities/**' - - 'scripts/**' -# We only care about the latest revision of a PR, so cancel previous instances. +# We only care about the latest revision, so cancel previous instances. concurrency: - group: msys2-cmake-build-${{ github.event.pull_request.number || github.ref_name }} + group: msys2-cmake-build-${{ github.ref_name }} cancel-in-progress: true jobs: diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index 019e2ad9393d..03cf00060a5d 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -1,4 +1,4 @@ -name: Cataclysm Windows build (MSYS2) +name: Windows build (MSYS2) on: push: @@ -15,24 +15,10 @@ on: - '!tools/format/**' - 'utilities/**' - 'scripts/**' - pull_request: - branches: - - upload - paths-ignore: - - 'android/**' - - 'build-data/osx/**' - - 'doc/**' - - 'doxygen_doc/**' - - 'gfx/**' - - 'lang/**' - - 'tools/**' - - '!tools/format/**' - - 'utilities/**' - - 'scripts/**' -# We only care about the latest revision of a PR, so cancel previous instances. +# We only care about the latest revision, so cancel previous instances. concurrency: - group: msys2-build-${{ github.event.pull_request.number || github.ref_name }} + group: msys2-build-${{ github.ref_name }} cancel-in-progress: true jobs: From dcc986f3692b559e739e2ca0f3c8faa01921a68f Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 3 Nov 2023 22:55:00 +0300 Subject: [PATCH 178/188] Unify CMake and Makefile warnings --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef575bd9b456..92776a0ea73f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,6 +235,8 @@ if (NOT MSVC) -Wsuggest-override \ -Wunused-macros \ -Wzero-as-null-pointer-constant \ + -Wno-unknown-warning-option \ + -Wno-dangling-reference \ -Wno-range-loop-analysis") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option") From 3b741b87d675b8360ae7a2eb06d04784eadece2a Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 3 Nov 2023 22:55:35 +0300 Subject: [PATCH 179/188] ci: tweak msys cmake build --- .github/workflows/msys2-cmake.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/msys2-cmake.yml b/.github/workflows/msys2-cmake.yml index 3fb048598c58..77c9a18d96de 100644 --- a/.github/workflows/msys2-cmake.yml +++ b/.github/workflows/msys2-cmake.yml @@ -67,9 +67,10 @@ jobs: -DSOUND=ON \ -DLUA=ON \ -DTESTS=ON \ - -DCMAKE_BUILD_TYPE=Debug \ + -DDYNAMIC_LINKING=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_CXX_FLAGS="-w" \ - -G "MSYS Makefiles" \ + -G "Ninja" \ .. - name: Build From 46390457a8d7f4a9cb87a19062782163b5b702c9 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 7 Nov 2023 20:04:35 +0300 Subject: [PATCH 180/188] Remove /permissive- --- build-scripts/MSVC.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index b2d37ad0715e..7ad85eaee5c5 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -12,7 +12,6 @@ C++ flags used by all builds: /MP cl.exe build with multiple processes /utf-8 set source and execution character sets to UTF-8 /bigobj increase # of sections in object files -/permissive- enforce more standards compliant behavior /sdl- disable additional security checks /FC full path in compiler messages /Gd __cdecl @@ -53,7 +52,7 @@ No need to force /TLBID:1 because is default set(CMAKE_C_COMPILER cl.exe) set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}) set(CMAKE_CXX_FLAGS_INIT "\ -/MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \ +/MP /utf-8 /bigobj /sdl- /FC /Gd /GS- /Gy /GF \ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ /TP /Zc:forScope /Zc:inline /Zc:wchar_t" ) From 546c1af81bd9cc3afab9b4f0269f27e1f6a834db Mon Sep 17 00:00:00 2001 From: Olanti Date: Fri, 27 Oct 2023 23:20:52 +0300 Subject: [PATCH 181/188] Alt fix for compiling Lua with CXX compiler --- CMakeLists.txt | 2 +- src/lua/CMakeLists.txt | 14 ++++++++++++-- src/sol/CMakeLists.txt | 2 +- src/sol/config.hpp | 4 ++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92776a0ea73f..bc6bf1308f3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) -project(CataclysmBN) +project(CataclysmBN CXX) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules) diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index c018b2307be3..99128063f29e 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -1,5 +1,15 @@ file(GLOB LUA_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c) file(GLOB LUA_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) +list(APPEND LUA_SOURCES ${LUA_HEADERS}) -add_library(liblua ${LUA_SOURCES} ${LUA_HEADERS}) -target_include_directories(liblua PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +# We compile Lua C sources with C++ compiler so we don't have to bother +# with defining 2 different compilers. +set_source_files_properties(${LUA_SOURCES} PROPERTIES LANGUAGE CXX) + +add_library(liblua ${LUA_SOURCES}) +target_include_directories(liblua SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +set_target_properties(liblua PROPERTIES LINKER_LANGUAGE CXX) + +# Silence all errors. It's C code being compiled as C++, there're lots of them. +target_compile_options(liblua PRIVATE -w) diff --git a/src/sol/CMakeLists.txt b/src/sol/CMakeLists.txt index a4dfa73ae7ea..c0b9bad9c2f9 100644 --- a/src/sol/CMakeLists.txt +++ b/src/sol/CMakeLists.txt @@ -3,5 +3,5 @@ file(GLOB SOL_SOURCES config.hpp forward.hpp sol.hpp) add_library(libsol INTERFACE ${SOL_SOURCES}) # HACK: "/.." here is needed to avoid custom logic in Makefile. # Get rid of it once we get rid of Make, and move sol sources into subdirectory. -target_include_directories(libsol INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_include_directories(libsol SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..) target_link_libraries(libsol INTERFACE liblua) diff --git a/src/sol/config.hpp b/src/sol/config.hpp index 823a0e939527..fe88df36b2ca 100644 --- a/src/sol/config.hpp +++ b/src/sol/config.hpp @@ -52,6 +52,10 @@ the build system, or the command line options of your compiler. // We compile Lua parts with C++ compiler, so sol doesn't need to use extern "C" #define SOL_BUILD_CXX_MODE 1 +// Ugly hack so non-CMake builds work +#if defined(CMAKE) +# define SOL_USE_CXX_LUA 1 +#endif // Be helpful and verbose, even at the cost of speed #define SOL_ALL_SAFETIES_ON 1 From e6ec2fde20d42f5cd1a3e4cc7c202f936c0e6c32 Mon Sep 17 00:00:00 2001 From: Olanti Date: Mon, 13 Nov 2023 22:07:55 +0300 Subject: [PATCH 182/188] Add PCH to tests --- src/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 13 +++++++++++++ tests/pch/tests-pch.hpp | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb1617b8938d..05c0e934098c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,7 +140,7 @@ if (CURSES) if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") target_precompile_headers(cataclysm-common PRIVATE - ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) + ${CMAKE_SOURCE_DIR}/pch/main-pch.hpp) endif () if (WIN32) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 642dc519d1b5..cb21182661c1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,6 +7,9 @@ if (BUILD_TESTING) # TODO: build MO files required for tests + # This needs to include catch.h with different macro switch + set_source_files_properties(test_main.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + if (TILES) add_executable(cata_test-tiles ${CATACLYSM_BN_TEST_SOURCES}) target_link_libraries(cata_test-tiles PRIVATE cataclysm-tiles-common) @@ -15,6 +18,11 @@ if (BUILD_TESTING) COMMAND sh -c "$ --rng-seed time" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") + target_precompile_headers(cata_test-tiles PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/pch/tests-pch.hpp) + endif () + set_target_properties( cata_test-tiles PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) endif () @@ -25,5 +33,10 @@ if (BUILD_TESTING) NAME test COMMAND sh -c "$ --rng-seed time" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + if (NOT "${CMAKE_EXPORT_COMPILE_COMMANDS}") + target_precompile_headers(cata_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/pch/tests-pch.hpp) + endif () endif () endif () diff --git a/tests/pch/tests-pch.hpp b/tests/pch/tests-pch.hpp index 91f67a3c5913..a403a41a1d6e 100644 --- a/tests/pch/tests-pch.hpp +++ b/tests/pch/tests-pch.hpp @@ -1,3 +1,7 @@ #include "../pch/main-pch.hpp" #define CATCH_CONFIG_ALL_PARTS -#include "catch/catch.hpp" +#if defined(CMAKE) +# include "../catch/catch.hpp" +#else +# include "catch/catch.hpp" +#endif From 439334df1e240f9b624d51896c95bdd9af8be832 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 15:52:12 +0300 Subject: [PATCH 183/188] Fix more UB on global statics cleanup --- tests/test_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 9d554959ebf9..e1861cb1428d 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -327,6 +327,7 @@ int main( int argc, const char *argv[] ) DebugLog( DL::Info, DC::Main ) << "Randomness seeded to: " << seed; auto _on_out_of_scope = on_out_of_scope( []() { + g.reset(); DynamicDataLoader::get_instance().unload_data(); } ); try { From 620824ccc8860c396d80f53ae70535788da1e60f Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 17:01:30 +0300 Subject: [PATCH 184/188] Tweaks to VS CMake guide --- .../docs/en/dev/guides/building/vs_cmake.md | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md index 9c71186aeb8e..b1a0eb18e030 100644 --- a/doc/src/content/docs/en/dev/guides/building/vs_cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/vs_cmake.md @@ -8,8 +8,6 @@ CMake build is work-in-progress. ::: -For official way to build CataclysmBN see [Compiler Support](../../reference/compiler_support.md). - ## Prerequisites - `cmake` >= 3.20.0 @@ -95,8 +93,8 @@ layout the drop-down menu for this may be hidden behind the overflow button. ## Translations -Translations are optional and require `msgfmt` binary from `gettext` package, but `vcpkg` should -install it automatically. +Translations are optional and require `msgfmt` binary from `gettext` package; `vcpkg` should install +it automatically. ### Terminal @@ -107,14 +105,14 @@ Run the command ### Visual Studio Visual Studio should have built the translations in the previous step. If it did not, open Solution -Explorer, switch it into CMake Targets mode (can be done with a right click), then right click on +Explorer, switch it into CMake Targets mode (can be done with right click), then right click on `translations_compile` target -> `Build translations_compile`. ## Install :::caution -Install is still considered WIP and has not been tested much. +Install is still considered WIP and has received little testing. ::: @@ -139,10 +137,12 @@ You can run them manually from the terminal, as long as you do it from the proje as by default the game expects data files to be in current path. For running and debugging from Visual Studio, it's recommended to open the generated VS solution -located at `out\build\\CataclysmBN.sln` (should be there regardless of whether you've -completed the previous steps in VS or terminal) and work with it instead. Alternatively, it's -possible to stay in the "Open Folder" mode, but then you'll have to customize launch configuration -for the game executable (and tests). +located at `out\build\\CataclysmBN.sln` (it will be there regardless of whether you've +completed previous steps in IDE or terminal) and do any further work with it instead. + +Alternatively, it's possible to stay in the "Open Folder" mode, but then you'll have to customize +launch configuration for the game executable (and tests), and there may be other yet undiscovered +side effects. ### Terminal @@ -157,9 +157,11 @@ To execute tests, run ### Visual Studio (Option 1, Recommended) Close Visual Studio, then navigate to `out\build\\` and open `CataclysmBN.sln`. Set -`cataclysm-tiles` as Startup Project (can be done with a right click from Solution Explorer), and -you'll be able to run and debug the game executable and tests without additional issues. It will -already be preconfigured to look for the data files in the top project directory. +`cataclysm-tiles` as Startup Project (can be done with right click from Solution Explorer), and +you'll be able to run and debug the game executable without additional issues. It will already be +preconfigured to look for the data files in the top project directory. + +To run tests, switch the Startup Project to `cata_test-tiles`. ### Visual Studio (Option 2) From 00fed13e1c21fb15efd248be95da19ade84131db Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 17:47:14 +0300 Subject: [PATCH 185/188] Add new options to CMake guide --- doc/src/content/docs/en/dev/guides/building/cmake.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/src/content/docs/en/dev/guides/building/cmake.md b/doc/src/content/docs/en/dev/guides/building/cmake.md index 863139a277d9..0b9ca80a40f2 100644 --- a/doc/src/content/docs/en/dev/guides/building/cmake.md +++ b/doc/src/content/docs/en/dev/guides/building/cmake.md @@ -370,6 +370,14 @@ Override default Git binary name or path. Use UNIX system directories for game data in release build. +- USE_XDG_DIR=`` + +Use XDG directories for save and config files. + +- TESTS=`` + +Whether to build tests. + So a CMake command for building Cataclysm-BN in release mode with tiles and sound support will look as follows, provided it is run in build directory located in the project. From c691c401ac3409bbc16ce170921d2e11f7eedd8f Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 17:47:14 +0300 Subject: [PATCH 186/188] Fix port mistake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc6bf1308f3a..d37b71170687 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,7 +361,7 @@ if (BACKTRACE) endif () endif () -if ((LOCALIZE OR BUILD_TESTING) AND "${GETTEXT_MSGFMT_BINARY}" STREQUAL "") +if (NOT (LANGUAGES STREQUAL "none") AND "${GETTEXT_MSGFMT_BINARY}" STREQUAL "") if(MSVC) list(APPEND Gettext_ROOT C:\\msys64\\usr) list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\usr) From edd04f0457c2282a1d889b482fe79bff15ab2b26 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 17:53:04 +0300 Subject: [PATCH 187/188] Remove automatic CMake formatter --- .cmake-format.yml | 43 ----------------------------------- .github/workflows/autofix.yml | 5 ---- Makefile | 18 --------------- 3 files changed, 66 deletions(-) delete mode 100644 .cmake-format.yml diff --git a/.cmake-format.yml b/.cmake-format.yml deleted file mode 100644 index ca7a01af99c8..000000000000 --- a/.cmake-format.yml +++ /dev/null @@ -1,43 +0,0 @@ -# options affecting formatting -format: - # how wide to allow formatted cmake files - line_width: 100 - # how many spaces to tab for indent - tab_size: 4 - # if true, separate flow control names from their parentheses - separate_ctrl_name_with_space: true # currently ignored by cmake-lint - # if true, separate function names from parentheses with a - separate_fn_name_with_space: false # currently ignored by cmake-lint - # if a statement is wrapped to more than one line, than dangle - # the closing parenthesis on its own line. - dangle_parens: false # currently ignored by cmake-lint - # Format command names consistently as 'lower' or 'upper' case - # 'canonical': like in official documentation - command_case: 'canonical' # currently ignored by cmake-lint - # Format keywords consistently as 'lower' or 'upper' case - keyword_case: 'upper' # currently ignored by cmake-lint -# options affecting comment reflow and formatting -markup: - # enable comment markup parsing and reflow - enable_markup: false -# options affecting linter -lint: - # list of lint codes to disable - # C0113: Missing COMMENT in statement which allows it - disabled_codes: ['C0113'] - # regular expression pattern describing valid function names - function_pattern: '[a-z_]+' - # regular expression pattern describing valid names for private variables - # WEIRD: strangely named "directory variable name" in lint output - private_var_pattern: '_[0-9A-Z_]+' - # regular expression pattern describing valid names for public variables (strangely named "directories"?) - # WEIRD: strangely named "directory variable name" in lint output - public_var_pattern: '[0-9A-Z]+' - # regular expression pattern describing valid macro names - macro_pattern: '[a-z_]+' - # regular expression pattern describing valid names for function/macro - # arguments and loop variables - argument_var_pattern: '[A-Z][A-Z0-9_]+' - # require no more than this many newlines between statements - max_statement_spacing: 2 - diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 2eb388f4c7f4..63b9251c012a 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -18,8 +18,6 @@ jobs: - run: sudo apt-get install astyle - - run: sudo pip install cmakelang - - uses: denoland/setup-deno@v1 with: deno-version: v1.x @@ -30,9 +28,6 @@ jobs: - name: format markdown and typescript files run: deno fmt - - name: format CMake files - run: make cmake-format - - name: json formatting run: make style-all-json-parallel RELEASE=1 diff --git a/Makefile b/Makefile index ea2224f6678f..8e7402f4a7c3 100644 --- a/Makefile +++ b/Makefile @@ -1206,24 +1206,6 @@ check: version $(BUILD_PREFIX)cataclysm.a clean-tests: $(MAKE) -C tests clean -cmake-format: - cmake-format -i \ - ./CMakeLists.txt \ - ./.github/vcpkg_triplets/x64-windows-static.cmake \ - ./.github/vcpkg_triplets/x64-windows.cmake \ - ./.github/vcpkg_triplets/x86-windows-static.cmake \ - ./.github/vcpkg_triplets/x86-windows.cmake \ - ./cmake_uninstall.cmake.in \ - ./CMakeLists.txt \ - ./data/CMakeLists.txt \ - ./lang/CMakeLists.txt \ - ./src/CMakeLists.txt \ - ./src/version.cmake \ - ./tests/CMakeLists.txt \ - ./tools/clang-tidy-plugin/CMakeLists.txt \ - ./tools/format/CMakeLists.txt \ - -c .cmake-format.yml - .PHONY: tests check ctags etags clean-tests install lint -include $(SOURCES:$(SRC_DIR)/%.cpp=$(DEPDIR)/%.P) From 858bbe39a58b4e38041cd433831402c82a6bccf2 Mon Sep 17 00:00:00 2001 From: Olanti Date: Tue, 14 Nov 2023 19:33:01 +0300 Subject: [PATCH 188/188] Only run CMake+MSVC on upload --- .../workflows/msvc-full-features-cmake.yml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/msvc-full-features-cmake.yml b/.github/workflows/msvc-full-features-cmake.yml index 1bd8cbfaaeb3..e6c29f56f161 100644 --- a/.github/workflows/msvc-full-features-cmake.yml +++ b/.github/workflows/msvc-full-features-cmake.yml @@ -16,25 +16,10 @@ on: - '!tools/format/**' - 'utilities/**' - 'scripts/**' - pull_request: - branches: - - upload - paths-ignore: - - 'android/**' - - 'build-data/osx/**' - - 'doc/**' - - 'doxygen_doc/**' - - 'gfx/**' - - 'lang/**' - - 'lgtm/**' - - 'tools/**' - - '!tools/format/**' - - 'utilities/**' - - 'scripts/**' -# We only care about the latest revision of a PR, so cancel previous instances. +# We only care about the latest revision, so cancel previous instances. concurrency: - group: msvc-cmake-build-${{ github.event.pull_request.number || github.ref_name }} + group: msvc-cmake-build-${{ github.ref_name }} cancel-in-progress: true env: