Computer Assisted Medical Intervention Tool Kit  version 5.2
 
Loading...
Searching...
No Matches
CamiTKInstallAllHeaders.h
Go to the documentation of this file.
1
46
47 set(options "")
48 set(oneValueArgs COMPONENT GROUP)
49 set(multiValueArgs "")
50 cmake_parse_arguments(CAMITK_INSTALL_ALL_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
51
52 #
53 # 1. Create the build-time directory tree
54 #
55
56 # The base include directories
57 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CMAKE_BINARY_DIR}/include/${CAMITK_SHORT_VERSION_STRING})
58
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}")
62
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}
68 POST_BUILD
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}"
71 VERBATIM
72 )
73 endif()
74 # Update base dirs
75 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP})
76 endif()
77
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}
81 POST_BUILD
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}"
84 VERBATIM
85 )
86 endif()
87 # Update base dirs
88 set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
89
90 #
91 # 2. Install the file (build-time and install-time)
92 #
93
94 # get the list of headers
95 file(GLOB_RECURSE HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ *.h)
96
97 # Build time installation
98 foreach(HEADER ${HEADERS})
99 # Get the subdirectory name of the header
100 string(REGEX MATCH ".*/" SUBDIR ${HEADER})
101
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}
106 POST_BUILD
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}"
109 VERBATIM
110 )
111 set(CAMITK_INSTALL_ALL_HEADERS_${SUBDIR} "CREATED") # To avoid creating the directory another time
112 endif()
113
114 # Install header at build time
115 add_custom_command( TARGET ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
116 POST_BUILD
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}"
119 VERBATIM
120 )
121 endforeach()
122
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})
127
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}
131 )
132 endforeach()
133end(){)
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