2018-06-11 10:48:10 +02:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2013-08-05 12:40:33 +02:00
|
|
|
|
2018-01-18 00:01:27 +01:00
|
|
|
# detect if Catch is being bundled,
|
|
|
|
# disable testsuite in that case
|
|
|
|
if(NOT DEFINED PROJECT_NAME)
|
|
|
|
set(NOT_SUBPROJECT ON)
|
|
|
|
endif()
|
|
|
|
|
2018-07-23 10:12:15 +02:00
|
|
|
project(Catch2 LANGUAGES CXX VERSION 2.3.0)
|
2013-08-05 12:40:33 +02:00
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
# Provide path for scripts
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
|
|
|
|
|
2018-01-18 00:01:27 +01:00
|
|
|
include(GNUInstallDirs)
|
2018-06-11 10:48:10 +02:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
include(CTest)
|
2018-01-18 00:01:27 +01:00
|
|
|
|
2018-01-18 19:20:08 +01:00
|
|
|
option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
|
2018-07-22 18:01:42 +02:00
|
|
|
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
|
2018-01-18 19:20:08 +01:00
|
|
|
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
|
2018-08-28 09:44:47 +02:00
|
|
|
option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF)
|
2018-01-18 19:20:08 +01:00
|
|
|
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
|
|
|
|
option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
|
2018-06-19 07:14:09 +02:00
|
|
|
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
2018-06-23 19:04:22 +02:00
|
|
|
option(CATCH_INSTALL_HELPERS "Install contrib alongside library" ON)
|
|
|
|
|
2017-11-05 12:46:04 +01:00
|
|
|
|
2017-01-09 17:27:06 +01:00
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2013-08-05 12:40:33 +02:00
|
|
|
# define some folders
|
2017-01-06 17:19:20 +01:00
|
|
|
set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
2013-08-05 12:40:33 +02:00
|
|
|
set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
|
2017-01-14 21:55:37 +01:00
|
|
|
set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark)
|
2017-01-06 17:59:18 +01:00
|
|
|
set(HEADER_DIR ${CATCH_DIR}/include)
|
|
|
|
|
2017-05-11 13:00:03 +02:00
|
|
|
if(USE_WMAIN)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup")
|
|
|
|
endif()
|
|
|
|
|
2018-08-18 22:06:25 +02:00
|
|
|
find_package(PythonInterp)
|
2018-07-22 18:01:42 +02:00
|
|
|
if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT)
|
2018-08-18 22:06:25 +02:00
|
|
|
if (NOT PYTHONINTERP_FOUND)
|
|
|
|
message(FATAL_ERROR "Python not found, but required for tests")
|
|
|
|
endif()
|
2018-06-11 10:48:10 +02:00
|
|
|
add_subdirectory(projects)
|
|
|
|
endif()
|
2017-01-31 20:22:45 +01:00
|
|
|
|
2018-01-18 19:20:08 +01:00
|
|
|
if(CATCH_BUILD_EXAMPLES)
|
2017-11-05 09:15:22 +01:00
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
|
|
|
|
2018-08-28 09:44:47 +02:00
|
|
|
if(CATCH_BUILD_EXTRA_TESTS)
|
|
|
|
add_subdirectory(projects/ExtraTests)
|
|
|
|
endif()
|
2018-01-29 23:56:43 +01:00
|
|
|
|
|
|
|
# add catch as a 'linkable' target
|
2018-06-11 10:48:10 +02:00
|
|
|
add_library(Catch2 INTERFACE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# depend on some obvious c++11 features so the dependency is transitively added dependents
|
|
|
|
target_compile_features(Catch2
|
|
|
|
INTERFACE
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(Catch2
|
|
|
|
INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/single_include>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
|
|
)
|
2018-01-29 23:56:43 +01:00
|
|
|
|
|
|
|
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
|
2018-06-11 10:48:10 +02:00
|
|
|
add_library(Catch2::Catch2 ALIAS Catch2)
|
2018-01-29 23:56:43 +01:00
|
|
|
|
|
|
|
set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
|
|
|
|
|
2018-06-24 10:11:14 +02:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
configure_package_config_file(
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake
|
|
|
|
INSTALL_DESTINATION
|
|
|
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-01-29 23:56:43 +01:00
|
|
|
# create and install an export set for catch target as Catch2::Catch
|
2018-06-11 10:48:10 +02:00
|
|
|
install(
|
|
|
|
TARGETS
|
|
|
|
Catch2
|
|
|
|
EXPORT
|
2018-06-24 10:11:14 +02:00
|
|
|
Catch2Targets
|
|
|
|
DESTINATION
|
|
|
|
${CMAKE_INSTALL_LIBDIR}
|
2018-06-11 10:48:10 +02:00
|
|
|
)
|
|
|
|
|
2018-06-24 10:11:14 +02:00
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
install(
|
|
|
|
EXPORT
|
2018-06-24 10:11:14 +02:00
|
|
|
Catch2Targets
|
2018-06-11 10:48:10 +02:00
|
|
|
NAMESPACE
|
|
|
|
Catch2::
|
|
|
|
DESTINATION
|
|
|
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
|
|
|
)
|
2018-01-29 23:56:43 +01:00
|
|
|
|
2018-02-09 10:50:14 +01:00
|
|
|
write_basic_package_version_file(
|
2018-06-11 10:48:10 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
|
|
|
COMPATIBILITY
|
|
|
|
SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
DIRECTORY
|
|
|
|
"single_include/"
|
|
|
|
DESTINATION
|
|
|
|
"${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES
|
2018-06-24 10:11:14 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake"
|
2018-06-11 10:48:10 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake"
|
|
|
|
DESTINATION
|
|
|
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Install documentation
|
2018-06-19 07:14:09 +02:00
|
|
|
if(CATCH_INSTALL_DOCS)
|
|
|
|
install(
|
|
|
|
DIRECTORY
|
|
|
|
docs/
|
|
|
|
DESTINATION
|
|
|
|
"${CMAKE_INSTALL_DOCDIR}"
|
|
|
|
)
|
|
|
|
endif()
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2018-06-23 19:04:22 +02:00
|
|
|
if(CATCH_INSTALL_HELPERS)
|
|
|
|
# Install CMake scripts
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"contrib/ParseAndAddCatchTests.cmake"
|
|
|
|
"contrib/Catch.cmake"
|
|
|
|
"contrib/CatchAddTests.cmake"
|
|
|
|
DESTINATION
|
|
|
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Install debugger helpers
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"contrib/gdbinit"
|
|
|
|
"contrib/lldbinit"
|
|
|
|
DESTINATION
|
|
|
|
${CMAKE_INSTALL_DATAROOTDIR}/Catch2
|
|
|
|
)
|
|
|
|
endif()
|
2018-01-29 23:56:43 +01:00
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
## Provide some pkg-config integration
|
|
|
|
set(PKGCONFIG_INSTALL_DIR
|
|
|
|
"${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig"
|
|
|
|
CACHE PATH "Path where catch2.pc is installed"
|
|
|
|
)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/catch2.pc
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/catch2.pc"
|
|
|
|
DESTINATION
|
|
|
|
${PKGCONFIG_INSTALL_DIR}
|
|
|
|
)
|