Computer Assited Medical Intervention Tool Kit  version 4.0
CamiTKExtensionProject.h
Go to the documentation of this file.
29 
30  get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} CEP_DIR_NAME)
31 
32  parse_arguments(${CEP_DIR_NAME}_CMAKE
33  "NEEDS_CEPDEFAULT_APPLICATIONDESCRIPTIONCONTACTNAMELICENSE" # possible lists
34  "ENABLED" # possible options
35  ${ARGN}
36  )
37 
38  # get the proper name
39  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_NAME)
40  set(CEP_NAME ${CEP_DIR_NAME})
41  else()
42  set(CEP_NAME ${${CEP_DIR_NAME}_CMAKE_NAME})
43  endif()
44  string(TOUPPER ${CEP_NAME} CEP_NAME_CMAKE)
45 
46  # if it is the first cmake run, create the internal variable with a correct initial value (false is default)
47  if(NOT CEP_${CEP_NAME_CMAKE}_INTERNAL)
48  # add option to enable/disable this CEP
49  if(${CEP_DIR_NAME}_CMAKE_ENABLED)
50  set(CEP_${CEP_NAME_CMAKE}_ENABLED TRUE)
51  else()
52  set(CEP_${CEP_NAME_CMAKE}_ENABLED FALSE)
53  endif()
54  set(CEP_${CEP_NAME_CMAKE} ${CEP_${CEP_NAME_CMAKE}_ENABLED} CACHE BOOL "Build CEP ${CEP_NAME}")
55  set(CEP_${CEP_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable CAMITK_CEP_${CEP_NAME_CMAKE} already created?")
56  endif()
57 
58  if(CEP_${CEP_NAME_CMAKE})
59  message(STATUS "Building CEP ${CEP_NAME}")
60 
61  project(${CEP_NAME})
62 
63  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_CONTACT)
64  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}\"")
65  endif()
66 
67  if(NOT DEFINED ${CEP_DIR_NAME}_CMAKE_LICENSE)
68  set(${CEP_NAME}_LICENSE "LGPL-v3")
69  else()
70  set(${CEP_NAME}_LICENSE ${${CEP_DIR_NAME}_CMAKE_LICENSE})
71  endif()
72 
73  # update module path
74  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
75 
76  # init cep sub project
78 
79  # packaging macro must be called before parsing extensions CMakeList files.
80  camitk_cep_packaging(NAME ${CEP_NAME}
81  CONTACT ${${CEP_DIR_NAME}_CMAKE_CONTACT}
82  DESCRIPTION ${${CEP_DIR_NAME}_CMAKE_DESCRIPTION}
83  LICENSE ${${CEP_NAME}_LICENSE}
84  )
85 
86  # add all subprojects
87  camitk_add_subdirectory(libraries)
88  camitk_add_subdirectory(components)
91  camitk_add_subdirectory(applications)
92 
93  # CEP packaging (only works if this is a stand-alone CEP
95 
96  # For Microsoft Visual C++, sets the default application for the "ALL_BUILD" project
97  # (i.e. launches imp when we you click on "Debug" or "Start Without Debugging" button on Visual)
98  # In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
99  # to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
100  # is there a specifi application to run by default
101  if(${CEP_NAME_CMAKE}_CMAKE_DEFAULT_APPLICATION)
102  set(CEP_DEFAULT_APPLICATION ${${CEP_NAME_CMAKE}_CMAKE_DEFAULT_APPLICATION})
103  else()
104  set(CEP_DEFAULT_APPLICATION "camitk-imp")
105  endif()
106 
107  # simply target name so that the custom target name does not contains any space
108  string(REGEX REPLACE " " "" SIMPLIFIED_CEP_NAME ${CEP_NAME})
109 
110  # if this is a single CEP, provides the installation facilities
111  # otherwise, just add include(CamiTKInstall) to get the installation facilities
112  if (NOT CAMITK_EXTENSION_PROJECT_SET)
113  #-- camitk_global_install == install in CAMITK_DIR
114  if (CAMITK_SDK_BUILD)
115  # if the SDK is currently being build => install in CMAKE_INSTALL_PREFIX
116  add_custom_target(${SIMPLIFIED_CEP_NAME}_global_install
117  # Second cmake to install
118  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
119  COMMENT "Global Installation in ${CMAKE_INSTALL_PREFIX}"
120  )
121 
122  else()
123  # this is called from a normal CEP build => install in CAMITK_DIR
124  add_custom_target(${SIMPLIFIED_CEP_NAME}_global_install
125  # First cmake to redefine install prefix
126  COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH=${CAMITK_DIR} ${CMAKE_BINARY_DIR}
127  # Second cmake to install
128  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
129  COMMENT "Global Installation in ${CAMITK_DIR}"
130  )
131  endif()
132 
133  # camitk_local_install == install in User Config directory
134  add_custom_target(${SIMPLIFIED_CEP_NAME}_local_install
135  # First cmake to redefine install prefix
136  COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH=${CAMITK_USER_DIR} ${CMAKE_BINARY_DIR}
137  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install --config ${CMAKE_CFG_INTDIR}
138  COMMENT "Local Installation in ${CAMITK_USER_DIR}"
139  )
140  endif()
141 
142  # Add an update_translate targete to configure all the .qrc files for the different extensions of this CEP on demand.
143  # .qrc files consider up to date .ts resources files for translation
144  add_custom_target(${SIMPLIFIED_CEP_NAME}_updatetranslate
145  COMMAND ${CMAKE_COMMAND} -E echo "Updating translation for ${CEP_NAME}"
146  COMMAND ${CMAKE_COMMAND} -DCAMITK_TRANSLATE=TRUE ${CMAKE_BINARY_DIR}
147  COMMAND ${CMAKE_COMMAND} -DCAMITK_TRANSLATE=FALSE ${CMAKE_BINARY_DIR}
148  COMMAND ${CMAKE_COMMAND} -E echo "Translation updated for ${CEP_NAME}"
149  )
150 
151 
152  endif()
153 end(){)
camitk_sub_project_validate()
macro camitk_sub_project_validate validates the xml_subprojects variable by ending its xml tag i...
Definition: CamiTKSubProjectValidate.h:15
get_directory_name()
macro get_directory_name set the variable VariableName to the name of the last directory of FullPathD...
Definition: GetDirectoryName.h:14
parse_arguments()
macro parse_arguments is a fork from CMakeMacroParseArguments see http://www.cmake.org/Wiki/CMakeMacroParseArguments for more information
Definition: ParseArguments.h:13
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:28
set(CAMITK_TEST_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/command) set(CAMITK_TEST_COMMAND_RESULT_FILE $
This CMake file run a command and put the output in a given file.
Definition: CamiTKTestPassFile.h:11
camitk_add_subdirectory()
camitk_add_subdirectory is a utility macro that add a source subdirectory only if: ...
Definition: CamiTKAddSubDirectory.h:19
camitk_extension_project()
macro camitk_extension_project creates an optional (disabled by default) CEP (CamiTK Extension Projec...
Definition: CamiTKExtensionProject.h:28
static void include(QRect &r, const QRect &rect)
Definition: canvas_typed/qtcanvas.cpp:98
camitk_sub_project_init()
MACRO camitk_sub_project_init initializes the xml_subprojects variable to gather CamiTK subprojects...
Definition: CamiTKSubProjectInit.h:10