Computer Assited Medical Intervention Tool Kit  version 4.1
ExportHeaders.h
Go to the documentation of this file.
41 
42  set(options "")
43  set(oneValueArgs COMPONENT SUBDIRECTORY GROUP)
44  set(multiValueArgs "")
45  cmake_parse_arguments(EXPORT_HEADER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
46 
47  # special case for components: remove prefix for the destination directory
48  string(REGEX REPLACE "^component-|^component_|^action-|^action_|^library_|^library-" "" EXPORT_HEADER_DESTINATION "${EXPORT_HEADER_COMPONENT}")
49 
50  # define where to install files
51  set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${CAMITK_SHORT_VERSION_STRING})
52  set(EXPORT_HEADER_INSTALL_ROOT ${CMAKE_INSTALL_PREFIX})
53 
54  # Check group
55  if(EXPORT_HEADER_GROUP)
56  # check directory
57  if (NOT EXISTS "${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}")
58  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
59  POST_BUILD
60  COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}
61  COMMENT "Creating build-time group include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}"
62  VERBATIM
63  )
64  endif()
65  set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_GROUP}/${EXPORT_HEADER_DESTINATION})
66  endif()
67 
68  # check that the directory exists otherwise create it
69  if (NOT EXISTS "${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}")
70  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
71  POST_BUILD
72  COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}
73  COMMENT "Creating build-time include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}"
74  VERBATIM
75  )
76  endif()
77 
78  # check the SUBDIRECTORY parameter
79  if(EXPORT_HEADER_SUBDIRECTORY)
80  set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_DESTINATION}/${EXPORT_HEADER_SUBDIRECTORY})
81  # create subdirectory if it does not exists
82  if (NOT EXISTS "${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}")
83  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
84  POST_BUILD
85  COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}
86  COMMENT "Creating build-time include subdir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}"
87  VERBATIM
88  )
89  endif()
90  endif()
91 
92 
93  # at build time, copy the files to build directory include files when the target is built
94  foreach(HEADER ${EXPORT_HEADER_UNPARSED_ARGUMENTS})
95  # check if file name is relative or not
96  set(FILE_TO_COPY ${HEADER})
97 
98  # copy after build, only if there was a change
99  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
100  POST_BUILD
101  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_COPY} ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}/
102  COMMENT "Installing build-time header ${HEADER}"
103  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
104  VERBATIM
105  )
106  endforeach()
107 
108  # during installation, copy the files to install directory
109  install(FILES ${EXPORT_HEADER_UNPARSED_ARGUMENTS}
110  # DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
111  DESTINATION include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
112  COMPONENT ${EXPORT_HEADER_COMPONENT}
113  )
114 
115 end(){)
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
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
export_headers()
export_headers is a macro that install header files at build and install time
Definition: ExportHeaders.h:40
#define a
static void include(QRect &r, const QRect &rect)
Definition: canvas_typed/qtcanvas.cpp:98