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