2 #! Create a Command Line App.
4 #! \brief This function will create a command line executable and the scripts required to run it
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:
17 #! mitkFunctionCreateCommandLineApp(
19 #! DEPENDS MitkCore MitkPlanarFigure
20 #! PACKAGE_DEPENDS ITK VTK
28 NAME # Name of the algorithm/target
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>
44 cmake_parse_arguments(ALG "${_function_options}
" "${_function_params}
" "${_function_multiparams}
" ${ARGN})
46 if( NOT (DEFINED MITK_USE_MatchPoint) OR NOT (${MITK_USE_MatchPoint}))
47 message(FATAL_ERROR "Need
package Matchpoint to deploy MatchPoint Algorithms.")
51 message(FATAL_ERROR "NAME argument cannot be empty.")
54 SET(ALG_TARGET "MDRA_${ALG_NAME}")
57 set(ALG_CPP_FILES "${ALG_NAME}.cpp")
61 set(ALG_PROFILE "${ALG_NAME}.profile")
62 ENDIF(NOT ALG_PROFILE)
64 MESSAGE(STATUS "... generate MDRA profile (from ${ALG_PROFILE})...")
66 include(${MatchPoint_SOURCE_DIR}/CMake/mapFunctionCreateAlgorithmProfile.cmake)
67 CREATE_ALGORITHM_PROFILE(${ALG_NAME} ${ALG_PROFILE})
69 MESSAGE(STATUS "... algorithm UID: ${ALGORITHM_PROFILE_UID}")
71 ADD_LIBRARY(${ALG_TARGET} SHARED ${ALG_CPP_FILES} ${ALGORITHM_PROFILE_FILE})
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}"
78 mitk_use_modules(TARGET ${ALG_TARGET}
79 MODULES ${ALG_DEPENDS}
80 PACKAGES PRIVATE ITK MatchPoint ${ALG_PACKAGE_DEPENDS}
83 target_include_directories(${ALG_TARGET} PRIVATE ${ALG_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
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)
91 list(APPEND _mitk_additional_library_search_paths "${_search_path}")
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})
100 install(TARGETS ${ALG_TARGET} RUNTIME DESTINATION bin LIBRARY DESTINATION bin)
mitkFunctionCreateMatchPointDeployedAlgorithm()
This function will create a command line executable and the scripts required to run it...