Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Update dependecies #46

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,10 +20,15 @@ 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)
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)

Expand Down Expand Up @@ -118,8 +123,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
Expand Down Expand Up @@ -165,7 +169,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
)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 2 additions & 4 deletions configured_files/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 14 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
cmake_minimum_required(VERSION 3.15...3.23)
cmake_minimum_required(VERSION 3.16...3.25)

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()

Expand All @@ -21,10 +28,6 @@ find_package(Catch2 CONFIG REQUIRED)

include(Catch)

add_library(catch_main OBJECT catch_main.cpp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept this lines to avoid changing to Catch2::Catch2WithMain in all other target_link_libraries. It worked anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on what the benefits are of keeping the catch_main target? When keeping it it just serves as an alias for Catch2::CatchWithMain. My initial thought was to remove it, since it shortens and simplifies the cmake file and thus servers the purpose of a minimal starter project better.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think none to be honest. But you see that's an project_options include. I'm not sure if it changes something or not.

target_link_libraries(catch_main PUBLIC Catch2::Catch2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed only here to target_link_libraries(catch_main PUBLIC Catch2::Catch2WithMain)

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)

Expand All @@ -36,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
Expand All @@ -45,7 +48,7 @@ catch_discover_tests(
TEST_PREFIX
"unittests."
REPORTER
xml
XML
OUTPUT_DIR
.
OUTPUT_PREFIX
Expand All @@ -55,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
Expand All @@ -73,15 +76,15 @@ 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(
relaxed_constexpr_tests
TEST_PREFIX
"relaxed_constexpr."
REPORTER
xml
XML
OUTPUT_DIR
.
OUTPUT_PREFIX
Expand Down
3 changes: 0 additions & 3 deletions test/catch_main.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/constexpr_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

constexpr unsigned int Factorial(unsigned int number)// NOLINT(misc-no-recursion)
{
Expand Down
2 changes: 1 addition & 1 deletion test/tests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

unsigned int Factorial(unsigned int number)// NOLINT(misc-no-recursion)
{
Expand Down