From a4619402a3c489e920e721b520a0c00f7f230e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Tue, 9 Jul 2024 17:42:39 +0200 Subject: [PATCH 01/10] Move to VCPKG. --- CMakeLists.txt | 7 +---- CMakePresets.json | 52 ++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 60 +++++++++++++++++++++++++++++++++++----- vcpkg-configuration.json | 21 ++++++++++++++ vcpkg.json | 14 ++++++++++ 5 files changed, 141 insertions(+), 13 deletions(-) create mode 100644 CMakePresets.json create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cffcf2..3e51edf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,5 @@ cmake_minimum_required(VERSION 3.16) -if(DEFINED DEPENDENCIES_DIR) - include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake) -else() - include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake) -endif() - project(lootcli) + add_subdirectory(src) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..023baf5 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,52 @@ +{ + "configurePresets": [ + { + "errors": { + "deprecated": true + }, + "hidden": true, + "name": "cmake-dev", + "warnings": { + "deprecated": true, + "dev": true + } + }, + { + "cacheVariables": { + "VCPKG_MANIFEST_NO_DEFAULT_FEATURES": { + "type": "BOOL", + "value": "ON" + } + }, + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "hidden": true, + "name": "vcpkg" + }, + { + "binaryDir": "${sourceDir}/vsbuild", + "architecture": { + "strategy": "set", + "value": "x64" + }, + "cacheVariables": { + "CMAKE_CXX_FLAGS": "/EHsc /MP /W4", + "VCPKG_TARGET_TRIPLET": { + "type": "STRING", + "value": "x64-windows-static-md" + } + }, + "generator": "Visual Studio 17 2022", + "inherits": ["cmake-dev", "vcpkg"], + "name": "vs2022-windows", + "toolset": "v143" + } + ], + "buildPresets": [ + { + "name": "vs2022-windows", + "resolvePackageReferences": "on", + "configurePreset": "vs2022-windows" + } + ], + "version": 4 +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ceacdc..b0a83f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,58 @@ cmake_minimum_required(VERSION 3.16) +find_package(tomlplusplus CONFIG REQUIRED) +find_package(libloot CONFIG REQUIRED) +find_package(Boost REQUIRED CONFIG COMPONENTS locale) +find_package(nlohmann_json CONFIG REQUIRED) + +# avoid CMake error/warning +set_target_properties(libloot::loot PROPERTIES + MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo + MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo +) + add_executable(lootcli WIN32) +set_target_properties(lootcli PROPERTIES CXX_STANDARD 20) +target_sources(lootcli + PRIVATE + game_settings.cpp + game_settings.h + lootthread.cpp + lootthread.h + main.cpp + pch.h + version.h + version.rc + ${CMAKE_CURRENT_SOURCE_DIR}/../include/lootcli/lootcli.h +) +target_compile_definitions(lootcli PRIVATE _UNICODE UNICODE) +target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) +target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) +target_link_libraries(lootcli + PRIVATE libloot::loot Boost::headers Boost::locale + tomlplusplus::tomlplusplus nlohmann_json::nlohmann_json) + +if (MSVC) + target_compile_options(lootcli + PRIVATE + "/MP" + "/Wall" + "/external:anglebrackets" + "/external:W0" + ) + target_link_options(lootcli + PRIVATE + $<$:/LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF> + ) + + set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli) +endif() + +# add_library(lootcli-utils ) -mo2_configure_executable(lootcli - WARNINGS OFF - TRANSLATIONS OFF - PRIVATE_DEPENDS boost Qt::Core loot tomlplusplus) -target_include_directories(lootcli - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) +# add_library(mo2::lootcli ALIAS lootcli) -mo2_install_target(lootcli INSTALLDIR bin/loot) +install(FILES + $ + $ +DESTINATION bin/loot) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..d0298e8 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,21 @@ +{ + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7", + "packages": ["boost*", "boost-*"] + }, + { + "kind": "git", + "repository": "https://github.com/ModOrganizer2/vcpkg-registry", + "baseline": "27d8adbfe9e4ce88a875be3a45fadab69869eb60", + "packages": ["libloot"] + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..e4b41f2 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,14 @@ +{ + "dependencies": [ + "boost-locale", + "tomlplusplus", + "libloot", + "nlohmann-json" + ], + "overrides": [ + { + "name": "tomlplusplus", + "version": "3.1.0" + } + ] +} From 47bc128f49260ec3a2cfc5e556ff35c2ca93c1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Tue, 9 Jul 2024 18:45:13 +0200 Subject: [PATCH 02/10] Add lootcli-header target. --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ cmake/config.cmake.in | 3 +++ src/CMakeLists.txt | 19 +++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 cmake/config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e51edf..35e9d98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,32 @@ cmake_minimum_required(VERSION 3.16) +include(CMakePackageConfigHelpers) + project(lootcli) add_subdirectory(src) + +# install the header helper +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake" + INSTALL_DESTINATION "lib/cmake/mo2-lootcli-header" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h" lootcli_version) +string(REGEX MATCH "#define LOOTCLI_VERSION_STRING[ \t]*\"([0-9.]+)\"" _ ${lootcli_version}) +set(lootcli_version ${CMAKE_MATCH_1}) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake" + VERSION "${lootcli_version}" + COMPATIBILITY AnyNewerVersion + ARCH_INDEPENDENT +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/mo2-lootcli-header-config-version.cmake + DESTINATION lib/cmake/mo2-lootcli-header +) diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in new file mode 100644 index 0000000..4c845a2 --- /dev/null +++ b/cmake/config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-lootcli-header-targets.cmake" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a83f5..9a2a9f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,11 +48,22 @@ if (MSVC) set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli) endif() -# add_library(lootcli-utils ) - -# add_library(mo2::lootcli ALIAS lootcli) - install(FILES $ $ DESTINATION bin/loot) + +# library to make the header available +add_library(lootcli-header INTERFACE) +target_sources(lootcli-header INTERFACE + FILE_SET HEADERS + BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include + FILES ${CMAKE_CURRENT_LIST_DIR}/../include/lootcli/lootcli.h) +add_library(mo2::lootcli-header ALIAS lootcli-header) + +install(TARGETS lootcli-header EXPORT lootcliHeaderTargets FILE_SET HEADERS) +install(EXPORT lootcliHeaderTargets + FILE mo2-lootcli-header-targets.cmake + NAMESPACE mo2:: + DESTINATION lib/cmake/mo2-lootcli-header +) From a92b6e9804d513377054f8ec0e67ea43ce735bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sat, 13 Jul 2024 18:37:38 +0200 Subject: [PATCH 03/10] Set WIN32_EXECUTABLE property. --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a2a9f7..c19ee1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,9 @@ set_target_properties(libloot::loot PROPERTIES ) add_executable(lootcli WIN32) -set_target_properties(lootcli PROPERTIES CXX_STANDARD 20) +set_target_properties(lootcli PROPERTIES + CXX_STANDARD 20 + WIN32_EXECUTABLE TRUE) target_sources(lootcli PRIVATE game_settings.cpp From 4ac0a21c744d959828847190541cd43c38e89537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sat, 13 Jul 2024 19:46:28 +0200 Subject: [PATCH 04/10] Remove nlohmann_json dependency. Build header file alone when Qt is not available. --- src/CMakeLists.txt | 14 ++++++++++++-- vcpkg.json | 7 +------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c19ee1a..5d7a221 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,17 @@ cmake_minimum_required(VERSION 3.16) +# Qt is not required, this allows us to skip building the executable and only create +# the single-header interface when using this as a VCPKG dependency + +find_package(Qt6 CONFIG COMPONENTS Core) + +if (Qt6_FOUND) + +message(STATUS "Qt6 found, building lootcli executable") + find_package(tomlplusplus CONFIG REQUIRED) find_package(libloot CONFIG REQUIRED) find_package(Boost REQUIRED CONFIG COMPONENTS locale) -find_package(nlohmann_json CONFIG REQUIRED) # avoid CMake error/warning set_target_properties(libloot::loot PROPERTIES @@ -32,7 +40,7 @@ target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../includ target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) target_link_libraries(lootcli PRIVATE libloot::loot Boost::headers Boost::locale - tomlplusplus::tomlplusplus nlohmann_json::nlohmann_json) + tomlplusplus::tomlplusplus Qt6::Core) if (MSVC) target_compile_options(lootcli @@ -55,6 +63,8 @@ install(FILES $ DESTINATION bin/loot) +endif() + # library to make the header available add_library(lootcli-header INTERFACE) target_sources(lootcli-header INTERFACE diff --git a/vcpkg.json b/vcpkg.json index e4b41f2..3a673f8 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,10 +1,5 @@ { - "dependencies": [ - "boost-locale", - "tomlplusplus", - "libloot", - "nlohmann-json" - ], + "dependencies": ["boost-locale", "tomlplusplus", "libloot"], "overrides": [ { "name": "tomlplusplus", From dabf91444fd8daa275ae098fadbeb6ac41f041f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Fri, 9 Aug 2024 15:33:06 +0200 Subject: [PATCH 05/10] Minor cleaning. --- src/CMakeLists.txt | 8 ++++++-- vcpkg-configuration.json | 21 --------------------- vcpkg.json | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 vcpkg-configuration.json diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d7a221..0bda942 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,7 +35,10 @@ target_sources(lootcli version.rc ${CMAKE_CURRENT_SOURCE_DIR}/../include/lootcli/lootcli.h ) -target_compile_definitions(lootcli PRIVATE _UNICODE UNICODE) +target_compile_definitions(lootcli + PRIVATE + _UNICODE UNICODE + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) target_include_directories(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) target_precompile_headers(lootcli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pch.h) target_link_libraries(lootcli @@ -46,7 +49,7 @@ if (MSVC) target_compile_options(lootcli PRIVATE "/MP" - "/Wall" + "/W4" "/external:anglebrackets" "/external:W0" ) @@ -54,6 +57,7 @@ if (MSVC) PRIVATE $<$:/LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF> ) + target_compile_definitions(lootcli PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) set_target_properties(lootcli PROPERTIES VS_STARTUP_PROJECT lootcli) endif() diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json deleted file mode 100644 index d0298e8..0000000 --- a/vcpkg-configuration.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "default-registry": { - "kind": "git", - "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7" - }, - "registries": [ - { - "kind": "git", - "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "f61a294e765b257926ae9e9d85f96468a0af74e7", - "packages": ["boost*", "boost-*"] - }, - { - "kind": "git", - "repository": "https://github.com/ModOrganizer2/vcpkg-registry", - "baseline": "27d8adbfe9e4ce88a875be3a45fadab69869eb60", - "packages": ["libloot"] - } - ] -} diff --git a/vcpkg.json b/vcpkg.json index 3a673f8..e745c17 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,5 +5,26 @@ "name": "tomlplusplus", "version": "3.1.0" } - ] + ], + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "8ae59b5b1329a51875abc71d528da93d9c3e8972" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "8ae59b5b1329a51875abc71d528da93d9c3e8972", + "packages": ["boost*", "boost-*"] + }, + { + "kind": "git", + "repository": "https://github.com/ModOrganizer2/vcpkg-registry", + "baseline": "84ff92223433d101738a3c6cef96fa6ae6a6f302", + "packages": ["libloot"] + } + ] + } } From ea6898f41c52b2c73bcaac70cc2ef3ca56ab50ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 May 2025 15:03:55 +0200 Subject: [PATCH 06/10] Bump VCPKG registry baseline. --- vcpkg.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcpkg.json b/vcpkg.json index e745c17..b26027a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,19 +10,19 @@ "default-registry": { "kind": "git", "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "8ae59b5b1329a51875abc71d528da93d9c3e8972" + "baseline": "294f76666c3000630d828703e675814c05a4fd43" }, "registries": [ { "kind": "git", "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "8ae59b5b1329a51875abc71d528da93d9c3e8972", + "baseline": "294f76666c3000630d828703e675814c05a4fd43", "packages": ["boost*", "boost-*"] }, { "kind": "git", "repository": "https://github.com/ModOrganizer2/vcpkg-registry", - "baseline": "84ff92223433d101738a3c6cef96fa6ae6a6f302", + "baseline": "14e24beaf47774d19e4f16ed757e257124e69e9f", "packages": ["libloot"] } ] From 14db0d468342e136b7eefcf20041c6baec98383d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 May 2025 15:20:09 +0200 Subject: [PATCH 07/10] Bump VCPKG registry baseline. --- vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index b26027a..d890106 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -22,7 +22,7 @@ { "kind": "git", "repository": "https://github.com/ModOrganizer2/vcpkg-registry", - "baseline": "14e24beaf47774d19e4f16ed757e257124e69e9f", + "baseline": "8beb2e0efa9c17dd6d17bb05288dd1e40727f673", "packages": ["libloot"] } ] From 96f6529243986a557a1286bbdc19a76029849fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 May 2025 15:24:03 +0200 Subject: [PATCH 08/10] Add pre-commit hook. --- .pre-commit-config.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3103a1f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - id: check-case-conflict + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format + 'types_or': [c++, c] + +ci: + autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks." + autofix_prs: true + autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate." + autoupdate_schedule: quarterly + submodules: false From 870d807aa3c13058e3541953a5cf26be32500a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 May 2025 16:30:52 +0200 Subject: [PATCH 09/10] Fix Github action. --- .github/workflows/build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60d5d98..5ee7475 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,18 @@ name: Build LootCLI on: push: - branches: master + branches: [master] pull_request: types: [opened, synchronize, reopened] + +env: + VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite + jobs: build: runs-on: windows-2022 steps: - name: Build LootCLI - uses: ModOrganizer2/build-with-mob-action@master + uses: ModOrganizer2/build-with-mob-action@dev/vcpkg with: - mo2-third-parties: boost libloot mo2-dependencies: cmake_common From 3037916e4072e16eb342f4a0de340355674557d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 28 May 2025 14:02:04 +0200 Subject: [PATCH 10/10] Update Github action. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ee7475..d9ca97e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,6 @@ jobs: runs-on: windows-2022 steps: - name: Build LootCLI - uses: ModOrganizer2/build-with-mob-action@dev/vcpkg + uses: ModOrganizer2/build-with-mob-action@master with: mo2-dependencies: cmake_common