Computer Assited Medical Intervention Tool Kit  version 4.1
CamiTKApplication.h
Go to the documentation of this file.
56 
57  # Instruct CMake to run moc automatically when needed.
58  set(CMAKE_AUTOMOC ON)
59 
60  #########################################################################
61  # #
62  # ARGUMENTS PARSING #
63  # #
64  # * Use a macro to create the CMAKE variables according to the #
65  # provided options as input. #
66  # #
67  #########################################################################
68 
69  get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} APPLICATION_NAME)
70 
71  set(options DISABLED NEEDS_ITK NEEDS_XSD NEEDS_XERCESC NEEDS_PYTHON)
72  set(oneValueArgs "")
73  set(multiValueArgs NEEDS_CEP_LIBRARIES NEEDS_TOOL NEEDS_COMPONENT_EXTENSION NEEDS_ACTION_EXTENSION DEFINES CXX_FLAGS ADDITIONAL_SOURCES CEP_NAME DESCRIPTION EXTERNAL_LIBRARIES INCLUDE_DIRECTORIES EXTRA_TRANSLATE_LANGUAGE)
74  cmake_parse_arguments(${APPLICATION_NAME_CMAKE} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
75 
76 
77 
78  #########################################################################
79  # #
80  # CREATE CMAKE VARIABLES #
81  # #
82  # * Create required and useful CMake variables for the macro #
83  # #
84  #########################################################################
85 
86  # CMAKE CACHE VARIABLE
87  # if it is the first cmake run, create the application variable with a correct initial value
88  if(NOT APPLICATION_${APPLICATION_NAME_CMAKE}_INTERNAL)
89  # add option to enable/disable this extension and set it to true by default
90  # Building the extension can be disabled by giving the argument DISABLED to the macro
91  # or by passing the flag -D${TYPE_EXTENSION_CMAKE}_${APPLICATION_NAME_CMAKE}_DISABLED:BOOL=TRUE
92  if(${APPLICATION_NAME_CMAKE}_DISABLED)
93  set(APPLICATION_${APPLICATION_NAME_CMAKE}_ENABLED FALSE)
94  else()
95  set(APPLICATION_${APPLICATION_NAME_CMAKE}_ENABLED TRUE)
96  endif()
97  set(APPLICATION_${APPLICATION_NAME_CMAKE} ${APPLICATION_${APPLICATION_NAME_CMAKE}_ENABLED} CACHE BOOL "Build application ${APPLICATION_NAME}")
98  set(APPLICATION_${APPLICATION_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable APPLICATION_${APPLICATION_NAME} already created?")
99  endif()
100 
101  # APPLICATION TARGET NAME
102  if (PACKAGING_NSIS)
103  # NSIS requires that cpack component names do not feature space or "-" characters
104  set(APPLICATION_TARGET_NAME application_${APPLICATION_NAME})
105  else()
106  set(APPLICATION_TARGET_NAME application-${APPLICATION_NAME})
107  endif()
108 
109 
110 
111  # if this extension is enabled, do everything needed
112  # otherwise... do nothing
113  if (APPLICATION_${APPLICATION_NAME_CMAKE})
114 
115  message(STATUS "Building application ${APPLICATION_NAME}")
116 
117 
118 
119  #########################################################################
120  # #
121  # INCLUDE DIRECTORIES #
122  # #
123  # * Include basic directories where to look header files #
124  # * Include also additional user provided directories #
125  # * These directories are used for compilation step #
126  # #
127  #########################################################################
128  # BASIC DIRECTORIES
129  include_directories(${CAMITK_INCLUDE_DIRECTORIES})
130  include_directories(${CMAKE_CURRENT_BINARY_DIR})
131  include_directories(${CMAKE_CURRENT_SOURCE_DIR})
132 
133  # USER INPUT DIRECTORIES
134  include_directories(${${APPLICATION_NAME_CMAKE}_INCLUDE_DIRECTORIES})
135 
136 
137 
138  #########################################################################
139  # #
140  # GATHER RESSOURCES #
141  # #
142  # * get all the headers (.h) and source files (.cpp) of the project #
143  # * create the needed Qt files (using moc and uic) #
144  # * On Windows, Visual Studio, group .moc and .ui files #
145  # in subdirectories #
146  # #
147  #########################################################################
148 
149  # get all headers, sources and do what is needed for Qt
150  # one need to do this just before the add_library so that all defines, include directories and link directories
151  # are set properly (gather_headers_and_sources include the call to Qt moc and uic)
152  gather_headers_and_sources(${APPLICATION_NAME})
153 
154 
155 
156  #########################################################################
157  # #
158  # TARGET COMPILATION DEFINITION #
159  # #
160  # * Additional sources files to consider at compilation (.cpp) #
161  # * CMake project target definition #
162  # #
163  #########################################################################
164  # EXTERNAL SOURCES
165  set(${APPLICATION_NAME}_SOURCES ${${APPLICATION_NAME}_SOURCES} ${${APPLICATION_NAME_CMAKE}_ADDITIONAL_SOURCES})
166 
167  # APPLE BUNDLE DEFINITIONS
168  if(APPLE)
169  set(MACOSX_BUNDLE_INFO_STRING "${APPLICATION_TARGET_NAME} ${CAMITK_SHORT_VERSION_STRING}")
170  set(MACOSX_BUNDLE_BUNDLE_VERSION "${APPLICATION_TARGET_NAME} ${CAMITK_SHORT_VERSION_STRING}")
171  set(MACOSX_BUNDLE_LONG_VERSION_STRING "${APPLICATION_TARGET_NAME} ${CAMITK_SHORT_VERSION_STRING}")
172  set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${CAMITK_SHORT_VERSION_STRING}")
173  set(MACOSX_BUNDLE_COPYRIGHT "Univ. Grenoble Alpes")
174  set(MACOSX_BUNDLE_ICON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/resources/camitk-${APPLICATION_NAME}.icns")
175  set(MACOSX_BUNDLE_BUNDLE_NAME "${APPLICATION_TARGET_NAME}")
176 
177  set(MACOSX_BUNDLE_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_TARGET_NAME}.app/Contents/Resources")
178  set(MACOSX_BUNDLE_ICON "${MACOSX_BUNDLE_ICON_FILE}")
179  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${MACOSX_BUNDLE_RESOURCES})
180  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MACOSX_BUNDLE_ICON} ${MACOSX_BUNDLE_RESOURCES})
181  endif()
182 
183 
184 
185  #########################################################################
186  # #
187  # ADDITIONAL KNOWN LIBRARY DEPENDENCIES #
188  # #
189  # * Look for specific library needed #
190  # * Specific libraries are specified as option with the #
191  # NEEDS_LIBRARY syntax (see macro syntax for more options) #
192  # * Backward compatibility : Warn user if using old NEEDS_TOOL syntax #
193  # #
194  #########################################################################
195 
196  # Looking for ITK
197  set(ITK_LIBRARIES "")
198  if(${APPLICATION_NAME_CMAKE}_NEEDS_ITK)
199  find_package(ITK REQUIRED)
200  if(ITK_FOUND)
201  include(${ITK_USE_FILE})
202  set(ITK_VERSION ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}) #ITK_VERSION is not always set
203  set(CAMITK_ITK_VERSION ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR})
204  message(STATUS "${APPLICATION_TARGET_NAME}: Found ITK version ${ITK_VERSION}")
205 
206  if ((${ITK_VERSION} VERSION_GREATER "4") AND (${ITK_VERSION} VERSION_LESS "5")) # ITK 4.9 on Windows, maybe a lesser version for Linux.
207  if(MSVC)
208  set(ITK_DIR ${ITK_DIR}/../..)
209  # Construct list of ITK libraries for linking = CAMITK_ITK_LIBRARIES
210  foreach(ITK_LIBRARY ${ITK_LIBRARIES})
211  string(SUBSTRING ${ITK_LIBRARY} 0 3 ${ITK_LIBRARY}_PREFIX)
212  # Some libraries have not the expected 'itk' prefix. Add it then
213  if((NOT ${${ITK_LIBRARY}_PREFIX} STREQUAL "itk") AND (NOT ${${ITK_LIBRARY}_PREFIX} STREQUAL "ITK"))
214  set(ITK_LIBRARY itk${ITK_LIBRARY})
215  endif()
216  set(CAMITK_ITK_LIBRARIES ${CAMITK_ITK_LIBRARIES} debug ${ITK_DIR}/${ITK_LIBRARY}-${CAMITK_ITK_VERSION}${CAMITK_DEBUG_POSTFIX}.lib optimized ${ITK_DIR}/${ITK_LIBRARY}-${CAMITK_ITK_VERSION}.lib)
217  endforeach()
218  elseif(UNIX)
219  set(CAMITK_ITK_LIBRARIES ${ITK_LIBRARIES})
220  elseif(APPLE)
221  message(WARNING "CamiTKExtension.cmake: ITK LIBRARY NOT SET FOR APPLE")
222  endif()
223  else()
224  message(FATAL_ERROR "Wrong version of ITK : ${ITK_VERSION}. Required is at least 4.x to 4.9")
225  endif()
226  else()
227  message(FATAL_ERROR "ITK not found but required for ${APPLICATION_TARGET_NAME}")
228  endif()
229  endif()
230 
231  # XERCES-C
232  set(XERCESC_LIBRARIES)
233  if(${APPLICATION_NAME_CMAKE}_NEEDS_XERCESC)
234  # XercesC is required
235  find_package(XercesC REQUIRED)
236  if (XERCESC_FOUND)
237  include_directories(${XERCESC_INCLUDE_DIR})
238  set(XERCESC_LIBRARIES ${XERCESC_LIBRARY})
239  else()
240  # most probably win32 or crosscompiling
241  message(FATAL_ERROR "${APPLICATION_NAME}: xerces-c required. Please provide Xerces-C path.")
242  endif()
243  endif()
244 
245  # XSD
246  if(${APPLICATION_NAME_CMAKE}_NEEDS_XSD)
247  # XercesC is required
248  find_package(XercesC REQUIRED)
249  if (XERCESC_FOUND)
250  include_directories(${XERCESC_INCLUDE_DIR})
251  set(XERCESC_LIBRARIES ${XERCESC_LIBRARY})
252  find_package(XSD REQUIRED)
253  include_directories(${XSD_INCLUDE_DIR})
254  else()
255  # most probably win32 or crosscompiling
256  message(FATAL_ERROR "${APPLICATION_NAME}: xerces-c required because of XSD cxx, please set XERCESC_INCLUDE_DIR")
257  endif()
258  endif()
259 
260  # PYTHON
261  set(PYTHON_LIBRARIES "")
262  if(${APPLICATION_NAME_CMAKE}_NEEDS_PYTHON)
263  message(STATUS "Python needed by ${APPLICATION_NAME}")
264  find_package(PythonLibs 2.7 REQUIRED)
265  if(PYTHONLIBS_FOUND)
266  message(STATUS "Python found (needed by ${APPLICATION_NAME})")
267  include_directories(${PYTHON_INCLUDE_DIRS})
268  # PYTHON_LIBRARIES is automatically and correctly set by find_package
269  else()
270  message(FATAL_ERROR "Python (2.7 or above) is required by ${APPLICATION_NAME} : please add your python installation dir to your PATH environment variable")
271  endif()
272  endif()
273 
274  # EXTERNAL LIBRARIES
275  set(EXTERNAL_LIBRARIES)
276  if(${APPLICATION_NAME_CMAKE}_EXTERNAL_LIBRARIES)
277  foreach(EXTERNAL_LIBRARY ${${APPLICATION_NAME_CMAKE}_EXTERNAL_LIBRARIES})
278  if (MSVC) # TODO We have to decide how to handle debug version of external libraries
279  set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES}
280  debug ${EXTERNAL_LIBRARY}${CAMITK_DEBUG_POSTFIX}.lib
281  optimized ${EXTERNAL_LIBRARY}.lib
282  )
283  else()
284  set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${EXTERNAL_LIBRARY})
285  endif()
286  endforeach()
287  endif()
288 
289 
290 
291  #########################################################################
292  # #
293  # LINK DIRECTORIES #
294  # #
295  # * Link directories are used to indicate the compiler where #
296  # to look for folder containing libraries to link with. #
297  # #
298  #########################################################################
299  # CAMITK BASIC LIB DIRECTORIES
300  link_directories(${CAMITK_LINK_DIRECTORIES})
301 
302 
303 
304  #########################################################################
305  # #
306  # TARGET COMPILATION DEFINITION #
307  # #
308  # * Additional sources files to consider at compilation (.cpp) #
309  # * CMake project target definition #
310  # #
311  #########################################################################
312  # CMAKE TARGET DEFINITION
313  add_executable(${APPLICATION_TARGET_NAME} ${${APPLICATION_NAME}_SOURCES})
314 
315 
316 
317  #########################################################################
318  # #
319  # QT LINKING LIBRARIES #
320  # #
321  # * Set at linking the Qt5 libraries #
322  # #
323  #########################################################################
324  qt5_use_modules(${APPLICATION_TARGET_NAME} ${CAMITK_QT_COMPONENTS})
325 
326 
327 
328  #########################################################################
329  # #
330  # CAMITK ACTION / COMPONENT / LIBRARIES DEPENDENCIES #
331  # #
332  # * Look for action / component / libraries dependencies #
333  # * Specific actions / components / libraries are specified as option #
334  # with the NEEDS_ACTION/COMPONENT_EXTENSION/CEP_LIBRARIES syntax #
335  # * Add dependencies to library-camitkcore and the testing #
336  # action/component if test are runned on it #
337  # #
338  #########################################################################
339 
340  # 1st CAMITKCORE LIBRARY DEPENDENCY
341  # add the target dependency (i.e., enable proper parallelization of the build process
342  # only if inside the sdk build
343  if(CAMITK_COMMUNITY_EDITION_BUILD)
344  add_dependencies(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
345  # add the dependency to the core automoc target
346  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${CAMITK_CORE_TARGET_LIB_NAME})
347  endif()
348 
349  # 2nd COMPONENTS DEPENDENCIES
350  if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
351  set(COMPONENTS_DEPENDENCY_LIST "") #use for generating the project.xml file
352  foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
353  # include directories from build, camitk (local or global install).
354  include_directories(${CAMITK_BUILD_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
355  include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
356  # file dependency
357  if (MSVC)
358  list(APPEND COMPONENT_EXTENSION_LIBRARIES
359  debug ${CAMITK_BUILD_PRIVATE_LIB_DIR}/components/${COMPONENT_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
360  optimized ${COMPONENT_NEEDED}
361  )
362  else()
363  list(APPEND COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_NEEDED})
364  endif()
365  # CMake / CDash dependencies
366  if(PACKAGING_NSIS)
367  add_dependencies(${APPLICATION_TARGET_NAME} component_${COMPONENT_NEEDED})
368  # add the dependency to the component automoc target
369  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS component_${COMPONENT_NEEDED})
370  else()
371  add_dependencies(${APPLICATION_TARGET_NAME} component-${COMPONENT_NEEDED})
372  list(APPEND COMPONENTS_DEPENDENCY_LIST component-${COMPONENT_NEEDED})
373  # add the dependency to the component automoc target
374  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS component-${COMPONENT_NEEDED})
375  endif()
376  endforeach()
377  endif()
378 
379  # 3rd ACTIONS DEPENDENCIES
380  if(${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
381  set(ACTIONS_DEPENDENCY_LIST "") #use for generating the project.xml file
382  foreach(ACTION_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
383  # include directories from build, camitk (local or global install).
384  include_directories(${CAMITK_BUILD_INCLUDE_DIR}/actions/${ACTION_NEEDED})
385  include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
386  # file dependency
387  if (MSVC)
388  list(APPEND ACTION_EXTENSION_LIBRARIES
389  debug ${CAMITK_BUILD_PRIVATE_LIB_DIR}/actions/${ACTION_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
390  optimized ${ACTION_NEEDED}
391  )
392  else()
393  list(APPEND ACTION_EXTENSION_LIBRARIES ${ACTION_NEEDED})
394  endif()
395  # CMake / CDash dependencies
396  if (PACKAGING_NSIS)
397  add_dependencies(${APPLICATION_TARGET_NAME} action_${ACTION_NEEDED})
398  # add the dependency to the action automoc target
399  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS action_${ACTION_NEEDED})
400  else()
401  add_dependencies(${APPLICATION_TARGET_NAME} action-${ACTION_NEEDED})
402  list(APPEND ACTIONS_DEPENDENCY_LIST action-${ACTION_NEEDED})
403  # add the dependency to the action automoc target
404  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS action-${ACTION_NEEDED})
405  endif()
406  endforeach()
407  endif()
408 
409  # 4th CEP LIBRARIES DEPENDENCIES
410  if(${APPLICATION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
411  set(CEP_LIBRARIES_DEPENDENCY_LIST "") #use for generating the project.xml file
412  foreach(CEP_LIBRARY_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
413  # include directories from build, camitk (local or global install).
414  include_directories(${CAMITK_BUILD_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED})
415  include_directories(${CAMITK_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED})
416  # file dependency
417  if (MSVC)
418  list(APPEND CEP_LIBRARIES debug ${CEP_LIBRARY_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
419  optimized ${CEP_LIBRARY_NEEDED}
420  )
421  else()
422  list(APPEND CEP_LIBRARIES ${CEP_LIBRARY_NEEDED})
423  endif()
424  # CMake / CDash dependencies
425  if (PACKAGING_NSIS)
426  add_dependencies(${APPLICATION_TARGET_NAME} library_${CEP_LIBRARY_NEEDED})
427  # add the dependency to the library automoc target
428  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS library_${CEP_LIBRARY_NEEDED})
429  else()
430  add_dependencies(${APPLICATION_TARGET_NAME} library-${CEP_LIBRARY_NEEDED})
431  list(APPEND CEP_LIBRARIES_DEPENDENCY_LIST library-${CEP_LIBRARY_NEEDED})
432  # add the dependency to the library automoc target
433  set_property(TARGET ${APPLICATION_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS library-${CEP_LIBRARY_NEEDED})
434  endif()
435  endforeach()
436  endif()
437 
438 
439 
440  #########################################################################
441  # #
442  # COMPILATION FLAG #
443  # #
444  # * Flags are options to give to the compiler #
445  # * Add user input flags #
446  # * Add platform specific flags #
447  # #
448  #########################################################################
449 
450  # USER INPUT COMPILER FLAG
451  if(${APPLICATION_NAME_CMAKE}_DEFINES)
452  foreach (FLAG ${${APPLICATION_NAME_CMAKE}_DEFINES})
453  add_definitions(-D${FLAG})
454  endforeach()
455  endif()
456 
457  # USER INPUT CUSTOM COMPILER FLAG
458  if(${APPLICATION_NAME_CMAKE}_CXX_FLAGS)
459  foreach (FLAG ${${APPLICATION_NAME_CMAKE}_CXX_FLAGS})
460  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
461  endforeach()
462  endif()
463 
464 
465 
466  #########################################################################
467  # #
468  # LINKING #
469  # #
470  # * Linking is the last stage of compilation #
471  # * Indicate what libraries to use for linking the target #
472  # #
473  #########################################################################
474  # LINKING LIBRARIES
475  target_link_libraries(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_LIBRARIES} ${CAMITK_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${CEP_LIBRARIES} ${XERCESC_LIBRARY} ${CAMITK_ITK_LIBRARIES} ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES})
476 
477 
478 
479  #########################################################################
480  # #
481  # OUTPUT #
482  # #
483  # * Define the output directory (location and name) #
484  # * Define the output name of the library #
485  # * Add ${CAMITK_DEBUG_POSTFIX} suffix to Debug MSVC built libraries #
486  # #
487  #########################################################################
488 
489  # OUTPUT NAME
490  if (MSVC)
491  set_target_properties(${APPLICATION_TARGET_NAME}
492  PROPERTIES OUTPUT_NAME camitk-${APPLICATION_NAME}
493  DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX}
494  )
495  else()
496  set_target_properties(${APPLICATION_TARGET_NAME}
497  PROPERTIES OUTPUT_NAME camitk-${APPLICATION_NAME}
498  )
499  endif()
500 
501  # OUTPUT DIRECTORY LOCATION
502  # always in bin folder
503  set_target_properties(${APPLICATION_TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR}
504  RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR}
505  RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR}
506  )
507 
508  #########################################################################
509  # #
510  # INSTALLATION #
511  # #
512  # * When installing the project, header files (.h) and test data are #
513  # copied into a installation folder to determine. #
514  # * Indicate in this section, where to install your project and which #
515  # files to copy into that folder (during local/global installation) #
516  # #
517  #########################################################################
518 
519  # FOLDER INSTALLATION
520  # Indicate where to install the application
521  install(TARGETS ${APPLICATION_TARGET_NAME}
522  RUNTIME DESTINATION bin
523  COMPONENT ${APPLICATION_TARGET_NAME}
524  )
525 
526 
527 
528  #########################################################################
529  # #
530  # CDASH SUBPROJECT DESCRIPTION #
531  # #
532  # * Update the XML descriton of the subprojects dependenicies #
533  # for CDash. #
534  # #
535  #########################################################################
536  # CDASH XML SUBPROJECTS DESCRIPTION UPDATE
537 # if(NOT ((APPLICATION_TARGET_NAME STREQUAL "application-testactions") OR (APPLICATION_TARGET_NAME STREQUAL "application-testcomponents")))
538  # We will add manually the CDash dependencies of the testing applications
539  # See CamiTKCDashPublishSubProject.cmake
540  camitk_register_subproject(APPLICATION ${APPLICATION_TARGET_NAME} DEPENDENCIES library-camitkcore ${COMPONENTS_DEPENDENCY_LIST} ${ACTIONS_DEPENDENCY_LIST} ${CEP_LIBRARIES_DEPENDENCY_LIST})
541 # endif()
542 
543  #####################################################################################
544  # #
545  # TRANSLATION #
546  # #
547  # * CAMITK_TRANSLATIONS contains the list of language to translate #
548  # the QString to. #
549  # #
550  # * Create the translate.pro file which contains 4 sections: #
551  # - HEADERS: list of .h/.hpp files to look for tr("") QString #
552  # - SOURCES: list of .cpp files to look for tr("") QString #
553  # - FORMS: list of .ui files to look for tr("") QString #
554  # - TRANSLATIONS: list of .ts files which use CAMITK_TRANSLATIONS #
555  # to define each .ts file #
556  # #
557  # * Execute lupdate program to update the .ts files with new QString #
558  # found. #
559  # #
560  # * Execute lrelease program to create .qm files (binary equivalent of #
561  # .ts files #
562  # #
563  # * Create translate.qrc which contains the list of .qm files. #
564  # * Create the flags.qrc file which contains the list of .png flags #
565  # images #
566  # #
567  #####################################################################################
568  if(CAMITK_TRANSLATE)
569  if(${APPLICATION_NAME_CMAKE}_EXTRA_TRANSLATE_LANGUAGE)
570  camitk_translate(EXTRA_LANGUAGE ${${APPLICATION_NAME_CMAKE}_EXTRA_TRANSLATE_LANGUAGE})
571  else()
572  camitk_translate()
573  endif()
574  endif()
575 
576 
577  #########################################################################
578  # #
579  # PACKAGING CATEGORIZATION #
580  # #
581  # * On Windows, when building a package (win32 installer), the #
582  # install shield wizard proposes you to select which component #
583  # to install. #
584  # * Each component to install has a short description following its #
585  # name to understand its role. #
586  # * This section deals with the categorization and the description #
587  # of the component in this installer. #
588  # #
589  #########################################################################
590 
591  # WINDOWS INSTALLER CATEGORIZATION
592  if(${APPLICATION_NAME_CMAKE}_CEP_NAME)
593  if (${APPLICATION_NAME_CMAKE}_CEP_NAME MATCHES "SDK")
594  # The default SDK extensions are categorized as "required" and are not "unselectable" by the user at installation time
595  cpack_add_component(${APPLICATION_TARGET_NAME}
596  DISPLAY_NAME ${APPLICATION_TARGET_NAME}
597  DESCRIPTION ${${APPLICATION_NAME_CMAKE}_DESCRIPTION}
598  REQUIRED
599  GROUP SDK
600  )
601 
602  else()
603  # Extension is selectable for installation in the wizard of the installer
604  cpack_add_component(${APPLICATION_TARGET_NAME}
605  DISPLAY_NAME ${APPLICATION_TARGET_NAME}
606  DESCRIPTION ${${APPLICATION_NAME_CMAKE}_DESCRIPTION}
607  GROUP ${${APPLICATION_NAME_CMAKE}_CEP_NAME}
608  )
609  endif()
610  else()
611  # Extension if not categorized for packaging presentation
612  cpack_add_component(${APPLICATION_TARGET_NAME}
613  DISPLAY_NAME ${APPLICATION_TARGET_NAME}
614  DESCRIPTION ${${APPLICATION_NAME_CMAKE}_DESCRIPTION}
615  )
616 
617  endif()
618 
619  # additional unix system files/resources
620  if(UNIX)
621  # Man page installation
622  set(${APPLICATION_NAME_CMAKE}_MAN_PAGE ${CMAKE_CURRENT_SOURCE_DIR}/resources/camitk-${APPLICATION_NAME}.1)
623  if (EXISTS ${${APPLICATION_NAME_CMAKE}_MAN_PAGE})
624  message(STATUS "Found man page for ${APPLICATION_TARGET_NAME}")
625  install(FILES ${${APPLICATION_NAME_CMAKE}_MAN_PAGE}
626  DESTINATION ${CAMITK_APPLICATION_MAN_INSTALL_DIR}
627  )
628  else()
629  # check if .in exists
630  if (EXISTS "${${APPLICATION_NAME_CMAKE}_MAN_PAGE}.in")
631  message(STATUS "Found man page configuration file for ${APPLICATION_TARGET_NAME}")
632  install(CODE "message(STATUS \"Updating ${APPLICATION_NAME} man page (version ${CAMITK_VERSION_MAJOR}.${CAMITK_VERSION_MINOR} as of ${CURRENT_DATE})\")")
633  # set variable in sub-cmake shell
634  install(CODE "set(APPLICATION_NAME ${APPLICATION_NAME})")
635  install(CODE "set(CURRENT_DATE ${CURRENT_DATE})")
636  install(CODE "set(CAMITK_VERSION_MAJOR ${CAMITK_VERSION_MAJOR})")
637  install(CODE "set(CAMITK_VERSION_MINOR ${CAMITK_VERSION_MINOR})")
638  # remove previous version
639  install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/camitk-${APPLICATION_NAME}.1)")
640  # configure current version
641  install(CODE "configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/camitk-${APPLICATION_NAME}.1.in ${CMAKE_CURRENT_BINARY_DIR}/camitk-${APPLICATION_NAME}.1 @ONLY)")
642  # install file
643  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/camitk-${APPLICATION_NAME}.1 DESTINATION ${CAMITK_APPLICATION_MAN_INSTALL_DIR})
644  endif()
645  endif()
646 
647  # Desktop file
648  set(${APPLICATION_NAME_CMAKE}_DESKTOP ${CMAKE_CURRENT_SOURCE_DIR}/resources/camitk-${APPLICATION_NAME}.desktop)
649  if (EXISTS ${${APPLICATION_NAME_CMAKE}_DESKTOP})
650  message(STATUS "Found desktop file for ${APPLICATION_TARGET_NAME}")
651  install(FILES ${${APPLICATION_NAME_CMAKE}_DESKTOP} DESTINATION ${CAMITK_APPLICATION_DESKTOP_INSTALL_DIR})
652  endif()
653 
654  # application pixmap
655  set(${APPLICATION_NAME_CMAKE}_PIXMAP ${CMAKE_CURRENT_SOURCE_DIR}/resources/camitk-${APPLICATION_NAME}.xpm)
656  if (EXISTS ${${APPLICATION_NAME_CMAKE}_PIXMAP})
657  message(STATUS "Found pixmap for ${APPLICATION_TARGET_NAME}")
658  install(FILES ${${APPLICATION_NAME_CMAKE}_PIXMAP} DESTINATION ${CAMITK_APPLICATION_PIXMAP_INSTALL_DIR})
659  endif()
660 
661  endif()
662 
663  endif() #APPLICATION_${APPLICATION_NAME_CMAKE}
664 
665 end(){)
A pseudo-namespace used to group CMake macros and functions.
camitk_application()
macro camitk_application simplify writing a CMakeLists.txt for CamiTK application extension ...
Definition: CamiTKApplication.h:55
Definition: itkImageToVTKImageFilter.h:39
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
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
#define a
gather_headers_and_sources()
macro gather_headers_and_sources find all headers, sources, including the qt ui, moc and resources an...
Definition: GatherHeadersAndSources.h:15
test result execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CAMITK_TEST_COMMAND_FILE} ${CAMITK_TEST_COMMAND_RESULT_FILE} ${CAMITK_TEST_COMMAND_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_COMMAND_FILE} ${CAMITK_TEST_PASS_FILE_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_RESULT_FILE}) file(WRITE $
Definition: CamiTKTestPassFile.h:21
static void include(QRect &r, const QRect &rect)
Definition: canvas_typed/qtcanvas.cpp:98