mirror of https://github.com/catchorg/Catch2.git
Don't build Catch2WithMain target by default for v2
The `Catch2WithMain` target was added experimentally for v2.13.4 to provide potentially better compilation (and link) times to users. However, having it compiled by default causes worse experience for people who do not use it, and for the v2 versions the single include distribution is still the main one. Closes #2142
This commit is contained in:
parent
b8b03da534
commit
cec35630fb
|
@ -25,12 +25,12 @@ option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
|
||||||
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
|
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
|
||||||
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
|
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
|
||||||
option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF)
|
option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF)
|
||||||
|
option(CATCH_BUILD_STATIC_LIBRARY "Builds static library from the main implementation. EXPERIMENTAL" OFF)
|
||||||
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
|
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
|
||||||
option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
|
option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
|
||||||
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
||||||
option(CATCH_INSTALL_HELPERS "Install contrib alongside library" ON)
|
option(CATCH_INSTALL_HELPERS "Install contrib alongside library" ON)
|
||||||
|
|
||||||
|
|
||||||
# define some folders
|
# define some folders
|
||||||
set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
|
set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
|
||||||
|
@ -104,6 +104,7 @@ endif()
|
||||||
add_library(Catch2::Catch2 ALIAS Catch2)
|
add_library(Catch2::Catch2 ALIAS Catch2)
|
||||||
|
|
||||||
# Hacky support for compiling the impl into a static lib
|
# Hacky support for compiling the impl into a static lib
|
||||||
|
if (CATCH_BUILD_STATIC_LIBRARY)
|
||||||
add_library(Catch2WithMain ${CMAKE_CURRENT_LIST_DIR}/src/catch_with_main.cpp)
|
add_library(Catch2WithMain ${CMAKE_CURRENT_LIST_DIR}/src/catch_with_main.cpp)
|
||||||
target_link_libraries(Catch2WithMain PUBLIC Catch2)
|
target_link_libraries(Catch2WithMain PUBLIC Catch2)
|
||||||
add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain)
|
add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain)
|
||||||
|
@ -113,6 +114,7 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_CXX_COMPILER_VERSI
|
||||||
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10))
|
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10))
|
||||||
target_compile_options(Catch2WithMain PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
target_compile_options(Catch2WithMain PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
||||||
endif()
|
endif()
|
||||||
|
endif(CATCH_BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
# Only perform the installation steps when Catch is not being used as
|
# Only perform the installation steps when Catch is not being used as
|
||||||
# a subproject via `add_subdirectory`, or the destinations will break,
|
# a subproject via `add_subdirectory`, or the destinations will break,
|
||||||
|
@ -128,11 +130,17 @@ if (NOT_SUBPROJECT)
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Workaround lack of generator expressions in install(TARGETS
|
||||||
|
set(InstallationTargets Catch2)
|
||||||
|
if (TARGET Catch2WithMain)
|
||||||
|
list(APPEND InstallationTargets Catch2WithMain)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# create and install an export set for catch target as Catch2::Catch
|
# create and install an export set for catch target as Catch2::Catch
|
||||||
install(
|
install(
|
||||||
TARGETS
|
TARGETS
|
||||||
Catch2 Catch2WithMain
|
${InstallationTargets}
|
||||||
EXPORT
|
EXPORT
|
||||||
Catch2Targets
|
Catch2Targets
|
||||||
DESTINATION
|
DESTINATION
|
||||||
|
|
Loading…
Reference in New Issue