From 27dca5d9c973d63567158ad1267c4f8311a45577 Mon Sep 17 00:00:00 2001 From: David Seifert Date: Tue, 30 Jan 2018 11:13:53 +0100 Subject: [PATCH] Install Catch only when run as standalone project --- CMakeLists.txt | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65f1927b..0d3e0866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0) # detect if Catch is being bundled, # disable testsuite in that case if(NOT DEFINED PROJECT_NAME) - set(NOT_SUBPROJECT ON) + set(CATCH_NOT_SUBPROJECT ON) endif() project(Catch2 LANGUAGES CXX VERSION 2.1.1) @@ -304,7 +304,7 @@ endif() include(CTest) -if (BUILD_TESTING AND NOT_SUBPROJECT) +if (BUILD_TESTING AND CATCH_NOT_SUBPROJECT) add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS}) target_include_directories(SelfTest PRIVATE ${HEADER_DIR}) @@ -386,20 +386,19 @@ if(CATCH_BUILD_EXAMPLES) add_subdirectory(examples) endif() -install(DIRECTORY "single_include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/catch") +if(DEFINED CATCH_NOT_SUBPROJECT) + install(DIRECTORY "single_include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/catch") + install(DIRECTORY docs/ DESTINATION "${CMAKE_INSTALL_DOCDIR}") -install(DIRECTORY docs/ DESTINATION "${CMAKE_INSTALL_DOCDIR}") - -## Provide some pkg-config integration -# Don't bother on Windows -if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows) - - set(PKGCONFIG_INSTALL_DIR - "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" - CACHE PATH "Path where catch.pc is installed" - ) - - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/catch.pc.in ${CMAKE_CURRENT_BINARY_DIR}/catch.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR}) + ## Provide some pkg-config integration + # Don't bother on Windows + if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows) + set(PKGCONFIG_INSTALL_DIR + "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" + CACHE PATH "Path where catch.pc is installed" + ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/catch.pc.in ${CMAKE_CURRENT_BINARY_DIR}/catch.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR}) + endif() endif()