From 48db48207f16008bc9ae265ee0c7ee71c826fba1 Mon Sep 17 00:00:00 2001 From: Olivier Le Doeuff Date: Wed, 19 Oct 2022 16:26:58 +0200 Subject: [PATCH] Allow to install a target without `INCLUDE_DESTINATION` (#33) * Allow to install a target without `INCLUDE_DESTINATION` Concrete use case: A library like `gtest_main` that define a `main` symbols just need to be linked to. * All `INCLUDE_DIR` to be empty too --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2e27d1..868d490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,13 +165,15 @@ function(packageProject) set(PROJECT_INCLUDE_HEADER_PATTERN "*") endif() - install( - DIRECTORY ${PROJECT_INCLUDE_DIR}/ - DESTINATION ${PROJECT_INCLUDE_DESTINATION} - COMPONENT "${PROJECT_NAME}_Development" - FILES_MATCHING - PATTERN "${PROJECT_INCLUDE_HEADER_PATTERN}" - ) + if(PROJECT_INCLUDE_DESTINATION AND PROJECT_INCLUDE_DIR) + install( + DIRECTORY ${PROJECT_INCLUDE_DIR}/ + DESTINATION ${PROJECT_INCLUDE_DESTINATION} + COMPONENT "${PROJECT_NAME}_Development" + FILES_MATCHING + PATTERN "${PROJECT_INCLUDE_HEADER_PATTERN}" + ) + endif() set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}