48 set(oneValueArgs COMPONENT GROUP)
49 set(multiValueArgs
"")
50 cmake_parse_arguments(CAMITK_INSTALL_ALL_HEADERS
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
53 # 1. Create the build-time directory tree
57 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CMAKE_BINARY_DIR}/
include/${CAMITK_SHORT_VERSION_STRING})
59 # Get action, component or library name without its prefix
60 set(CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
61 string(REGEX REPLACE
"^component-|^component_|^action-|^action_|^viewer-|^viewer_|^library_|^library-" "" CAMITK_INSTALL_ALL_HEADERS_COMPONENT
"${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}")
63 # Check group directory
64 if(CAMITK_INSTALL_ALL_HEADERS_GROUP)
65 # Create group directory if not already existing
66 if (NOT EXISTS
"${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP}" AND NOT CAMITK_INSTALL_ALL_HEADERS_DIRECTORY)
67 add_custom_command( TARGET ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
69 COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP}
70 COMMENT
"Creating build-time group include dir ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP}"
75 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP})
78 # Create component directory if not already existing
79 if (NOT EXISTS
"${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}" AND NOT CAMITK_INSTALL_ALL_HEADERS_DIRECTORY)
80 add_custom_command( TARGET ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
82 COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}
83 COMMENT
"Creating build-time include dir ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}"
88 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
91 # 2. Install the file (build-time and install-time)
94 # get the list of headers
95 file(GLOB_RECURSE HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ *.h)
97 # Build time installation
98 foreach(HEADER ${HEADERS})
99 # Get the subdirectory name of the header
100 string(REGEX MATCH
".*/" SUBDIR ${HEADER})
102 # Create subdirectory
if not already existing
103 if(NOT EXISTS
"${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${SUBDIR}" AND NOT CAMITK_INSTALL_ALL_HEADERS_${SUBDIR})
104 # Create directory at build time
105 add_custom_command( TARGET ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
107 COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${SUBDIR}
108 COMMENT
"Creating build-time include dir ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}/${SUBDIR}"
111 set(CAMITK_INSTALL_ALL_HEADERS_${SUBDIR}
"CREATED") # To avoid creating the directory another time
114 # Install header at build time
115 add_custom_command( TARGET ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
117 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER} ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${SUBDIR}
118 COMMENT
"Installing build-time header ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}/${HEADER}"
123 # Install time, copy all the .h directories structure
124 foreach(HEADER ${HEADERS})
125 # Get the subdirectory name of the header
126 string(REGEX MATCH
".*/" SUBDIR ${HEADER})
128 install(FILES ${HEADER}
129 DESTINATION
include/${CAMITK_SHORT_VERSION_STRING}/${CAMITK_INSTALL_ALL_HEADERS_GROUP}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}/${SUBDIR}
130 COMPONENT ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
iwyu out CACHE PATH Output filename for include what you use set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE}) if(NOT EXISTS $
Definition: CamiTKIncludeWhatYouUse.h:22
static void include(QRect &r, const QRect &rect)
Definition: canvas_typed/qtcanvas.cpp:98
camitk_install_all_headers()
camitk_install_all_headers is a macro that install all header files of a project at build and install...
Definition: CamiTKInstallAllHeaders.h:45