From 581b11ca4828afd1734ba4bd95d245fbf988357c Mon Sep 17 00:00:00 2001 From: Daniel Nachbaur Date: Fri, 8 Apr 2016 17:06:56 +0200 Subject: [PATCH] Fix install in common_library() with subfolders --- CHANGES.md | 1 + CommonLibrary.cmake | 4 ++-- InstallFiles.cmake | 13 +++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 28a3535..d6ada71 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ * Add Sanitizer.cmake for gcc and clang runtime sanitizer support * Add CoverageGcovr.cmake for gcovr support * FindGLEW_MX considers GLEW_ROOT as environment and CMake variable +* Fix install in common_library() with subfolders * Ignore moc and qrc files in coverage report * Make CPACK_RESOURCE_FILE_LICENSE configurable * New CompilerIdentification.cmake, resulted from splitting Compiler.cmake diff --git a/CommonLibrary.cmake b/CommonLibrary.cmake index b85cd31..efabcfd 100644 --- a/CommonLibrary.cmake +++ b/CommonLibrary.cmake @@ -203,8 +203,8 @@ function(_common_library Name) endif() # install(TARGETS ... PUBLIC_HEADER ...) flattens directories - install_files(include/${INCLUDE_NAME} - FILES ${PUBLIC_HEADERS} COMPONENT dev) + install_files(include/${INCLUDE_NAME} FILES ${PUBLIC_HEADERS} + COMPONENT dev BASE ${OUTPUT_INCLUDE_DIR}/${INCLUDE_NAME}) endfunction() macro(generate_library_header NAME) diff --git a/InstallFiles.cmake b/InstallFiles.cmake index 1c19015..0692205 100644 --- a/InstallFiles.cmake +++ b/InstallFiles.cmake @@ -1,19 +1,24 @@ -# Copyright (c) 2012 Stefan.Eilemann@epfl.ch +# Copyright (c) 2012-2016 Stefan.Eilemann@epfl.ch -# Usage: install_files( FILES [COMPONENT ]) +# Usage: install_files( FILES [COMPONENT ] [BASE ]) # Installs files while preserving their relative directory. Files # with an absolute path are installed directly into prefix. include(CMakeParseArguments) function(INSTALL_FILES PREFIX) - set(ARG_NAMES COMPONENT) + set(ARG_NAMES COMPONENT BASE) set(ARGS_NAMES FILES) cmake_parse_arguments(THIS "" "${ARG_NAMES}" "${ARGS_NAMES}" ${ARGN}) foreach(FILE ${THIS_FILES}) if(IS_ABSOLUTE ${FILE}) - set(DIR) + if(THIS_BASE) + string(REPLACE ${THIS_BASE} "" DIR ${FILE}) + string(REGEX MATCH "(.*)[/\\]" DIR ${DIR}) + else() + set(DIR) + endif() else() string(REGEX MATCH "(.*)[/\\]" DIR ${FILE}) endif()