Computer Assisted Medical Intervention Tool Kit  version 5.2
CamiTKExtensionProject.h
Go to the documentation of this file.
35 
36  get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} CEP_DIR_NAME)
37 
38  set(options ENABLED ENABLE_TESTING ENABLE_TEST_COVERAGE)
39  set(oneValueArgs DEFAULT_APPLICATION DESCRIPTION CONTACT NAME LICENSE)
40  set(multiValueArgs NEEDS_CEP)
41  cmake_parse_arguments(${CEP_DIR_NAME}_CMAKE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
42 
43  # get the proper name
44  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_NAME)
45  set(CEP_NAME ${CEP_DIR_NAME})
46  else()
47  set(CEP_NAME ${${CEP_DIR_NAME}_CMAKE_NAME})
48  endif()
49  string(TOUPPER ${CEP_NAME} CEP_NAME_CMAKE)
50 
51  # if it is the first cmake run, create the internal variable with a correct initial value (false is default)
52  if(NOT CEP_${CEP_NAME_CMAKE}_INTERNAL)
53  # add option to enable/disable this CEP
54  if(${CEP_DIR_NAME}_CMAKE_ENABLED)
55  set(CEP_${CEP_NAME_CMAKE}_ENABLED TRUE)
56  else()
57  set(CEP_${CEP_NAME_CMAKE}_ENABLED FALSE)
58  endif()
59  set(CEP_${CEP_NAME_CMAKE} ${CEP_${CEP_NAME_CMAKE}_ENABLED} CACHE BOOL "Build CEP ${CEP_NAME}")
60  set(CEP_${CEP_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable CAMITK_CEP_${CEP_NAME_CMAKE} already created?")
61  endif()
62 
63  if(CEP_${CEP_NAME_CMAKE})
64  message(STATUS "Building CEP ${CEP_NAME}")
65 
66  if (${CEP_DIR_NAME}_CMAKE_ENABLE_TESTING OR ${CEP_DIR_NAME}_CMAKE_ENABLE_TEST_COVERAGE)
67  include(CTest)
68  enable_testing()
69  message(STATUS "Testing framework enabled")
70  endif()
71 
72  if (${CEP_DIR_NAME}_CMAKE_ENABLE_TEST_COVERAGE)
73  set(${CEP_DIR_NAME}_CMAKE_ENABLE_TESTING ON)
74  # to create specific target: camitk-ce-test-coverage
75  option(CAMITK_TEST_COVERAGE "Code coverage" ON)
76  include(macros/camitk/test/CamiTKTestCoverage)
77  endif()
78 
79  project(${CEP_NAME})
80 
81  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_CONTACT)
82  message(FATAL_ERROR "In camitk_extension_project(...) for CEP \"${CEP_NAME}\": CONTACT argument is mandatory\n Should give the email address of the person(s) to contact for more information about the CEP \"${CEP_NAME}\"")
83  endif()
84 
85  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_LICENSE)
86  set(${CEP_NAME}_LICENSE "LGPL-v3")
87  else()
88  set(${CEP_NAME}_LICENSE ${${CEP_DIR_NAME}_CMAKE_LICENSE})
89  endif()
90 
91  # update module path
92  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
93 
94  # init cep sub project
96 
97  # packaging macro must be called before parsing extensions CMakeList files.
98  camitk_cep_packaging(NAME ${CEP_NAME}
99  CONTACT ${${CEP_DIR_NAME}_CMAKE_CONTACT}
100  DESCRIPTION ${${CEP_DIR_NAME}_CMAKE_DESCRIPTION}
101  LICENSE ${${CEP_NAME}_LICENSE}
102  )
103 
104  # add all subprojects
105  camitk_add_subdirectory(libraries)
106  camitk_add_subdirectory(components)
107  camitk_add_subdirectory(actions)
108  camitk_add_subdirectory(viewers)
109  camitk_add_subdirectory(applications)
110 
111  # CEP packaging (only works if this is a stand-alone CEP
113 
114  # For Microsoft Visual C++, sets the default application for the "ALL_BUILD" project
115  # (i.e. launches imp when we you click on "Debug" or "Start Without Debugging" button on Visual)
116  # In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
117  # to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
118  # is there a specifi application to run by default
119  if(${CEP_NAME_CMAKE}_CMAKE_DEFAULT_APPLICATION)
120  set(CEP_DEFAULT_APPLICATION ${${CEP_NAME_CMAKE}_CMAKE_DEFAULT_APPLICATION})
121  else()
122  set(CEP_DEFAULT_APPLICATION "camitk-imp")
123  endif()
124 
125  # simply target name so that the custom target name does not contains any space
126  string(REGEX REPLACE " " "" ESCAPED_PROJECT_NAME "${CEP_NAME}")
127  string(TOLOWER "${ESCAPED_PROJECT_NAME}" SIMPLIFIED_CEP_NAME)
128 
129  # if this is a single CEP, provides the installation facilities
130  # otherwise, just add include(CamiTKInstall) to get the installation facilities
131  if (NOT CAMITK_EXTENSION_PROJECT_SET)
132  #-- camitk-global-install == install in CAMITK_DIR
133  if (CAMITK_COMMUNITY_EDITION_BUILD)
134  # if the SDK is currently being build => install in CMAKE_INSTALL_PREFIX
135  add_custom_target(camitk-${SIMPLIFIED_CEP_NAME}-global-install
136  # Second cmake to install
137  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
138  COMMENT "Global Installation in ${CMAKE_INSTALL_PREFIX}"
139  )
140 
141  else()
142  # this is called from a normal CEP build => install in CAMITK_DIR
143  add_custom_target(camitk-${SIMPLIFIED_CEP_NAME}-global-install
144  # First cmake to redefine install prefix
145  COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH=${CAMITK_DIR} ${CMAKE_BINARY_DIR}
146  # Second cmake to install
147  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
148  COMMENT "Global Installation in ${CAMITK_DIR}"
149  )
150  endif()
151 
152  # camitk-local-install == install in User Config directory
153  add_custom_target(camitk-${SIMPLIFIED_CEP_NAME}-local-install
154  # First cmake to redefine install prefix
155  COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH=${CAMITK_USER_DIR} ${CMAKE_BINARY_DIR}
156  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
157  COMMENT "Local Installation in ${CAMITK_USER_DIR}"
158  )
159 
160  # Add an update-translate target to configure all the .qrc files for the different extensions of this CEP on demand.
161  # .qrc files consider up to date .ts resources files for translation
162  add_custom_target(camitk-${SIMPLIFIED_CEP_NAME}-update-translate
163  COMMAND ${CMAKE_COMMAND} -E echo "Updating translation for ${CEP_NAME}"
164  COMMAND ${CMAKE_COMMAND} -DCAMITK_TRANSLATE=TRUE ${CMAKE_BINARY_DIR}
165  COMMAND ${CMAKE_COMMAND} -DCAMITK_TRANSLATE=FALSE ${CMAKE_BINARY_DIR}
166  COMMAND ${CMAKE_COMMAND} -E echo "Translation updated for ${CEP_NAME}"
167  COMMENT "Translation updated for ${CEP_NAME}"
168  )
169 
170  # Add a package source target using unified names
171  add_custom_target(camitk-${SIMPLIFIED_CEP_NAME}-package-source
172  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package_source --config ${CMAKE_CFG_INTDIR}
173  COMMENT "Building package source ${CEP_NAME}"
174  )
175 
176  endif()
177 
178  endif()
179 end(){)
if(${CMAKE_VERSION} VERSION_GREATER "3.3" OR ${CMAKE_VERSION} VERSION_EQUAL "3.3") option(CAMITK_INCLUDE_WHAT_YOU_USE "Enable the header analysis on you code
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
camitk_init_manifest_data()
MACRO camitk_init_manifest_data initializes the global variables that will gather all the information...
Definition: CamiTKInitManifestData.h:51
camitk_write_manifest_data()
macro camitk_write_manifest_data validates the xml_subprojects variable by ending its xml tag i....
Definition: CamiTKWriteManifestData.h:15
camitk_cep_packaging()
CamiTK cep packaging allows you to build a package from a CEP If README and COPYRIGHT files exists at...
Definition: CamiTKCEPPackaging.h:29
camitk_extension_project()
macro camitk_extension_project creates an optional (disabled by default) CEP (CamiTK Extension Projec...
Definition: CamiTKExtensionProject.h:34
camitk_add_subdirectory()
camitk_add_subdirectory is a utility macro that add a source subdirectory only if:
Definition: CamiTKAddSubDirectory.h:18
get_directory_name()
macro get_directory_name set the variable VariableName to the name of the last directory of FullPathD...
Definition: GetDirectoryName.h:14
Definition: Action.cpp:36