Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionCreateMatchPointDeployedAlgorithm.cmake
Go to the documentation of this file.
1 #!
2 #! Create a Command Line App.
3 #!
4 #! \brief This function will create a command line executable and the scripts required to run it
5 #!
6 #! \param NAME (required) Name of the algorithm / cmake target
7 #! \param DEPENDS (optional) Required MITK modules beyond MitkCommandLine
8 #! \param PACKAGE_DEPENDS (optional) list of "packages" this command line app depends on (e.g. ITK, VTK, etc.)
9 #! \param CPP_FILES (optional) list of cpp files, if it is not given NAME.cpp is assumed
10 #! \param INCLUDE_DIRS (optional): All directories that should be added as include dirs to the project
11 #! \param PROFILE (optional): The profile file that should be used for the algorithm. If not set it is "./<algname>.profile".
12 #! \param ADDITIONAL_LIBS (optional) List of additional private libraries linked to this module.
13 #! The folder containing the library will be added to the global list of library search paths.
14 #! \param H_FILES (optional) List of public header files for this module.
15 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like:
16 #! \code
17 #! mitkFunctionCreateCommandLineApp(
18 #! NAME MyApp
19 #! DEPENDS MitkCore MitkPlanarFigure
20 #! PACKAGE_DEPENDS ITK VTK
21 #! )
22 #! \endcode
23 #!
24 
26 
27  set(_function_params
28  NAME # Name of the algorithm/target
29  )
30 
31  set(_function_multiparams
32  DEPENDS # list of modules this command line app depends on
33  PACKAGE_DEPENDS # list of "packages" this command line app depends on (e.g. ITK, VTK, etc.)
34  CPP_FILES # (optional) list of cpp files, if it is not given NAME.cpp is assumed
35  INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE] <list>
36  ADDITIONAL_LIBS # list of addidtional private libraries linked to this module.
37  H_FILES # list of header files: [PUBLIC|PRIVATE] <list>
38  )
39 
40  set(_function_options
41 
42  )
43 
44  cmake_parse_arguments(ALG "${_function_options}" "${_function_params}" "${_function_multiparams}" ${ARGN})
45 
46  if( NOT (DEFINED MITK_USE_MatchPoint) OR NOT (${MITK_USE_MatchPoint}))
47  message(FATAL_ERROR "Need package Matchpoint to deploy MatchPoint Algorithms.")
48  endif()
49 
50  if(NOT ALG_NAME)
51  message(FATAL_ERROR "NAME argument cannot be empty.")
52  endif()
53 
54  SET(ALG_TARGET "MDRA_${ALG_NAME}")
55 
56  if(NOT ALG_CPP_FILES)
57  set(ALG_CPP_FILES "${ALG_NAME}.cpp")
58  endif()
59 
60  IF(NOT ALG_PROFILE)
61  set(ALG_PROFILE "${ALG_NAME}.profile")
62  ENDIF(NOT ALG_PROFILE)
63 
64  MESSAGE(STATUS "... generate MDRA profile (from ${ALG_PROFILE})...")
65 
66  include(${MatchPoint_SOURCE_DIR}/CMake/mapFunctionCreateAlgorithmProfile.cmake)
67  CREATE_ALGORITHM_PROFILE(${ALG_NAME} ${ALG_PROFILE})
68 
69  MESSAGE(STATUS "... algorithm UID: ${ALGORITHM_PROFILE_UID}")
70 
71  ADD_LIBRARY(${ALG_TARGET} SHARED ${ALG_CPP_FILES} ${ALGORITHM_PROFILE_FILE})
72 
73  SET_TARGET_PROPERTIES(${ALG_TARGET} PROPERTIES
74  OUTPUT_NAME "mdra-${MatchPoint_VERSION_MAJOR}-${MatchPoint_VERSION_MINOR}_${ALG_NAME}"
75  OUTPUT_NAME_DEBUG "mdra-D-${MatchPoint_VERSION_MAJOR}-${MatchPoint_VERSION_MINOR}_${ALG_NAME}"
76  PREFIX "" )
77 
78  mitk_use_modules(TARGET ${ALG_TARGET}
79  MODULES ${ALG_DEPENDS}
80  PACKAGES PRIVATE ITK MatchPoint ${ALG_PACKAGE_DEPENDS}
81  )
82 
83  target_include_directories(${ALG_TARGET} PRIVATE ${ALG_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
84 
85  if(ALG_ADDITIONAL_LIBS)
86  target_link_libraries(${ALG_TARGET} PRIVATE ${ALG_ADDITIONAL_LIBS})
87  get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
88  foreach(_lib_filepath ${ALG_ADDITIONAL_LIBS})
89  get_filename_component(_search_path "${_lib_filepath}" PATH)
90  if(_search_path)
91  list(APPEND _mitk_additional_library_search_paths "${_search_path}")
92  endif()
93  endforeach()
94  if(_mitk_additional_library_search_paths)
95  list(REMOVE_DUPLICATES _mitk_additional_library_search_paths)
96  set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths})
97  endif()
98  endif()
99 
100  install(TARGETS ${ALG_TARGET} RUNTIME DESTINATION bin LIBRARY DESTINATION bin)
101 
102 endfunction()
static char * line
Definition: svm.cpp:2884
mitkFunctionCreateMatchPointDeployedAlgorithm()
This function will create a command line executable and the scripts required to run it...
const std::string NAME