1
0
mirror of https://github.com/catchorg/Catch2.git synced 2025-01-15 14:48:00 +00:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Martin Hořeňovský
4005d87460
Use proper linkage between Catch2Main and Catch2 2019-12-18 20:14:34 +01:00
Martin Hořeňovský
0dc30e51c0
Update codecov ignorelist 2019-12-18 18:04:31 +01:00
Martin Hořeňovský
0c62a50392
Add the catch_main source file 2019-12-18 18:02:57 +01:00
Martin Hořeňovský
68cf4ca883
Add back coverage CMake option 2019-12-18 17:31:10 +01:00
Martin Hořeňovský
9c07e2a416
Add test for tag aliases 2019-12-18 17:30:41 +01:00
Martin Hořeňovský
a4c31ecd16
Small CMakeLists cleanup 2019-12-18 17:30:08 +01:00
Martin Hořeňovský
1cc05122d7
Add Catch2Main CMake target that contains test main 2019-12-18 17:25:04 +01:00
5 changed files with 32 additions and 46 deletions

View File

@ -9,6 +9,7 @@ endif()
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF)
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
option(CATCH_INSTALL_EXTRAS "Install extras alongside library" ON)
@ -61,7 +62,6 @@ if(CATCH_BUILD_EXTRA_TESTS)
endif()
#option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
#option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
#option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
#
#set_property(GLOBAL PROPERTY USE_FOLDERS ON)

View File

@ -10,11 +10,6 @@ coverage:
default:
target: 80%
ignore:
- "projects/SelfTest"
- "**/catch_reporter_tap.hpp"
- "**/catch_reporter_automake.hpp"
- "**/catch_reporter_teamcity.hpp"
- "**/catch_reporter_sonarqube.hpp"
- "**/external/clara.hpp"

View File

@ -224,23 +224,15 @@ add_library(Catch2 STATIC
${BENCHMARK_HEADERS}
${BENCHMARK_SOURCES}
)
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
add_library(Catch2::Catch2 ALIAS Catch2)
if (ANDROID)
target_link_libraries(Catch2 INTERFACE log)
endif()
target_include_directories(Catch2
PUBLIC
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# depend on bunch of C++11 and C++14 features to have C++14 enabled by default
target_compile_features(Catch2
INTERFACE
PUBLIC
cxx_alignas
cxx_alignof
cxx_attributes
@ -263,11 +255,27 @@ target_compile_features(Catch2
cxx_variadic_macros
)
target_include_directories(Catch2
PUBLIC
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
add_library(Catch2Main STATIC
${SOURCES_DIR}/catch_main.cpp
)
add_library(Catch2::Catch2Main ALIAS Catch2Main)
target_link_libraries(Catch2Main PUBLIC Catch2)
if (NOT_SUBPROJECT)
# create and install an export set for catch target as Catch2::Catch
install(
TARGETS
Catch2
Catch2Main
EXPORT
Catch2Targets
DESTINATION
@ -283,9 +291,8 @@ if (NOT_SUBPROJECT)
DESTINATION
${CATCH_CMAKE_CONFIG_DESTINATION}
)
# This installs the headers
# Install the headers
install(DIRECTORY ${SOURCES_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h*")
# TODO: Also install the helper main
endif()
# Some tests require a full recompilation of Catch2 lib with different

View File

@ -0,0 +1,6 @@
/*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <catch2/catch_default_main.hpp>

View File

@ -75,7 +75,7 @@ set(HEADERS
${EXTERNAL_HEADERS}
${INTERNAL_HEADERS}
${REPORTER_HEADERS}
${BENCHMARK_HEADERS}
${BENCHMARK_HEADERS}
${BENCHMARK_SOURCES}
)
@ -89,33 +89,6 @@ include(CTest)
add_executable(SelfTest ${TEST_SOURCES})
target_link_libraries(SelfTest PRIVATE Catch2)
# It took CMake until 3.8 to abandon the doomed approach of enumerating
# required features so we just list bunch of C++11 and C++14 features.
target_compile_features(SelfTest
PRIVATE
cxx_alignas
cxx_alignof
cxx_attributes
cxx_auto_type
cxx_constexpr
cxx_defaulted_functions
cxx_deleted_functions
cxx_final
cxx_lambdas
cxx_noexcept
cxx_override
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_trailing_return_types
cxx_unicode_literals
cxx_user_literals
cxx_variadic_macros
cxx_variable_templates
)
if (CATCH_ENABLE_COVERAGE)
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
find_package(codecov)
@ -249,6 +222,11 @@ set_tests_properties(TestsInFile::InvalidTestNames-1 PROPERTIES PASS_REGULAR_EXP
add_test(NAME TestsInFile::InvalidTestNames-2 COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/invalid-test-names.input")
set_tests_properties(TestsInFile::InvalidTestNames-2 PROPERTIES PASS_REGULAR_EXPRESSION "No tests ran")
add_test(NAME TagAlias COMMAND $<TARGET_FILE:SelfTest> [@tricky] --list-tests)
set_tests_properties(TagAlias PROPERTIES
PASS_REGULAR_EXPRESSION "[0-9]+ matching test cases"
FAIL_REGULAR_EXPRESSION "0 matching test cases"
)
if (CATCH_USE_VALGRIND)
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)