From aeb2a3e8a2a57c5a6dcdec50ae5afc2e20b52277 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Tue, 17 Jan 2023 11:10:58 +0100 Subject: [PATCH 1/6] Fix formatting of CMake files --- CMakeLists.txt | 9 ++++++--- configured_files/CMakeLists.txt | 6 ++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 324628e7..3dd884be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,8 +118,7 @@ dynamic_project_options( --suppress=unmatchedSuppression --suppress=passedByValue --suppress=syntaxError - --inconclusive -) + --inconclusive) target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD}) # TODO: The INTERFACE library NAMESPACE ALIAS are missing! CK @@ -165,7 +164,11 @@ endif() # Add other targets that you want installed here, be default we just package the one executable # we know we want to ship -package_project(TARGETS intro project_options project_warnings +package_project( + TARGETS + intro + project_options + project_warnings # FIXME: this does not work! CK # PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings ) diff --git a/configured_files/CMakeLists.txt b/configured_files/CMakeLists.txt index 2bf896ee..4bcea54f 100644 --- a/configured_files/CMakeLists.txt +++ b/configured_files/CMakeLists.txt @@ -1,7 +1,5 @@ - # A very simple example of a configured file that might need to be # converted to one that is publicly installed in the case that # you are developing a library -configure_file("config.hpp.in" "${CMAKE_BINARY_DIR}/configured_files/include/internal_use_only/config.hpp" ESCAPE_QUOTES) - - +configure_file("config.hpp.in" "${CMAKE_BINARY_DIR}/configured_files/include/internal_use_only/config.hpp" + ESCAPE_QUOTES) From ff1e52c9c7b549d6a50c73d6852dde4723f5ac06 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Thu, 26 Jan 2023 12:52:21 +0100 Subject: [PATCH 2/6] Fix undefined PROJECT_IS_TOP_LEVEL for cmake <3.21 --- test/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a5e24bc6..a95b8fc4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,13 @@ project(CmakeConfigPackageTests LANGUAGES CXX) # ---- Test as standalone project the exported config package ---- +# This variable is set by project() in CMake 3.21+ +string( + COMPARE EQUAL + "${CMAKE_SOURCE_DIR}" + "${PROJECT_SOURCE_DIR}" + PROJECT_IS_TOP_LEVEL) + if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION) enable_testing() From 4b27224cf6637bf5028d1813ac27ad5d1fb622b8 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Tue, 17 Jan 2023 11:15:32 +0100 Subject: [PATCH 3/6] Support CMake 24 and 25 Neither version removed any features or introduced any policies that are needed for this project: - Version 24: https://cmake.org/cmake/help/latest/release/3.24.html - Version 25: https://cmake.org/cmake/help/latest/release/3.25.html --- CMakeLists.txt | 7 ++++++- test/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dd884be..6f092489 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16...3.23) +cmake_minimum_required(VERSION 3.16...3.25) # Not ideal to use this global variable, but necessary to make sure # that tooling and projects use the same version @@ -20,6 +20,11 @@ set(ENABLE_DEVELOPER_MODE # Change this to false if you want to disable warnings_as_errors in developer mode set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE) +# fix DOWNLOAD_EXTRACT_TIMESTAMP warning in FetchContent +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0135 NEW) +endif() + # Add project_options v0.20.0 # https://github.com/cpp-best-practices/project_options include(FetchContent) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a95b8fc4..407d912d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15...3.23) +cmake_minimum_required(VERSION 3.16...3.25) project(CmakeConfigPackageTests LANGUAGES CXX) From 9f45cc49b8a75324d00254fcf1612a6b48b809d7 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Tue, 17 Jan 2023 11:39:19 +0100 Subject: [PATCH 4/6] Update project_options to v0.26.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f092489..2f852df9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # Add project_options v0.20.0 # https://github.com/cpp-best-practices/project_options include(FetchContent) -FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.20.0.zip) +FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.3.zip) FetchContent_MakeAvailable(_project_options) include(${_project_options_SOURCE_DIR}/Index.cmake) From 4573b52b4d78664230d5c7ea1b80b1bdd097daa2 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Tue, 17 Jan 2023 12:12:21 +0100 Subject: [PATCH 5/6] Update Catch2 to version 3.3.0 --- README.md | 2 +- conanfile.txt | 2 +- test/CMakeLists.txt | 16 ++++++---------- test/catch_main.cpp | 3 --- test/constexpr_tests.cpp | 2 +- test/tests.cpp | 2 +- 6 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 test/catch_main.cpp diff --git a/README.md b/README.md index 8b9af443..f4b45908 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Now you can clone the project locally and get to work! ## Testing -See [Catch2 tutorial](https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md) +See [Catch2 tutorial](https://github.com/catchorg/Catch2/blob/develop/docs/tutorial.md) ## Fuzz testing diff --git a/conanfile.txt b/conanfile.txt index a92cc590..11f25c2a 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,7 +1,7 @@ # Docs at https://docs.conan.io/en/latest/reference/conanfile_txt.html [requires] -catch2/2.13.9 +catch2/3.3.0 cli11/2.2.0 spdlog/1.10.0 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 407d912d..2246e5e1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,10 +28,6 @@ find_package(Catch2 CONFIG REQUIRED) include(Catch) -add_library(catch_main OBJECT catch_main.cpp) -target_link_libraries(catch_main PUBLIC Catch2::Catch2) -target_link_libraries(catch_main PRIVATE myproject::project_options) - # Provide a simple smoke test to make sure that the CLI works and can display a --help message add_test(NAME cli.has_help COMMAND intro --help) @@ -43,7 +39,7 @@ add_test(NAME cli.version_matches COMMAND intro --version) set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}") add_executable(tests tests.cpp) -target_link_libraries(tests PRIVATE myproject::project_warnings myproject::project_options catch_main) +target_link_libraries(tests PRIVATE myproject::project_warnings myproject::project_options Catch2::Catch2WithMain) # automatically discover tests that are defined in catch based test files you can modify the unittests. Set TEST_PREFIX # to whatever you want, or use different for different binaries @@ -52,7 +48,7 @@ catch_discover_tests( TEST_PREFIX "unittests." REPORTER - xml + XML OUTPUT_DIR . OUTPUT_PREFIX @@ -62,14 +58,14 @@ catch_discover_tests( # Add a file containing a set of constexpr tests add_executable(constexpr_tests constexpr_tests.cpp) -target_link_libraries(constexpr_tests PRIVATE myproject::project_options myproject::project_warnings catch_main) +target_link_libraries(constexpr_tests PRIVATE myproject::project_options myproject::project_warnings Catch2::Catch2WithMain) catch_discover_tests( constexpr_tests TEST_PREFIX "constexpr." REPORTER - xml + XML OUTPUT_DIR . OUTPUT_PREFIX @@ -80,7 +76,7 @@ catch_discover_tests( # Disable the constexpr portion of the test, and build again this allows us to have an executable that we can debug when # things go wrong with the constexpr testing add_executable(relaxed_constexpr_tests constexpr_tests.cpp) -target_link_libraries(relaxed_constexpr_tests PRIVATE myproject::project_options myproject::project_warnings catch_main) +target_link_libraries(relaxed_constexpr_tests PRIVATE myproject::project_options myproject::project_warnings Catch2::Catch2WithMain) target_compile_definitions(relaxed_constexpr_tests PRIVATE -DCATCH_CONFIG_RUNTIME_STATIC_REQUIRE) catch_discover_tests( @@ -88,7 +84,7 @@ catch_discover_tests( TEST_PREFIX "relaxed_constexpr." REPORTER - xml + XML OUTPUT_DIR . OUTPUT_PREFIX diff --git a/test/catch_main.cpp b/test/catch_main.cpp deleted file mode 100644 index 28ceb8c5..00000000 --- a/test/catch_main.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#define CATCH_CONFIG_MAIN// This tells the catch header to generate a main - -#include diff --git a/test/constexpr_tests.cpp b/test/constexpr_tests.cpp index 6d95f0db..9bc5d775 100644 --- a/test/constexpr_tests.cpp +++ b/test/constexpr_tests.cpp @@ -1,4 +1,4 @@ -#include +#include constexpr unsigned int Factorial(unsigned int number)// NOLINT(misc-no-recursion) { diff --git a/test/tests.cpp b/test/tests.cpp index a130a5d5..62f73bd7 100644 --- a/test/tests.cpp +++ b/test/tests.cpp @@ -1,4 +1,4 @@ -#include +#include unsigned int Factorial(unsigned int number)// NOLINT(misc-no-recursion) { From 007424d9b4b4a814b82621cc1a0551757217a4b7 Mon Sep 17 00:00:00 2001 From: Steven van der Schoot Date: Tue, 17 Jan 2023 12:13:27 +0100 Subject: [PATCH 6/6] Update spdlog to version 1.11.0 --- conanfile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.txt b/conanfile.txt index 11f25c2a..f8d54899 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -3,7 +3,7 @@ [requires] catch2/3.3.0 cli11/2.2.0 -spdlog/1.10.0 +spdlog/1.11.0 [generators] cmake_find_package_multi