Computer Assited Medical Intervention Tool Kit  version 5.0
CamiTKExtension.h
Go to the documentation of this file.
1
116
117
118 # Instruct CMake to run moc automatically when needed.
119 set(CMAKE_AUTOMOC ON)
120
121
122 #########################################################################
123 # #
124 # ARGUMENTS PARSING #
125 # #
126 # * Use a macro to create the CMAKE variables according to the #
127 # provided options as input. #
128 # #
129 #########################################################################
130
131 get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} EXTENSION_NAME)
132
133 set(options ACTION_EXTENSION COMPONENT_EXTENSION VIEWER_EXTENSION DISABLED NEEDS_XERCESC NEEDS_ITK NEEDS_LIBXML2 NEEDS_XSD NEEDS_OPENCV NEEDS_IGSTK INSTALL_ALL_HEADERS NEEDS_GDCM ENABLE_AUTO_TEST ENABLE_INTEGRATION_TEST)
134 set(oneValueArgs TARGET_NAME CEP_NAME DESCRIPTION AUTO_TEST_LEVEL)
135 set(multiValueArgs NEEDS_TOOL NEEDS_CEP_LIBRARIES NEEDS_COMPONENT_EXTENSION NEEDS_ACTION_EXTENSION NEEDS_VIEWER_EXTENSION INCLUDE_DIRECTORIES EXTERNAL_LIBRARIES HEADERS_TO_INSTALL DEFINES CXX_FLAGS EXTERNAL_SOURCES EXTRA_TRANSLATE_LANGUAGE TEST_FILES)
136 cmake_parse_arguments(${EXTENSION_NAME_CMAKE} "${options}" "${oneValueArgs}"
137 "${multiValueArgs}" ${ARGN} )
138
139 #########################################################################
140 # #
141 # CREATE CMAKE VARIABLES #
142 # #
143 # * Create required and useful CMake variables for the macro #
144 # #
145 #########################################################################
146
147 # TYPE EXTENSION : ACTION or COMPONENT or VIEWER
148 if (${EXTENSION_NAME_CMAKE}_ACTION_EXTENSION)
149 set(TYPE_EXTENSION "action")
150 string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
151 elseif(${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION)
152 set(TYPE_EXTENSION "component")
153 string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
154 elseif(${EXTENSION_NAME_CMAKE}_VIEWER_EXTENSION)
155 set(TYPE_EXTENSION "viewer")
156 string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
157 endif()
158
159 # CMAKE CACHE VARIABLE
160 # if it is the first cmake run, create the extension variable with a correct initial value
161 if(NOT ${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_INTERNAL)
162 # add option to enable/disable this extension and set it to true by default
163 # Building the extension can be disabled by giving the argument DISABLED to the macro
164 # or by passing the flag -D${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_DISABLED:BOOL=TRUE
165 if(${EXTENSION_NAME_CMAKE}_DISABLED)
166 set(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_ENABLED FALSE)
167 else()
168 set(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_ENABLED TRUE)
169 endif()
170 set(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE} ${${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_ENABLED} CACHE BOOL "Build extension ${EXTENSION_NAME}")
171 set(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable ${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME} already created?")
172 endif()
173
174 # if this extension is enabled, do everything needed
175 # otherwise... do nothing
176 if (${${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}})
177
178 # TARGET NAME
179 # The target name is composed of the following: [action / component]-name
180 # * action / component is the type of extension as prefix
181 # * name is deduced from the input folder containing the calling CMakeLists.txt file of the extension.
182 if (${EXTENSION_NAME_CMAKE}_TARGET_NAME)
183 set(${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME ${${EXTENSION_NAME_CMAKE}_TARGET_NAME})
184 else()
185 set(${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME ${EXTENSION_NAME})
186 endif()
187 # replace "-" by "_" if the extension is being packaged with NSIS, the program to create a Windows installer.
188 if (PACKAGING_NSIS)
189 # NSIS requires that cpack component names do not feature space or "-" characters
190 set(${TYPE_EXTENSION_CMAKE}_TARGET_NAME ${TYPE_EXTENSION}_${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME})
191 else()
192 set(${TYPE_EXTENSION_CMAKE}_TARGET_NAME ${TYPE_EXTENSION}-${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME})
193 endif()
194
195 message(STATUS "Building extension ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}")
196
197 # EXTENSION_PLUGIN_FILE
198 # determine the extension full file name depending on the plateform
199 set(EXTENSION_PLUGIN_FILE "${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s")
200 if (MSVC)
201 set(EXTENSION_PLUGIN_FILE ${EXTENSION_PLUGIN_FILE}/${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll)
202 elseif(APPLE)
203 set(EXTENSION_PLUGIN_FILE ${EXTENSION_PLUGIN_FILE}/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dylib)
204 else()
205 # Must be Linux
206 set(EXTENSION_PLUGIN_FILE ${EXTENSION_PLUGIN_FILE}/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.so)
207 endif()
208
209 #########################################################################
210 # #
211 # INCLUDE DIRECTORIES #
212 # #
213 # * Include basic directories where to look header files #
214 # * Include also additional user provided directories #
215 # * These directories are used for compilation step #
216 # #
217 #########################################################################
218 # BASIC DIRECTORIES
219
220 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
221 include_directories(${CMAKE_CURRENT_BINARY_DIR})
222 include_directories(${CAMITK_INCLUDE_DIRECTORIES})
223
224 # USER INPUT DIRECTORIES
225 include_directories(${${EXTENSION_NAME_CMAKE}_INCLUDE_DIRECTORIES})
226
227
228
229 #########################################################################
230 # #
231 # GATHER RESOURCES #
232 # #
233 # * Get all the headers (.h) and source files (.cpp) of the project #
234 # * Create the needed Qt files (using moc and uic) #
235 # * On Windows, Visual Studio, group .moc and .ui files #
236 # in subdirectories #
237 # #
238 #########################################################################
239
240 # get all headers, sources and do what is needed for Qt
241 # one need to do this just before the add_library so that all defines, include directories and link directories
242 # are set properly (gather_headers_and_sources include the call to Qt moc and uic)
243 gather_headers_and_sources(${EXTENSION_NAME_CMAKE})
244
245
246
247 #########################################################################
248 # #
249 # ADDITIONAL KNOWN EXTERNAL LIBRARY DEPENDENCIES #
250 # #
251 # * Look for specific library needed #
252 # * Specific libraries are specified as option with the #
253 # NEEDS_LIBRARY syntax (see macro syntax for more options) #
254 # * Backward compatibility : Warn user if using old NEEDS_TOOL syntax #
255 # #
256 #########################################################################
257
258 # Looking for ITK
259 set(ITK_LIBRARIES "")
260 if(${EXTENSION_NAME_CMAKE}_NEEDS_ITK)
261 find_package(ITK REQUIRED PATHS /usr/lib/InsightToolkit)
262 if(ITK_FOUND)
263 include(${ITK_USE_FILE})
264 set(ITK_VERSION ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}) #ITK_VERSION is not always set
265 set(CAMITK_ITK_VERSION ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR})
266 message(STATUS "${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}: Found ITK version ${ITK_VERSION}")
267
268 if ((${ITK_VERSION} VERSION_GREATER "4")) # ITK 4.9 on Windows, maybe a lesser version for Linux.
269 if(MSVC)
270 set(ITK_DIR ${ITK_DIR}/../..)
271 # Construct list of ITK libraries for linking = CAMITK_ITK_LIBRARIES
272 foreach(ITK_LIBRARY ${ITK_LIBRARIES})
273 string(SUBSTRING ${ITK_LIBRARY} 0 3 ${ITK_LIBRARY}_PREFIX)
274 # Some libraries have not the expected 'itk' prefix. Add it then
275 if((NOT ${${ITK_LIBRARY}_PREFIX} STREQUAL "itk") AND (NOT ${${ITK_LIBRARY}_PREFIX} STREQUAL "ITK"))
276 set(ITK_LIBRARY itk${ITK_LIBRARY})
277 endif()
278 list(APPEND CAMITK_ITK_LIBRARIES debug ${ITK_DIR}/${ITK_LIBRARY}-${CAMITK_ITK_VERSION}${CAMITK_DEBUG_POSTFIX}.lib optimized ${ITK_DIR}/${ITK_LIBRARY}-${CAMITK_ITK_VERSION}.lib)
279 endforeach()
280 elseif(UNIX)
281 set(CAMITK_ITK_LIBRARIES ${ITK_LIBRARIES})
282 elseif(APPLE)
283 message(WARNING "CamiTKExtension.cmake: ITK LIBRARY NOT SET FOR APPLE")
284 endif()
285 else()
286 message(FATAL_ERROR "Wrong version of ITK : ${ITK_VERSION}. Required is at least 4.x")
287 endif()
288 else()
289 message(FATAL_ERROR "ITK not found but required for ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}")
290 endif()
291 endif()
292
293 # LIBXML2
294 set(LIBXML2_LIBRARY "")
295 if(${EXTENSION_NAME_CMAKE}_NEEDS_LIBXML2)
296 # LibXml2 is required
297 find_package(Xml2)
298 if (LIBXML2_FOUND)
299 add_definitions(${LIBXML2_DEFINITIONS})
300 include_directories(${LIBXML2_INCLUDE_DIR})
301 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES})
302 else()
303 # most probably win32 or crosscompiling
304 message(STATUS "${EXTENSION_NAME}: libxml2 required")
305 endif()
306 endif()
307
308 # OPENCV
309 set(OpenCV_LIBRARIES "")
310 if(${EXTENSION_NAME_CMAKE}_NEEDS_OPENCV)
311 # OpenCV is required
312 find_package( OpenCV REQUIRED )
313 else ( )
314 set(OpenCV_LIBRARIES "")
315 endif()
316
317 # IGSTK
318 set(IGSTK_LIBRARIES "")
319 if(${EXTENSION_NAME_CMAKE}_NEEDS_IGSTK)
320 find_package(IGSTK REQUIRED)
321 include(${IGSTK_USE_FILE})
322 else()
323 set(IGSTK_LIBRARIES "")
324 endif()
325
326 # XERCES-C
327 set(XERCESC_LIBRARIES)
328 if(${EXTENSION_NAME_CMAKE}_NEEDS_XERCESC)
329 # XercesC is required
330 if (NOT XERCESC_LIBRARY)
331 find_package(XercesC REQUIRED)
332 endif()
333 if (XERCESC_FOUND)
334 include_directories(${XERCESC_INCLUDE_DIR})
335 set(XERCESC_LIBRARIES ${XERCESC_LIBRARY})
336 else()
337 # most probably win32 or crosscompiling
338 message(FATAL_ERROR "${EXTENSION_NAME}: xerces-c required. Please provide Xerces-C path.")
339 endif()
340 endif()
341
342 # XSD
343 if(${EXTENSION_NAME_CMAKE}_NEEDS_XSD)
344 # XercesC is required
345 if (NOT XERCESC_LIBRARY)
346 find_package(XercesC REQUIRED)
347 endif()
348 find_package(XercesC REQUIRED)
349 if (XERCESC_FOUND)
350 include_directories(${XERCESC_INCLUDE_DIR})
351 set(XERCESC_LIBRARIES ${XERCESC_LIBRARY})
352 find_package(XSD REQUIRED)
353 include_directories(${XSD_INCLUDE_DIR})
354 else()
355 # most probably win32 or crosscompiling
356 message(FATAL_ERROR "${EXTENSION_NAME}: xerces-c required because of XSD cxx, please set XERCESC_INCLUDE_DIR")
357 endif()
358 endif()
359
360 # GDCM 2.2.x
361 set(GDCM_LIBRARIES)
362 if(${EXTENSION_NAME_CMAKE}_NEEDS_GDCM)
363 if(NOT GDCM_FOUND)
364 # Look for GDCM library only if not found (for instance, ITK has already search for it)
365 # Calling find_package(GDCM ..) more than once creates CMake errors.
366 find_package(GDCM 2.0 REQUIRED)
367 endif()
368 if(GDCM_FOUND)
369 include(${GDCM_USE_FILE})
370 if (MSVC)
371 # List all available GDCM library files
372 file(GLOB GDCM_LIB_FILES
373 LIST_DIRECTORIES false
374 "${GDCM_DIR}/../*${CAMITK_DEBUG_POSTFIX}.lib"
375
376 )
377 unset(GDCM_LIBRARIES)
378 foreach(GDCM_LIB_FILE ${GDCM_LIB_FILES})
379 # Get the actual name of the library
380 string(REGEX REPLACE "^.*/(.*)${CAMITK_DEBUG_POSTFIX}.lib"
381 "\\1" GDCM_LIB_FILE_OPTIMIZED
382 "${GDCM_LIB_FILE}")
383 # Add both debug and optimized version
384 set(GDCM_LIBRARIES ${GDCM_LIBRARIES} debug ${GDCM_LIB_FILE}
385 optimized ${GDCM_LIB_FILE_OPTIMIZED})
386 endforeach()
387
388 else()
389 set(GDCM_LIBRARIES gdcmCommon gdcmDICT gdcmDSED gdcmMEXD gdcmMSFF vtkgdcm)
390 endif()
391 else()
392 message(FATAL_ERROR "${EXTENSION_NAME}: GDCM 2.x or above library required. Please install GDCM.")
393 endif()
394 endif()
395
396 # EXTERNAL LIBRARIES
397 set(EXTERNAL_LIBRARIES)
398 if(${EXTENSION_NAME_CMAKE}_EXTERNAL_LIBRARIES)
399 foreach(EXTERNAL_LIBRARY ${${EXTENSION_NAME_CMAKE}_EXTERNAL_LIBRARIES})
400 if (MSVC)
401 list(APPEND EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES}
402 debug ${EXTERNAL_LIBRARY}${CAMITK_DEBUG_POSTFIX}.lib
403 optimized ${EXTERNAL_LIBRARY}.lib
404 )
405 else()
406 list(APPEND EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARY})
407 endif()
408 endforeach()
409 endif()
410
411
412
413 #########################################################################
414 # #
415 # LINK DIRECTORIES #
416 # #
417 # * Link directories are used to indicate the compiler where #
418 # to look for folder containing libraries to link with. #
419 # * Must be done BEFORE creating the CMake target with add_library #
420 # #
421 #########################################################################
422
423 # CAMITK BASIC LIB DIRECTORIES
424 link_directories(${CAMITK_LINK_DIRECTORIES})
425
426
427
428 #########################################################################
429 # #
430 # TARGET COMPILATION DEFINITION #
431 # #
432 # * Additional sources files to consider at compilation (.cpp) #
433 # * CMake project target definition #
434 # #
435 #########################################################################
436 # EXTERNAL SOURCES
437 set(${EXTENSION_NAME_CMAKE}_SOURCES ${${EXTENSION_NAME_CMAKE}_SOURCES} ${${EXTENSION_NAME_CMAKE}_EXTERNAL_SOURCES})
438
439 # CMAKE TARGET DEFINITION
440 add_library(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} SHARED ${${EXTENSION_NAME_CMAKE}_SOURCES})
441
442
443
444 #########################################################################
445 # #
446 # QT LINKING LIBRARIES #
447 # #
448 # * Set at linking the Qt5 libraries #
449 # #
450 #########################################################################
451 target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_QT_LIBRARIES})
452
453
454 #########################################################################
455 # #
456 # CAMITK ACTION / COMPONENT / LIBRARIES DEPENDENCIES #
457 # #
458 # * Look for action / component / libraries dependencies #
459 # * Specific actions / components / libraries are specified as option #
460 # with the NEEDS_ACTION/COMPONENT_EXTENSION/CEP_LIBRARIES syntax #
461 # * Add dependencies to library-camitkcore and the testing #
462 # action/component if test are runned on it #
463 # #
464 #########################################################################
465
466 # 1st CAMITKCORE LIBRARY DEPENDENCY
467 # add_dependencies(..) is only needed to enable parallel build during SDK build
468 # but generates an error for external CEP, where this target does not
469 # exists.
470 # Using target_link_libraries(..) is enough to link the extension to the CamiTK core library
471 if(CAMITK_COMMUNITY_EDITION_BUILD)
472 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
473 # add the dependency to the core automoc target only if inside a SDK build
474 set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${CAMITK_CORE_TARGET_LIB_NAME})
475 endif()
476
477
478 # 2nd COMPONENTS DEPENDENCIES
479 if(${EXTENSION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
480 set(COMPONENTS_DEPENDENCY_LIST "") #use for generating the project.xml file
481 foreach(COMPONENT_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
482 # include directories from build, camitk (local or global install).
483 include_directories(${CAMITK_BUILD_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
484 include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
485 # file dependency
486 if (MSVC)
487 list(APPEND COMPONENT_EXTENSION_LIBRARIES debug ${CAMITK_BUILD_PRIVATE_LIB_DIR}/components/${COMPONENT_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
488 optimized ${COMPONENT_NEEDED}
489 )
490 else()
491 list(APPEND COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_NEEDED})
492 endif()
493 # CMake / CDash dependencies
494 if(PACKAGING_NSIS)
495 # if the target is installed in the CAMITK_INCLUDE_DIR, import it before adding the dependencies
496 if(EXISTS ${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED} AND NOT TARGET component_${COMPONENT_NEEDED})
497 message(STATUS "Importing target component_${COMPONENT_NEEDED}")
498 add_library(component_${COMPONENT_NEEDED} INTERFACE IMPORTED)
499 endif()
500 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} component_${COMPONENT_NEEDED})
501 else()
502 if(EXISTS ${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED} AND NOT TARGET component-${COMPONENT_NEEDED})
503 message(STATUS "Importing target component-${COMPONENT_NEEDED}")
504 add_library(component-${COMPONENT_NEEDED} INTERFACE IMPORTED)
505 endif()
506 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} component-${COMPONENT_NEEDED})
507 list(APPEND COMPONENTS_DEPENDENCY_LIST component-${COMPONENT_NEEDED})
508 endif()
509 endforeach()
510 endif()
511
512 # 3rd ACTIONS DEPENDENCIES
513 if(${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
514 set(ACTIONS_DEPENDENCY_LIST "") #use for generating the project.xml file
515 foreach(ACTION_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
516 # include directories from build, camitk (local or global install).
517 include_directories(${CAMITK_BUILD_INCLUDE_DIR}/actions/${ACTION_NEEDED})
518 include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
519 # file dependency
520 if (MSVC)
521 list(APPEND ACTION_EXTENSION_LIBRARIES debug ${CAMITK_BUILD_PRIVATE_LIB_DIR}/actions/${ACTION_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
522 optimized ${ACTION_NEEDED}
523 )
524 else()
525 list(APPEND ACTION_EXTENSION_LIBRARIES ${ACTION_NEEDED})
526 endif()
527 # CMake / CDash dependencies
528 if (PACKAGING_NSIS)
529 # if the target is installed in the CAMITK_INCLUDE_DIR, import it before adding the dependencies
530 if(EXISTS ${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED} AND NOT TARGET action_${ACTION_NEEDED})
531 message(STATUS "Importing target action_${ACTION_NEEDED}")
532 add_library(action_${ACTION_NEEDED} INTERFACE IMPORTED)
533 endif()
534 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} action_${ACTION_NEEDED})
535 else()
536 # if the target is installed in the CAMITK_INCLUDE_DIR, import it before adding the dependencies
537 if(EXISTS ${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED} AND NOT TARGET action-${ACTION_NEEDED})
538 message(STATUS "Importing target action-${ACTION_NEEDED}")
539 add_library(action-${ACTION_NEEDED} INTERFACE IMPORTED)
540 endif()
541 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} action-${ACTION_NEEDED})
542 list(APPEND ACTIONS_DEPENDENCY_LIST action-${ACTION_NEEDED})
543 endif()
544 endforeach()
545 endif()
546
547 # 4th VIEWERS DEPENDENCIES
548 if(${EXTENSION_NAME_CMAKE}_NEEDS_VIEWER_EXTENSION)
549 set(VIEWERS_DEPENDENCY_LIST "") #use for generating the project.xml file
550 foreach(VIEWER_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_VIEWER_EXTENSION})
551 # include directories from build, camitk (local or global install).
552 include_directories(${CAMITK_BUILD_INCLUDE_DIR}/viewers/${VIEWER_NEEDED})
553 include_directories(${CAMITK_INCLUDE_DIR}/viewers/${VIEWER_NEEDED})
554 # file dependency
555 if (MSVC)
556 list(APPEND VIEWER_EXTENSION_LIBRARIES debug ${CAMITK_BUILD_PRIVATE_LIB_DIR}/viewers/${VIEWER_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
557 optimized ${VIEWER_NEEDED}
558 )
559 else()
560 list(APPEND VIEWER_EXTENSION_LIBRARIES ${VIEWER_NEEDED})
561 endif()
562 # CMake / CDash dependencies
563 if (PACKAGING_NSIS)
564 if(EXISTS ${CAMITK_INCLUDE_DIR}/viewers/${VIEWER_NEEDED} AND NOT TARGET viewer_${VIEWER_NEEDED})
565 message(STATUS "Importing target viewer_${VIEWER_NEEDED}")
566 add_library(viewer_${VIEWER_NEEDED} INTERFACE IMPORTED)
567 endif()
568 # now add the dependency
569 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} viewer_${VIEWER_NEEDED})
570 else()
571 # if the target is installed in the CAMITK_INCLUDE_DIR, import it before adding the dependencies
572 if(EXISTS ${CAMITK_INCLUDE_DIR}/viewers/${VIEWER_NEEDED} AND NOT TARGET viewer-${VIEWER_NEEDED})
573 message(STATUS "Importing target viewer-${VIEWER_NEEDED}")
574 add_library(viewer-${VIEWER_NEEDED} INTERFACE IMPORTED)
575 endif()
576 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} viewer-${VIEWER_NEEDED})
577 list(APPEND VIEWERS_DEPENDENCY_LIST viewer-${VIEWER_NEEDED})
578 endif()
579 endforeach()
580 endif()
581
582 # 5th CEP LIBRARIES DEPENDENCIES
583 if(${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
584 set(CEP_LIBRARIES_DEPENDENCY_LIST "") #use for generating the project.xml file
585 foreach(CEP_LIBRARY_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
586 # include directories from build, camitk (local or global install).
587 include_directories(${CAMITK_BUILD_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED})
588 include_directories(${CAMITK_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED})
589 # file dependency
590 if (MSVC)
591 list(APPEND CEP_LIBRARIES debug ${CEP_LIBRARY_NEEDED}${CAMITK_DEBUG_POSTFIX}.lib
592 optimized ${CEP_LIBRARY_NEEDED}
593 )
594 else()
595 list(APPEND CEP_LIBRARIES ${CEP_LIBRARY_NEEDED})
596 endif()
597 # CMake / CDash dependencies
598 if (PACKAGING_NSIS)
599 if (EXISTS ${CAMITK_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED} AND NOT TARGET library_${CEP_LIBRARY_NEEDED})
600 message(STATUS "Importing target library_${CEP_LIBRARY_NEEDED}")
601 add_library(library_${CEP_LIBRARY_NEEDED} INTERFACE IMPORTED)
602 endif()
603 # now add the dependency
604 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library_${CEP_LIBRARY_NEEDED})
605 # add the dependency to the component automoc target only if compiling SDK
606 #if(CAMITK_COMMUNITY_EDITION_BUILD)
607 #set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS library_${CEP_LIBRARY_NEEDED})
608 #endif()
609 else()
610 # if the target is installed in the CAMITK_INCLUDE_DIR, import it before adding the dependencies
611 if (EXISTS ${CAMITK_INCLUDE_DIR}/libraries/${CEP_LIBRARY_NEEDED} AND NOT TARGET library-${CEP_LIBRARY_NEEDED})
612 message(STATUS "Importing target library-${CEP_LIBRARY_NEEDED}")
613 add_library(library-${CEP_LIBRARY_NEEDED} INTERFACE IMPORTED)
614 endif()
615 add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library-${CEP_LIBRARY_NEEDED})
616 list(APPEND CEP_LIBRARIES_DEPENDENCY_LIST ${CEP_LIBRARY_NEEDED} library-${CEP_LIBRARY_NEEDED})
617 ## add the dependency to the component automoc target only if compiling SDK
618 #if(CAMITK_COMMUNITY_EDITION_BUILD)
619 #set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS library-${CEP_LIBRARY_NEEDED})
620 #endif()
621 endif()
622 endforeach()
623 endif()
624
625 #########################################################################
626 # #
627 # COMPILATION FLAG #
628 # #
629 # * Flags are options to give to the compiler #
630 # * Add user input flags #
631 # * Add platform specific flags #
632 # #
633 #########################################################################
634
635 # USER INPUT DEFINES COMPILER FLAG
636 if(${EXTENSION_NAME_CMAKE}_DEFINES)
637 foreach (FLAG ${${EXTENSION_NAME_CMAKE}_DEFINES})
638 add_definitions(-D${FLAG})
639 endforeach()
640 endif()
641
642 # USER INPUT CUSTOM COMPILER FLAG
643 if(${EXTENSION_NAME_CMAKE}_CXX_FLAGS)
644 foreach (FLAG ${${EXTENSION_NAME_CMAKE}_CXX_FLAGS})
645 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
646 endforeach()
647 endif()
648
649 # PLATFORM SPECIFIC COMPILER FLAG
650 # 64bits and other platform with relocation needs -fPIC
651 include(TestCXXAcceptsFlag)
652 check_cxx_accepts_flag(-fPIC FPIC_FLAG_ACCEPTED)
653 # no need to add -fPIC on mingw, otherwise it generates a warning: -fPIC ignored for target (all code is position independent) [enabled by default]
654 # msvc is also accepting the flag, but then produce warning D9002 : ignoring unknown option '-fPIC' cl
655 if(FPIC_FLAG_ACCEPTED AND NOT WIN32)
656 set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} APPEND PROPERTY COMPILE_FLAGS -fPIC)
657 endif()
658
659
660
661 #########################################################################
662 # #
663 # LINKING #
664 # #
665 # * Linking is the last stage of compilation #
666 # * Indicate what libraries to use for linking the target #
667 # #
668 #########################################################################
669 # LINKING LIBRARIES
670 # Any component or action has to be linked with ${CAMITK_CORE_LIBRARIES} and with all its dependencies
671 target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_LIBRARIES} ${CAMITK_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${VIEWER_EXTENSION_LIBRARIES} ${CEP_LIBRARIES} ${CAMITK_ITK_LIBRARIES} ${LIBXML2_LIBRARY} ${OpenCV_LIBRARIES} ${IGSTK_LIBRARIES} ${XERCESC_LIBRARIES} ${GDCM_LIBRARIES} ${EXTERNAL_LIBRARIES})
672
673
674
675 #########################################################################
676 # #
677 # OUTPUT #
678 # #
679 # * Define the output directory (location and name) #
680 # * Define the output name of the library #
681 # * Add ${CAMITK_DEBUG_POSTFIX} suffix to Debug MSVC built libraries #
682 # * Additional Linux .so files information #
683 # #
684 #########################################################################
685
686 # OUTPUT LIBRARY NAME
687 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
688 PROPERTIES OUTPUT_NAME ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}
689 )
690
691 # OUTPUT DIRECTORY LOCATION AND NAME
692 # Output directory (all extensions are private)
693 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
694 LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
695 LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
696 )
697 # Output directory (for dll plateform, this is still the same, extensions are private)
698 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
699 RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
700 RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
701 )
702 # Output directory (for dll plateform, this is still the same, extensions are private)
703 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
704 ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
705 ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${TYPE_EXTENSION}s
706 )
707
708 # OUTPUT LIBRARY NAME MSVC in DEBUG mode
709 if (MSVC)
710 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX})
711 endif()
712
713 # ADDITIONAL LINUX .so FILE INFORMATION
714 set(${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES ${${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES}
715 VERSION "${CAMITK_VERSION_MAJOR}.${CAMITK_VERSION_MINOR}.${CAMITK_VERSION_PATCH}"
716 SOVERSION "${CAMITK_VERSION_MAJOR}"
717 )
718 # set the library specific info (SONAME...)
719 set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES ${${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
720
721 # see http://www.cmake.org/pipermail/cmake/2012-April/049889.html
722 # target properties (outputname and remove soname)
723 # set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTY NO_SONAME 1)
724 # in CEP the version patch might not have been set
725 if (NOT CAMITK_VERSION_PATCH)
726 set(CAMITK_VERSION_PATCH 0)
727 endif()
728
729
730
731 #########################################################################
732 # #
733 # INSTALLATION #
734 # #
735 # * When installing the project, header files (.h) and test data are #
736 # copied into a installation folder to determine. #
737 # * Indicate in this section, where to install your project and which #
738 # files to copy into that folder (during local/global installation) #
739 # #
740 #########################################################################
741
742 # FOLDER INSTALLATION
743 # Indicate where to install the action/component
744 install(TARGETS ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
745 # TODO always use private lib, even for runtime
746 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
747 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
748 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
749 COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
750 )
751
752 # HEADERS INSTALLATION
753 # Build target to install provided headers to install (with HEADERS_TO_INSTALL option)
754 if(${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL)
755 export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
756 endif()
757
758 # Build target to install all header files(with INSTALL_ALL_HEADERS option)
759 if(${EXTENSION_NAME_CMAKE}_INSTALL_ALL_HEADERS)
760 export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
761 endif()
762
763 # TESTDATA INSTALLATION
764 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/testdata")
765 # Check test data dir directory
766 if (NOT EXISTS ${CAMITK_BUILD_TESTDATA_DIR})
767 make_directory( ${CAMITK_BUILD_TESTDATA_DIR} )
768 endif()
769
770 # copy the files to test data directory
771 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory testdata ${CAMITK_BUILD_TESTDATA_DIR}
772 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
773 )
774
775 # during installation, copy the files to install directory
776 set (TESTDATA_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/testdata)
777 install(DIRECTORY testdata/
778 #DESTINATION share/testdata
779 #DESTINATION share/${CAMITK_SHORT_VERSION_STRING}/testdata
780 DESTINATION ${TESTDATA_DEST_DIR}
781 # COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
782 PATTERN ".svn" EXCLUDE
783 PATTERN "*~" EXCLUDE
784 )
785 endif()
786
787 #########################################################################
788 # #
789 # CDASH SUBPROJECT DESCRIPTION #
790 # #
791 # * Update the XML description of the subprojects dependencies #
792 # for CDash. #
793 # #
794 #########################################################################
795 # CDASH XML SUBPROJECTS DESCRIPTION UPDATE
796 camitk_register_subproject(${TYPE_EXTENSION_CMAKE} ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} DEPENDENCIES library-camitkcore ${COMPONENTS_DEPENDENCY_LIST} ${ACTIONS_DEPENDENCY_LIST} ${VIEWERS_DEPENDENCY_LIST} ${CEP_LIBRARIES_DEPENDENCY_LIST})
797
798
799
800 #########################################################################
801 # #
802 # PACKAGING CATEGORIZATION #
803 # #
804 # * On Windows, when building a package (win32 installer), the #
805 # install shield wizard proposes you to select which component #
806 # to install. #
807 # * Each component to install has a short description following its #
808 # name to understand its role. #
809 # * This section deals with the categorization and the description #
810 # of the component in this installer. #
811 # #
812 #########################################################################
813
814 # WINDOWS INSTALLER CATEGORIZATION
815 if(${EXTENSION_NAME_CMAKE}_CEP_NAME)
816 if (${EXTENSION_NAME_CMAKE}_CEP_NAME MATCHES "SDK")
817 # The default SDK extensions are categorized as "required" and are not "unselectable" by the user at installation time
818 cpack_add_component(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
819 DISPLAY_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
820 DESCRIPTION ${${EXTENSION_NAME_CMAKE}_DESCRIPTION}
821 REQUIRED
822 GROUP SDK
823 )
824
825 else()
826 # Extension is selectable for installation in the wizard of the installer
827 cpack_add_component(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
828 DISPLAY_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
829 DESCRIPTION ${${EXTENSION_NAME_CMAKE}_DESCRIPTION}
830 GROUP ${${EXTENSION_NAME_CMAKE}_CEP_NAME}
831 )
832 endif()
833 else()
834 # Extension if not categorized for packaging presentation
835 cpack_add_component(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
836 DISPLAY_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
837 DESCRIPTION ${${EXTENSION_NAME_CMAKE}_DESCRIPTION}
838 )
839 endif()
840
841
842 #####################################################################################
843 # #
844 # TRANSLATION #
845 # #
846 # * CAMITK_TRANSLATIONS contains the list of language to translate #
847 # the QString to. #
848 # #
849 # * Create the translate.pro file which contains 4 sections: #
850 # - HEADERS: list of .h/.hpp files to look for tr("") QString #
851 # - SOURCES: list of .cpp files to look for tr("") QString #
852 # - FORMS: list of .ui files to look for tr("") QString #
853 # - TRANSLATIONS: list of .ts files which use CAMITK_TRANSLATIONS #
854 # to define each .ts file #
855 # #
856 # * Execute lupdate program to update the .ts files with new QString #
857 # found. #
858 # #
859 # * Execute lrelease program to create .qm files (binary equivalent of #
860 # .ts files #
861 # #
862 # * Create translate.qrc which contains the list of .qm files. #
863 # * Create the flags.qrc file which contains the list of .png flags #
864 # images #
865 # #
866 #####################################################################################
867 if(CAMITK_TRANSLATE)
868 if(${EXTENSION_NAME_CMAKE}_EXTRA_TRANSLATE_LANGUAGE)
869 if(EXTENSION_NAME STREQUAL "application")
870 camitk_translate(USE_FLAGS
871 EXTRA_LANGUAGE ${${EXTENSION_NAME_CMAKE}_EXTRA_TRANSLATE_LANGUAGE})
872 else()
873 camitk_translate(EXTRA_LANGUAGE ${${EXTENSION_NAME_CMAKE}_EXTRA_TRANSLATE_LANGUAGE})
874 endif()
875 else()
876 if(EXTENSION_NAME STREQUAL "application")
877 camitk_translate(USE_FLAGS)
878 else()
879 camitk_translate()
880 endif()
881 endif()
882 endif()
883
884
885
886 #########################################################################
887 # #
888 # CTEST - COMPONENT TESTS DESCRIPTION #
889 # #
890 #########################################################################
891
892 # if auto test possible and required
893 if (NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_AUTO_TEST)
894 if(${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION)
895 camitk_init_test( camitk-testcomponents )
896
897 camitk_parse_test_add_separator(EXTENSION_TYPE ${TYPE_EXTENSION} EXTENSION_NAME ${EXTENSION_NAME})
898
899 # Retrieve the files in testdata directory - a test will be applied for each of these files
900 # or use only the given files
901 if (${EXTENSION_NAME_CMAKE}_TEST_FILES)
902 # add testdata dir to filename
903 set(TESTFILES)
904 foreach(COMPONENT_TESTDATA_FILE ${${EXTENSION_NAME_CMAKE}_TEST_FILES})
905 list(APPEND TESTFILES ${CMAKE_CURRENT_SOURCE_DIR}/${COMPONENT_TESTDATA_FILE})
906 endforeach()
907 else()
908 get_subdirectoryfiles( ${CMAKE_CURRENT_SOURCE_DIR}/testdata TESTFILES )
909 endif()
910
911 if (NOT ${EXTENSION_NAME_CMAKE}_AUTO_TEST_LEVEL)
912 # default
913 set(TESTLEVEL 3)
914 else()
915 set(TESTLEVEL ${${EXTENSION_NAME_CMAKE}_AUTO_TEST_LEVEL})
916 if (NOT ${TESTLEVEL} MATCHES "^[1-3]")
917 # default
918 message(WARNING "AUTO_TEST_LEVEL set to 3 (${TESTLEVEL} is not a valid level)")
919 set(TESTLEVEL 3)
920 else()
921 set(TESTLEVEL ${${EXTENSION_NAME_CMAKE}_AUTO_TEST_LEVEL})
922 endif()
923 endif()
924
925 # Different the test level are done automatically:
926 # - level 1: load component extension, open & close test data
927 # - level 2: load component extension, open & close test data, save as
928 # - level 3: load component extension, open & close test data, save as and compare input with output
929 # disable some tests accordingly to options defined in camitk_extension macro arguments
930 if(TESTLEVEL STREQUAL "1")
931 set(TEST_DESCRIPTION "Test loading the extension, opening and closing the component.")
932 elseif(TESTLEVEL STREQUAL "2")
933 set(TEST_DESCRIPTION "Test loading the extension, opening the component and saving it as a file.")
934 else()
935 # level 3
936 set(TEST_DESCRIPTION "Test loading the extension, opening, saving and closing the component and comparing saved with input component.")
937 endif()
938
939 foreach(COMPONENT_TESTDATA_FILE ${TESTFILES})
940 # Give the file name (full path)
941 get_directory_name(${COMPONENT_TESTDATA_FILE} DATA_FILE)
942
943 # Test procedure: Open an extension and a component- save it - Compare saved file to original file(level3)
944 if(${TESTLEVEL} EQUAL 3)
945 # Level 3 = level 2 + test the output -> test level 2 + add the PASS_FILE_OUTPUT options to the test
946 camitk_add_test(EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/${DATA_FILE} -c ${EXTENSION_PLUGIN_FILE} -l 2"
947 PASS_FILE_OUTPUT ${CAMITK_BUILD_TESTDATA_DIR}/${DATA_FILE}
948 TEST_SUFFIX "-level3-"
949 PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
950 )
951 endif()
952
953 if(${TESTLEVEL} EQUAL 2)
954 camitk_add_test(EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/${DATA_FILE} -c ${EXTENSION_PLUGIN_FILE} -l 2"
955 TEST_SUFFIX "-level2-"
956 PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
957 )
958 endif()
959
960 if(${TESTLEVEL} EQUAL 1)
961 camitk_add_test(EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/${DATA_FILE} -c ${EXTENSION_PLUGIN_FILE} -l 1"
962 TEST_SUFFIX "-level1-"
963 PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
964 )
965 endif()
966
967 camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL ${TESTLEVEL} DESCRIPTION ${TEST_DESCRIPTION})
968 endforeach()
969
970 #########################################################################
971 # #
972 # CTEST - ACTION TESTS DESCRIPTION #
973 # #
974 #########################################################################
975 # We do not apply automatic tests on actions like (close, save, save as) as they
976 # may not act directly on components
977 elseif( ${EXTENSION_NAME_CMAKE}_ACTION_EXTENSION AND NOT (${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME} MATCHES "application"))
978 camitk_init_test( camitk-testactions )
979
980 camitk_parse_test_add_separator(EXTENSION_TYPE ${TYPE_EXTENSION} EXTENSION_NAME ${EXTENSION_NAME})
981
982 # get the names of actions .dlls in lib directory
983 get_subdirectoryfiles( ${CAMITK_BUILD_PRIVATE_LIB_DIR}/actions/ ACTIONSDLLS )
984
985 # Retrieve the files in testdata directory - a test will be applied for each of these files
986 # or use only the given files
987 if (${EXTENSION_NAME_CMAKE}_TEST_FILES)
988 # add testdata dir to filename
989 set(TESTFILES)
990 foreach(ACTION_TESTDATA_FILE ${${EXTENSION_NAME_CMAKE}_TEST_FILES})
991 list(APPEND TESTFILES ${CAMITK_BUILD_TESTDATA_DIR}/${ACTION_TESTDATA_FILE})
992 endforeach()
993 else()
994 get_subdirectoryfiles(${CAMITK_BUILD_TESTDATA_DIR} TESTFILES)
995 endif()
996
997 foreach( ACTION_TESTDATA_FILE ${TESTFILES})
998 # Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
999 camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
1000 TEST_SUFFIX "-level1-"
1001 PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
1002 )
1003 camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 1 DESCRIPTION "Open a file, load the action and apply it on the component.")
1004 endforeach()
1005 endif()
1006 endif() # NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_AUTO_TEST)
1007
1008 #########################################################################
1009 # #
1010 # CTEST - Integration test #
1011 # #
1012 #########################################################################
1013
1014 if (NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_INTEGRATION_TEST)
1015 # add a specific test to run the action, save the output and compare it to expected
1016 camitk_add_integration_test()
1017 endif()
1018
1019 endif() # ${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_ENABLED
1020
1021end(){)
1022
1023
1024# TODO write a viewer_extension macro in CamiTK
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_extension()
Macro camitk_extension simplifies writing a camitk extension (component, action, viewer)
Definition: CamiTKExtension.h:115
get_directory_name()
macro get_directory_name set the variable VariableName to the name of the last directory of FullPathD...
Definition: GetDirectoryName.h:14
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