mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
cmake: Add Catch2 unit testing
This commit is contained in:
parent
7bdcb5883d
commit
5139d1276b
1 changed files with 20 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ option(
|
||||||
"Link dependencies using CMake's find_package and do not use internal builds"
|
"Link dependencies using CMake's find_package and do not use internal builds"
|
||||||
${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
|
${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
|
||||||
)
|
)
|
||||||
|
option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" ON)
|
||||||
# This option isn't recommended for distribution builds and probably won't work (yet).
|
# This option isn't recommended for distribution builds and probably won't work (yet).
|
||||||
cmake_dependent_option(
|
cmake_dependent_option(
|
||||||
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
|
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
|
||||||
|
|
@ -81,6 +82,25 @@ option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
|
||||||
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
|
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
|
||||||
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
|
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
|
||||||
|
|
||||||
|
if(SRB2_CONFIG_ENABLE_TESTS)
|
||||||
|
# https://github.com/catchorg/Catch2
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME Catch2
|
||||||
|
VERSION 3.1.1
|
||||||
|
GITHUB_REPOSITORY catchorg/Catch2
|
||||||
|
OPTIONS
|
||||||
|
"CATCH_INSTALL_DOCS OFF"
|
||||||
|
)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
|
||||||
|
include(CTest)
|
||||||
|
include(Catch)
|
||||||
|
add_executable(srb2tests)
|
||||||
|
# To add tests, use target_sources to add individual test files to the target in subdirs.
|
||||||
|
target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
|
||||||
|
target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17)
|
||||||
|
catch_discover_tests(srb2tests)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Enable CCache
|
# Enable CCache
|
||||||
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
|
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
|
||||||
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
|
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue