Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroGenerateToolsLibrary.cmake
Go to the documentation of this file.
2 
3  set(libraryname ${ARGV0})
4 
5  set(reallycreatelibrary TRUE)
6 
7  if(${ARGC} EQUAL 2) # this won't work without the ${}, don't understand the cmake documentation
8  set(reallycreatelibrary FALSE)
9  endif(${ARGC} EQUAL 2)
10 
11  # if used inside MITK core, we fill variables in files.cmake
12  include(tools.cmake OPTIONAL)
13 
14 
15 
16  # GUI-less tools
17  if(TOOL_FILES)
18 
19  foreach( TOOL_FILE ${TOOL_FILES} )
20 
21  # construct tool name from file name
22  string(REGEX REPLACE ".*(^|[/\\])mitk(.+)\\.c(pp|xx)$" "\\2" TOOL_NAME ${TOOL_FILE})
23  message(STATUS "Adding segmentation tool: ${TOOL_NAME}")
24 
25  # source file names for this tool
26  set( TOOL_CPPS ${TOOL_FILE} ${TOOL_CPPS} )
27 
28  # remember factory name for a central register call
29  endforeach( TOOL_FILE ${TOOL_FILES} )
30 
31  endif(TOOL_FILES)
32 
33 
34 
35  # part for Qt widgets
36  if(TOOL_QTGUI_FILES)
37 
38  foreach( TOOL_GUI_FILE ${TOOL_QTGUI_FILES})
39 
40  # construct tool name from file name
41  string(REGEX REPLACE "^Qmitk(.+)GUI\\.c(pp|xx)$" "\\1" TOOL_NAME ${TOOL_GUI_FILE})
42  string(REGEX REPLACE "\\.c(pp|xx)$" ".h" TOOL_GUI_HEADER ${TOOL_GUI_FILE})
43  message(STATUS "Adding GUI for segmentation tool: ${TOOL_NAME}")
44 
45  # source file names for this tool
46  set( TOOL_GUI_CPPS ${TOOL_GUI_FILE} ${TOOL_GUI_CPPS} )
47  set( TOOL_GUI_MOC_H ${TOOL_GUI_HEADER} ${TOOL_GUI_MOC_H} )
48  endforeach( TOOL_GUI_FILE ${TOOL_QTGUI_FILES})
49 
50  qt_wrap_cpp(${libraryname} TOOL_GUI_CPPS ${TOOL_GUI_MOC_H})
51  endif()
52 
53 
54 
55  # care for additional files (should be used only with MITK external extensions)
56  if(TOOL_ADDITIONAL_CPPS)
57  set( TOOL_CPPS ${TOOL_ADDITIONAL_CPPS} ${TOOL_CPPS} )
58  endif(TOOL_ADDITIONAL_CPPS)
59 
60  if(TOOL_ADDITIONAL_MOC_H)
61  qt_wrap_cpp(${libraryname} TOOL_GUI_CPPS ${TOOL_ADDITIONAL_MOC_H})
62  endif(TOOL_ADDITIONAL_MOC_H)
63 
64  # in any case (GUI or non-GUI), create a shared library
65  if(TOOL_FILES OR TOOL_QTGUI_FILES)
66  if(libraryname AND reallycreatelibrary)
67  # configure one file with the itkLoad method
68  configure_file( ${MITK_DIR}/ToolExtensionITKFactoryLoader.cpp.in
69  ${PROJECT_BINARY_DIR}/mitkToolExtensionITKFactoryLoader.cpp
70  @ONLY )
71  # also mark this file for compilation
72  set( TOOL_CPPS ${PROJECT_BINARY_DIR}/mitkToolExtensionITKFactoryLoader.cpp ${TOOL_CPPS} )
73  message(STATUS "Creating itkLoad for external library " ${libraryname})
74 
75  message(STATUS "Adding library " ${libraryname})
76 
77  # a library to wrap up everything
78  # configure a file that contains an itkObjectFactory for this tool
79  include_directories(${CMAKE_CURRENT_SOURCE_DIR})
80 
81  add_library(${libraryname} SHARED ${TOOL_CPPS} ${TOOL_GUI_CPPS})
82  if(TOOL_QTGUI_FILES)
83  mitk_use_modules(TARGET ${libraryname} MODULES Qmitk)
84  else()
85  mitk_use_modules(TARGET ${libraryname} MODULES Mitk)
86  endif()
87 
88  endif(libraryname AND reallycreatelibrary)
89  endif(TOOL_FILES OR TOOL_QTGUI_FILES)
90 
91 
93 
mitk_use_modules()
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
MITK_GENERATE_TOOLS_LIBRARY()
const std::string TARGET