Disable installation step when Catch is used as a subproject

This is because otherwise the installations paths provided via
GNUInstallDirs become messed up and parts of the installation
package will end up in the wrong place.

Also it doesn't make much sense to force dependees to also install
our header alongside them.

Closes #1373
This commit is contained in:
Martin Hořeňovský 2018-08-31 11:40:55 +02:00
parent 90663b2e75
commit 0646e0283c

View File

@ -91,9 +91,12 @@ target_include_directories(Catch2
# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project # provide a namespaced alias for clients to 'link' against if catch is included as a sub-project
add_library(Catch2::Catch2 ALIAS Catch2) add_library(Catch2::Catch2 ALIAS Catch2)
# Only perform the installation steps when Catch is not being used as
# a subproject via `add_subdirectory`, or the destinations will break,
# see https://github.com/catchorg/Catch2/issues/1373
if (NOT_SUBPROJECT)
set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2")
include(CMakePackageConfigHelpers)
configure_package_config_file( configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake
@ -190,3 +193,5 @@ install(
DESTINATION DESTINATION
${PKGCONFIG_INSTALL_DIR} ${PKGCONFIG_INSTALL_DIR}
) )
endif(NOT_SUBPROJECT)