Computer Assisted Medical Intervention Tool Kit  version 5.2
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  # Remove prefix for the destination directory
48  string(REGEX REPLACE "^component-|^component_|^action-|^action_|^viewer-|^viewer_|^library_|^library-" "" EXPORT_HEADER_DESTINATION "${EXPORT_HEADER_COMPONENT}")
49 
50  #
51  # 1. Create the build-time directory tree
52  #
53 
54  # define where to install files
55  set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${CAMITK_SHORT_VERSION_STRING})
56 
57  # Check group
58  if(EXPORT_HEADER_GROUP)
59  # check directory
60  if (NOT EXISTS "${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}")
61  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
62  POST_BUILD
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}"
65  VERBATIM
66  )
67  endif()
68  set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_GROUP}/${EXPORT_HEADER_DESTINATION})
69  endif()
70 
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}
74  POST_BUILD
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}"
77  VERBATIM
78  )
79  endif()
80 
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}
87  POST_BUILD
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}"
90  VERBATIM
91  )
92  endif()
93  endif()
94 
95  #
96  # 2. Install the file (build-time and install-time)
97  #
98 
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})
103 
104  # copy after build, only if there was a change
105  add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
106  POST_BUILD
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}
110  VERBATIM
111  )
112  endforeach()
113 
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}
118  )
119 
120 end(){)
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
#define a
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