From dfffceabda82a871b75abcf8baba7a85450b870d Mon Sep 17 00:00:00 2001 From: "serious-scaffold[bot]" <160990600+serious-scaffold[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 06:12:57 +0000 Subject: [PATCH] chore(deps): update dependency https://github.com/serious-scaffold/ss-cmake to v0.0.11 (#435) * chore(deps): update dependency https://github.com/serious-scaffold/ss-cmake to v0.0.11 * Resolve conflicts Signed-off-by: l.feng <43399351+msclock@users.noreply.github.com> --------- Signed-off-by: l.feng <43399351+msclock@users.noreply.github.com> Co-authored-by: serious-scaffold[bot] <160990600+serious-scaffold[bot]@users.noreply.github.com> Co-authored-by: l.feng <43399351+msclock@users.noreply.github.com> --- CMakeLists.txt | 16 +--- ...ndHardening.cmake => ProjectOptions.cmake} | 48 ++++------- cmake/presets/base.json | 80 ++++++++++--------- cmake/presets/default.json | 10 +++ cmake/presets/generators/ninja.json | 38 --------- cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake | 4 + .../vcpkg/bootstrap/vcpkg_load_triplet.cmake | 13 +-- cmake/vcpkg/vcpkg.toolchain.cmake | 3 +- copier.yml | 1 - includes/copier-answers-sample.yml | 1 + template/.copier-answers.ss-cmake.yml | 2 +- template/CMakeLists.txt.jinja | 32 +++----- ....cmake[% endif %] => ProjectOptions.cmake} | 48 ++++------- template/cmake/presets/base.json | 80 ++++++++++--------- template/cmake/presets/default.json | 10 +++ template/cmake/presets/generators/ninja.json | 38 --------- .../vcpkg/bootstrap/vcpkg_bootstrap.cmake | 4 + .../vcpkg/bootstrap/vcpkg_load_triplet.cmake | 13 +-- .../cmake/vcpkg/vcpkg.toolchain.cmake.jinja | 3 +- template/copier.ss-cmake.yml | 5 -- template/vcpkg.json.jinja | 11 ++- vcpkg.json | 4 +- 22 files changed, 186 insertions(+), 278 deletions(-) rename cmake/{ConfigureWarningsAndHardening.cmake => ProjectOptions.cmake} (81%) rename template/cmake/{[% if ss_cmake_configure_warnings_and_hardening == true %]ConfigureWarningsAndHardening.cmake[% endif %] => ProjectOptions.cmake} (81%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad54d043..dd180a56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,28 +7,14 @@ project( HOMEPAGE_URL "https://github.com/serious-scaffold/ss-cpp" DESCRIPTION "A continuously evolving basic template for cpp development.") -set(CMAKE_CXX_STANDARD - 20 - CACHE STRING "C++ standard") -set(CMAKE_CXX_STANDARD_REQUIRED - ON - CACHE BOOL "C++ standard required") -set(CMAKE_CXX_EXTENSIONS - OFF - CACHE BOOL "C++ extensions") - -# Source includes from vcpkg -include_directories(${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include) - # Project default module find_package(cmake-modules REQUIRED) include(cmake-modules/ProjectDefault) # Project custom modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(ConfigureWarningsAndHardening) include(ConfigureVersion) -include(ConfigureDocs) include(ConfigureCoverage) +include(ConfigureDocs) add_subdirectory(src) diff --git a/cmake/ConfigureWarningsAndHardening.cmake b/cmake/ProjectOptions.cmake similarity index 81% rename from cmake/ConfigureWarningsAndHardening.cmake rename to cmake/ProjectOptions.cmake index 298cb6ae..9dc10ff5 100644 --- a/cmake/ConfigureWarningsAndHardening.cmake +++ b/cmake/ProjectOptions.cmake @@ -1,26 +1,27 @@ #[[ -This file configures the following things: - - dynamic tools: sanitizers, valgrind. - - static tools: clang-tidy, cppcheck. - - compiler flags - - hardening options - +ProjectOptions.cmake - Defines project-specific options for CMake. ]] -include_guard(GLOBAL) +set(CMAKE_CXX_STANDARD + 20 + CACHE STRING "C++ standard") +set(CMAKE_CXX_STANDARD_REQUIRED + ON + CACHE BOOL "C++ standard required") +set(CMAKE_CXX_EXTENSIONS + OFF + CACHE BOOL "C++ extensions") # ############################################################################## -# Sanitizer +# Sanitizer - cmake-modules/build/Sanitizer.cmake # ############################################################################## set(USE_SANITIZER OFF CACHE BOOL "Enable sanitizer") -include(cmake-modules/build/Sanitizer) - # ############################################################################## -# Valgrind +# Valgrind - cmake-modules/test/Valgrind.cmake # ############################################################################## set(USE_VALGRIND @@ -37,20 +38,16 @@ set(USE_VALGRIND_OPTIONS # Valgrind is unacceptably slow. CACHE STRING "valgrind options.") -include(cmake-modules/test/Valgrind) - # ############################################################################## -# Clang-Tidy +# Clang-Tidy - cmake-modules/build/ClangTidy.cmake # ############################################################################## set(USE_CLANGTIDY OFF CACHE BOOL "Enable Clang-Tidy") -include(cmake-modules/build/ClangTidy) - # ############################################################################## -# Cppcheck +# Cppcheck - cmake-modules/build/Cppcheck.cmake # ############################################################################## set(USE_CPPCHECK @@ -61,16 +58,8 @@ set(USE_CPPCHECK_SUPPRESSION_FILE CACHE STRING "Customize the path to the Cppcheck suppressions file of the project") -include(cmake-modules/build/Cppcheck) - # ############################################################################## -# CompilerFlags -# ############################################################################## - -include(cmake-modules/build/CompilerFlags) - -# ############################################################################## -# Hardening +# Hardening - cmake-modules/build/Hardening.cmake # ############################################################################## # Comment `-Wl,-z,nodlopen` for dlopen call @@ -105,9 +94,8 @@ if(NOT MSVC) set(USE_HARDENING_LINKS -fstack-protector-strong # Enable stack protector - "-fsanitize=undefined -fsanitize-minimal-runtime" # Enable minimal runtime - # undefined behavior sanitizer -Wl,-z,nodlopen # Restrict dlopen(3) calls - # to shared objects + "-fsanitize=undefined -fsanitize-minimal-runtime" + # -Wl,-z,nodlopen # Restrict dlopen(3) calls to shared objects -Wl,-z,noexecstack # Enable data execution prevention by marking stack # memory as non-executable -Wl,-z,relro # Mark relocation table entries resolved at load-time as @@ -116,5 +104,3 @@ if(NOT MSVC) # read-only. It impacts startup performance CACHE STRING "Additional hardening linking flags for GCC/Clang") endif() - -include(cmake-modules/build/Hardening) diff --git a/cmake/presets/base.json b/cmake/presets/base.json index f1b76670..f41a6880 100644 --- a/cmake/presets/base.json +++ b/cmake/presets/base.json @@ -5,63 +5,68 @@ "toolchains/vcpkg.json" ], "configurePresets": [ + { + "name": "base-common", + "hidden":true, + "binaryDir":"${sourceDir}/out/build/${presetName}", + "installDir":"${sourceDir}/out/install/${presetName}", + "cacheVariables":{ + "CMAKE_COMPILE_WARNING_AS_ERROR":false, + "CMAKE_EXPORT_COMPILE_COMMANDS":true, + "CMAKE_VERBOSE_MAKEFILE":"FALSE" + } + }, { "name": "base", "hidden": true, "inherits": [ + "base-common", "ninja", "vcpkg" ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_VERBOSE_MAKEFILE": "FALSE" + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "base-config", "hidden": true, "inherits": [ + "base-common", "ninja-config", "vcpkg" - ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_VERBOSE_MAKEFILE": "FALSE" - } + ] } ], "buildPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base" }, + { + "name": "base-config-debug", + "hidden": true, + "configurePreset": "base-config", + "configuration": "Debug" + }, { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "RelWithDebInfo" }, { - "name": "base-config-debug", + "name": "base-config-release", "hidden": true, - "inherits": "ninja-config-debug", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "Release" } ], "testPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base", "output": { "outputOnFailure": true @@ -74,28 +79,29 @@ { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "RelWithDebInfo" }, { "name": "base-config-debug", "hidden": true, - "inherits": "ninja-config-debug", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "Debug" + }, + { + "name": "base-config-release", + "hidden": true, + "inherits": [ + "base" + ], + "configurePreset": "base-config", + "configuration": "Release" } ] } diff --git a/cmake/presets/default.json b/cmake/presets/default.json index 7423711a..0db1eb66 100644 --- a/cmake/presets/default.json +++ b/cmake/presets/default.json @@ -32,6 +32,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ], "testPresets": [ @@ -49,6 +54,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ] } diff --git a/cmake/presets/generators/ninja.json b/cmake/presets/generators/ninja.json index 424407d8..2280f4e2 100644 --- a/cmake/presets/generators/ninja.json +++ b/cmake/presets/generators/ninja.json @@ -11,43 +11,5 @@ "hidden": true, "generator": "Ninja Multi-Config" } - ], - "buildPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } - ], - "testPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } ] } diff --git a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake index c697a0c6..5546f787 100644 --- a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +++ b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake @@ -188,6 +188,10 @@ function(_vcpkg_bootstrap) "${arg_UNPARSED_ARGUMENTS}") endif() + if(NOT DEFINED arg_REPO) + set(arg_REPO https://github.com/microsoft/vcpkg.git) + endif() + find_package(Git QUIET REQUIRED) if(DEFINED CACHE{_VCPKG_ROOT}) diff --git a/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake b/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake index 6ceb2f0e..95722b1d 100644 --- a/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake +++ b/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake @@ -207,19 +207,22 @@ macro(_vcpkg_load_triplet) set(_community_triplet "triplets/community/${VCPKG_TARGET_TRIPLET}.cmake") if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_triplet}") + set(_load_triplet "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_triplet}") - include("${_VCPKG_ROOT}/${_triplet}") - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_community_triplet}") - include("${_VCPKG_ROOT}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_community_triplet}") else() message( FATAL_ERROR "Triplet ${VCPKG_TARGET_TRIPLET} not found at ${CMAKE_CURRENT_LIST_DIR}/${_triplet} or ${_VCPKG_ROOT}/${_triplet}" ) endif() + + message(STATUS "Loading triplet: ${_load_triplet}") + include(${_load_triplet}) + unset(_triplet) unset(_community_triplet) + unset(_load_triplet) endmacro(_vcpkg_load_triplet) diff --git a/cmake/vcpkg/vcpkg.toolchain.cmake b/cmake/vcpkg/vcpkg.toolchain.cmake index 249c5525..106fe3b2 100644 --- a/cmake/vcpkg/vcpkg.toolchain.cmake +++ b/cmake/vcpkg/vcpkg.toolchain.cmake @@ -27,5 +27,4 @@ set(VCPKG_VERBOSE file(READ ${CMAKE_SOURCE_DIR}/vcpkg.json _vcpkg_json) string(JSON _builtin_baseline GET ${_vcpkg_json} builtin-baseline) -vcpkg_configure(CACHE_DIR_NAME ss-cpp REPO - https://github.com/microsoft/vcpkg.git REF ${_builtin_baseline}) +vcpkg_configure(CACHE_DIR_NAME ss-cpp REF ${_builtin_baseline}) diff --git a/copier.yml b/copier.yml index 70787a39..f47bc5ad 100644 --- a/copier.yml +++ b/copier.yml @@ -109,7 +109,6 @@ repo_host: [%- endif %] help: 'Specify the host of the self-managed GitLab:' type: str - when: '{{ repo_platform == "gitlab-self-managed" }}' page_host: default: |- diff --git a/includes/copier-answers-sample.yml b/includes/copier-answers-sample.yml index 559549ed..bf28a19c 100644 --- a/includes/copier-answers-sample.yml +++ b/includes/copier-answers-sample.yml @@ -14,6 +14,7 @@ header_target: header organization_name: Serious Scaffold project_description: A continuously evolving basic template for cpp development. project_name: Serious Scaffold Cpp +repo_host: github.com repo_name: ss-cpp repo_namespace: serious-scaffold repo_platform: github diff --git a/template/.copier-answers.ss-cmake.yml b/template/.copier-answers.ss-cmake.yml index 731243e8..93ce848b 100644 --- a/template/.copier-answers.ss-cmake.yml +++ b/template/.copier-answers.ss-cmake.yml @@ -1,3 +1,3 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: v0.0.7 +_commit: v0.0.11 _src_path: https://github.com/serious-scaffold/ss-cmake diff --git a/template/CMakeLists.txt.jinja b/template/CMakeLists.txt.jinja index 0a31a383..355bc437 100644 --- a/template/CMakeLists.txt.jinja +++ b/template/CMakeLists.txt.jinja @@ -1,26 +1,11 @@ -[%- from pathjoin("includes", "variable.jinja") import repo_url with context -%] - cmake_minimum_required(VERSION 3.25) message(STATUS "CMAKE VERSION:${CMAKE_VERSION}") project( - {{ repo_name }} + {{ ss_cmake_repo_name }} LANGUAGES CXX C - HOMEPAGE_URL "https://{{ repo_url() }}" - DESCRIPTION "{{ project_description }}") - -set(CMAKE_CXX_STANDARD - 20 - CACHE STRING "C++ standard") -set(CMAKE_CXX_STANDARD_REQUIRED - ON - CACHE BOOL "C++ standard required") -set(CMAKE_CXX_EXTENSIONS - OFF - CACHE BOOL "C++ extensions") - -# Source includes from vcpkg -include_directories(${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include) + HOMEPAGE_URL "https://{{ ss_cmake_repo_url }}" + DESCRIPTION "{{ ss_cmake_project_description }}") # Project default module find_package(cmake-modules REQUIRED) @@ -28,15 +13,18 @@ include(cmake-modules/ProjectDefault) # Project custom modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(ConfigureWarningsAndHardening) +[%- if ss_cmake_configure_version == true %] include(ConfigureVersion) -include(ConfigureDocs) +[%- endif %] +[%- if ss_cmake_configure_coverage == true %] include(ConfigureCoverage) -[%- if use_cpm == true %] +[%- endif %] +[%- if ss_cmake_use_cpm == true %] include(ConfigureCPMDependencies) [%- endif %] -[%- if use_conan == true %] +[%- if ss_cmake_use_conan == true %] include(ConfigureConanDependencies) [%- endif %] +include(ConfigureDocs) add_subdirectory(src) diff --git a/template/cmake/[% if ss_cmake_configure_warnings_and_hardening == true %]ConfigureWarningsAndHardening.cmake[% endif %] b/template/cmake/ProjectOptions.cmake similarity index 81% rename from template/cmake/[% if ss_cmake_configure_warnings_and_hardening == true %]ConfigureWarningsAndHardening.cmake[% endif %] rename to template/cmake/ProjectOptions.cmake index 298cb6ae..9dc10ff5 100644 --- a/template/cmake/[% if ss_cmake_configure_warnings_and_hardening == true %]ConfigureWarningsAndHardening.cmake[% endif %] +++ b/template/cmake/ProjectOptions.cmake @@ -1,26 +1,27 @@ #[[ -This file configures the following things: - - dynamic tools: sanitizers, valgrind. - - static tools: clang-tidy, cppcheck. - - compiler flags - - hardening options - +ProjectOptions.cmake - Defines project-specific options for CMake. ]] -include_guard(GLOBAL) +set(CMAKE_CXX_STANDARD + 20 + CACHE STRING "C++ standard") +set(CMAKE_CXX_STANDARD_REQUIRED + ON + CACHE BOOL "C++ standard required") +set(CMAKE_CXX_EXTENSIONS + OFF + CACHE BOOL "C++ extensions") # ############################################################################## -# Sanitizer +# Sanitizer - cmake-modules/build/Sanitizer.cmake # ############################################################################## set(USE_SANITIZER OFF CACHE BOOL "Enable sanitizer") -include(cmake-modules/build/Sanitizer) - # ############################################################################## -# Valgrind +# Valgrind - cmake-modules/test/Valgrind.cmake # ############################################################################## set(USE_VALGRIND @@ -37,20 +38,16 @@ set(USE_VALGRIND_OPTIONS # Valgrind is unacceptably slow. CACHE STRING "valgrind options.") -include(cmake-modules/test/Valgrind) - # ############################################################################## -# Clang-Tidy +# Clang-Tidy - cmake-modules/build/ClangTidy.cmake # ############################################################################## set(USE_CLANGTIDY OFF CACHE BOOL "Enable Clang-Tidy") -include(cmake-modules/build/ClangTidy) - # ############################################################################## -# Cppcheck +# Cppcheck - cmake-modules/build/Cppcheck.cmake # ############################################################################## set(USE_CPPCHECK @@ -61,16 +58,8 @@ set(USE_CPPCHECK_SUPPRESSION_FILE CACHE STRING "Customize the path to the Cppcheck suppressions file of the project") -include(cmake-modules/build/Cppcheck) - # ############################################################################## -# CompilerFlags -# ############################################################################## - -include(cmake-modules/build/CompilerFlags) - -# ############################################################################## -# Hardening +# Hardening - cmake-modules/build/Hardening.cmake # ############################################################################## # Comment `-Wl,-z,nodlopen` for dlopen call @@ -105,9 +94,8 @@ if(NOT MSVC) set(USE_HARDENING_LINKS -fstack-protector-strong # Enable stack protector - "-fsanitize=undefined -fsanitize-minimal-runtime" # Enable minimal runtime - # undefined behavior sanitizer -Wl,-z,nodlopen # Restrict dlopen(3) calls - # to shared objects + "-fsanitize=undefined -fsanitize-minimal-runtime" + # -Wl,-z,nodlopen # Restrict dlopen(3) calls to shared objects -Wl,-z,noexecstack # Enable data execution prevention by marking stack # memory as non-executable -Wl,-z,relro # Mark relocation table entries resolved at load-time as @@ -116,5 +104,3 @@ if(NOT MSVC) # read-only. It impacts startup performance CACHE STRING "Additional hardening linking flags for GCC/Clang") endif() - -include(cmake-modules/build/Hardening) diff --git a/template/cmake/presets/base.json b/template/cmake/presets/base.json index f1b76670..f41a6880 100644 --- a/template/cmake/presets/base.json +++ b/template/cmake/presets/base.json @@ -5,63 +5,68 @@ "toolchains/vcpkg.json" ], "configurePresets": [ + { + "name": "base-common", + "hidden":true, + "binaryDir":"${sourceDir}/out/build/${presetName}", + "installDir":"${sourceDir}/out/install/${presetName}", + "cacheVariables":{ + "CMAKE_COMPILE_WARNING_AS_ERROR":false, + "CMAKE_EXPORT_COMPILE_COMMANDS":true, + "CMAKE_VERBOSE_MAKEFILE":"FALSE" + } + }, { "name": "base", "hidden": true, "inherits": [ + "base-common", "ninja", "vcpkg" ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_VERBOSE_MAKEFILE": "FALSE" + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "base-config", "hidden": true, "inherits": [ + "base-common", "ninja-config", "vcpkg" - ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_VERBOSE_MAKEFILE": "FALSE" - } + ] } ], "buildPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base" }, + { + "name": "base-config-debug", + "hidden": true, + "configurePreset": "base-config", + "configuration": "Debug" + }, { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "RelWithDebInfo" }, { - "name": "base-config-debug", + "name": "base-config-release", "hidden": true, - "inherits": "ninja-config-debug", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "Release" } ], "testPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base", "output": { "outputOnFailure": true @@ -74,28 +79,29 @@ { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "RelWithDebInfo" }, { "name": "base-config-debug", "hidden": true, - "inherits": "ninja-config-debug", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "Debug" + }, + { + "name": "base-config-release", + "hidden": true, + "inherits": [ + "base" + ], + "configurePreset": "base-config", + "configuration": "Release" } ] } diff --git a/template/cmake/presets/default.json b/template/cmake/presets/default.json index 7423711a..0db1eb66 100644 --- a/template/cmake/presets/default.json +++ b/template/cmake/presets/default.json @@ -32,6 +32,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ], "testPresets": [ @@ -49,6 +54,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ] } diff --git a/template/cmake/presets/generators/ninja.json b/template/cmake/presets/generators/ninja.json index 424407d8..2280f4e2 100644 --- a/template/cmake/presets/generators/ninja.json +++ b/template/cmake/presets/generators/ninja.json @@ -11,43 +11,5 @@ "hidden": true, "generator": "Ninja Multi-Config" } - ], - "buildPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } - ], - "testPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } ] } diff --git a/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake b/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake index c697a0c6..5546f787 100644 --- a/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +++ b/template/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake @@ -188,6 +188,10 @@ function(_vcpkg_bootstrap) "${arg_UNPARSED_ARGUMENTS}") endif() + if(NOT DEFINED arg_REPO) + set(arg_REPO https://github.com/microsoft/vcpkg.git) + endif() + find_package(Git QUIET REQUIRED) if(DEFINED CACHE{_VCPKG_ROOT}) diff --git a/template/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake b/template/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake index 6ceb2f0e..95722b1d 100644 --- a/template/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake +++ b/template/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake @@ -207,19 +207,22 @@ macro(_vcpkg_load_triplet) set(_community_triplet "triplets/community/${VCPKG_TARGET_TRIPLET}.cmake") if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_triplet}") + set(_load_triplet "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_triplet}") - include("${_VCPKG_ROOT}/${_triplet}") - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_community_triplet}") - include("${_VCPKG_ROOT}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_community_triplet}") else() message( FATAL_ERROR "Triplet ${VCPKG_TARGET_TRIPLET} not found at ${CMAKE_CURRENT_LIST_DIR}/${_triplet} or ${_VCPKG_ROOT}/${_triplet}" ) endif() + + message(STATUS "Loading triplet: ${_load_triplet}") + include(${_load_triplet}) + unset(_triplet) unset(_community_triplet) + unset(_load_triplet) endmacro(_vcpkg_load_triplet) diff --git a/template/cmake/vcpkg/vcpkg.toolchain.cmake.jinja b/template/cmake/vcpkg/vcpkg.toolchain.cmake.jinja index acf91aae..ae525349 100644 --- a/template/cmake/vcpkg/vcpkg.toolchain.cmake.jinja +++ b/template/cmake/vcpkg/vcpkg.toolchain.cmake.jinja @@ -27,5 +27,4 @@ set(VCPKG_VERBOSE file(READ ${CMAKE_SOURCE_DIR}/vcpkg.json _vcpkg_json) string(JSON _builtin_baseline GET ${_vcpkg_json} builtin-baseline) -vcpkg_configure(CACHE_DIR_NAME {{ ss_cmake_repo_name}} REPO - https://github.com/microsoft/vcpkg.git REF ${_builtin_baseline}) +vcpkg_configure(CACHE_DIR_NAME {{ ss_cmake_repo_name}} REF ${_builtin_baseline}) diff --git a/template/copier.ss-cmake.yml b/template/copier.ss-cmake.yml index 86bc5038..4c847094 100644 --- a/template/copier.ss-cmake.yml +++ b/template/copier.ss-cmake.yml @@ -20,11 +20,6 @@ ss_cmake_configure_version: help: Whether to configure to detect git version in cmake integration for C++ type: bool -ss_cmake_configure_warnings_and_hardening: - default: true - help: Whether to configure warnings and hardening compiling options in cmake integrationo for C++ - type: bool - ss_cmake_use_cpm: default: false help: Whether to use CPM to manage C++ dependencies that will break up vcpkg dependency management. diff --git a/template/vcpkg.json.jinja b/template/vcpkg.json.jinja index fd6f0ef0..2c2e26f1 100644 --- a/template/vcpkg.json.jinja +++ b/template/vcpkg.json.jinja @@ -1,10 +1,9 @@ -[%- from pathjoin("includes", "variable.jinja") import repo_url with context -%] { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", - "name": "{{ repo_name }}", - "description": "{{ project_description }}", + "name": "{{ ss_cmake_repo_name }}", + "description": "{{ ss_cmake_project_description }}", "builtin-baseline": "4b6c50d962cc20aaa3ef457f8ba683b586263cfb", - "homepage": "https://{{ repo_url() }}", + "homepage": "https://{{ ss_cmake_repo_url }}", "dependencies": [ [%- if compile_target != '' or exe_target != '' or header_target != '' %] "fmt", @@ -45,7 +44,7 @@ [%- endif %] { "name": "cmake-modules", - "version": "1.6.11" + "version": "1.6.13" }, { "name": "robotology-cmake-ycm", @@ -67,7 +66,7 @@ "registries": [ { "kind": "git", - "baseline": "09ae1472980f5e2132654900bb48061444b1cea5", + "baseline": "acce0190fabf75096d6be7db6138cb714bc7aace", "repository": "https://github.com/msclock/cmake-registry", "packages": [ [%- if ss_cmake_use_conan == true %] diff --git a/vcpkg.json b/vcpkg.json index 0a46d9e2..7c0c5bef 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -22,7 +22,7 @@ }, { "name": "cmake-modules", - "version": "1.6.11" + "version": "1.6.13" }, { "name": "robotology-cmake-ycm", @@ -44,7 +44,7 @@ "registries": [ { "kind": "git", - "baseline": "09ae1472980f5e2132654900bb48061444b1cea5", + "baseline": "acce0190fabf75096d6be7db6138cb714bc7aace", "repository": "https://github.com/msclock/cmake-registry", "packages": [ "cmake-modules",