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