Merge branch 'testing'
This commit is contained in:
commit
ea201fe0f9
@ -15,6 +15,8 @@
|
|||||||
# building
|
# building
|
||||||
gcc
|
gcc
|
||||||
cmake
|
cmake
|
||||||
|
ninja
|
||||||
|
sccache
|
||||||
|
|
||||||
# pre-commit
|
# pre-commit
|
||||||
pre-commit
|
pre-commit
|
||||||
|
@ -8,6 +8,13 @@ project(
|
|||||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
include(ExportCompileCommands)
|
include(ExportCompileCommands)
|
||||||
|
include(sccache)
|
||||||
|
|
||||||
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
|
include(CTest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
|
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
|
||||||
"${PROJECT_BINARY_DIR}/include/version.h")
|
"${PROJECT_BINARY_DIR}/include/version.h")
|
||||||
@ -19,3 +26,7 @@ target_compile_features(hello PUBLIC cxx_std_20)
|
|||||||
|
|
||||||
target_include_directories(hello PRIVATE "${PROJECT_BINARY_DIR}/include"
|
target_include_directories(hello PRIVATE "${PROJECT_BINARY_DIR}/include"
|
||||||
"${PROJECT_SOURCE_DIR}/include")
|
"${PROJECT_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
6
cmake/sccache.cmake
Normal file
6
cmake/sccache.cmake
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
find_program(SCCACHE_FOUND sccache)
|
||||||
|
|
||||||
|
if(SCCACHE_FOUND)
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER sccache)
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER sccache)
|
||||||
|
endif()
|
14
tests/CMakeLists.txt
Normal file
14
tests/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FetchContent_Declare(
|
||||||
|
catch2
|
||||||
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||||
|
GIT_TAG v3.4.0)
|
||||||
|
FetchContent_MakeAvailable(catch2)
|
||||||
|
|
||||||
|
add_executable(dummy_tests dummy.cpp)
|
||||||
|
|
||||||
|
target_compile_features(dummy_tests PRIVATE cxx_std_20)
|
||||||
|
|
||||||
|
target_link_libraries(dummy_tests PRIVATE Catch2::Catch2WithMain)
|
||||||
|
|
||||||
|
include(Catch)
|
||||||
|
catch_discover_tests(dummy_tests)
|
4
tests/dummy.cpp
Normal file
4
tests/dummy.cpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("dummy", "dummy tests") { REQUIRE(1 + 1 == 2); }
|
||||||
|
TEST_CASE("dummy fails", "dummy tests") { REQUIRE_FALSE(1 + 1 != 2); }
|
Reference in New Issue
Block a user