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