43 set(oneValueArgs COMPONENT SUBDIRECTORY GROUP)
44 set(multiValueArgs
"")
45 cmake_parse_arguments(EXPORT_HEADER
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
47 # Remove prefix
for the destination directory
48 string(REGEX REPLACE
"^component-|^component_|^action-|^action_|^viewer-|^viewer_|^library_|^library-" "" EXPORT_HEADER_DESTINATION
"${EXPORT_HEADER_COMPONENT}")
51 # 1. Create the build-time directory tree
54 # define where to install files
55 set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/
include/${CAMITK_SHORT_VERSION_STRING})
58 if(EXPORT_HEADER_GROUP)
60 if (NOT EXISTS
"${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}")
61 add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
63 COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}
64 COMMENT
"Creating build-time group include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}"
68 set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_GROUP}/${EXPORT_HEADER_DESTINATION})
71 # check that the directory exists otherwise create it
72 if (NOT EXISTS
"${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}")
73 add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
75 COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}
76 COMMENT
"Creating build-time include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}"
81 # check the SUBDIRECTORY parameter
82 if(EXPORT_HEADER_SUBDIRECTORY)
83 set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_DESTINATION}/${EXPORT_HEADER_SUBDIRECTORY})
84 # create subdirectory
if it does not exists
85 if (NOT EXISTS
"${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}")
86 add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
88 COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}
89 COMMENT
"Creating build-time include subdir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}"
96 # 2. Install the file (build-time and install-time)
99 # at build time, copy the files to build directory include files when the target is built
100 foreach(HEADER ${EXPORT_HEADER_UNPARSED_ARGUMENTS})
101 # check
if file name is relative or not
102 set(FILE_TO_COPY ${HEADER})
104 # copy after build, only
if there was
a change
105 add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
107 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_COPY} ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}/
108 COMMENT
"Installing build-time header ${HEADER}"
109 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
114 # during installation, copy the files to install directory
115 install(FILES ${EXPORT_HEADER_UNPARSED_ARGUMENTS}
116 DESTINATION
include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
117 COMPONENT ${EXPORT_HEADER_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
export_headers()
export_headers is a macro that install header files at build and install time
Definition: ExportHeaders.h:40