forked from BlueQuartzSoftware/ITKImageProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
336 lines (272 loc) · 14.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
set(PLUGIN_NAME ITKImageProcessing)
set(${PLUGIN_NAME}_VERSION "1.0")
set(${PLUGIN_NAME}_VERSION_MAJOR "1")
set(${PLUGIN_NAME}_VERSION_MINOR "0")
get_filename_component(${PLUGIN_NAME}_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
set(ITKImageProcessing_BINARY_DIR "${DREAM3DProj_BINARY_DIR}/Plugins/${PLUGIN_NAME}")
option(ITKImageProcessing_LeanAndMean "Only compile the Reader and Writers, All other filters are disabled" OFF)
# --------------------------------------------------------------------
# Look for ITK as it is required.
if(NOT SIMPL_USE_ITK)
set(PluginNumFilters "-100")
set(DREAM3D_BUILD_PLUGIN_${PLUGIN_NAME} "OFF")
message(STATUS "${PLUGIN_NAME}: SIMPL_USE_ITK=OFF, ${PLUGIN_NAME} is disabled.")
return()
endif()
# --------------------------------------------------------------------
# Look for Qt 5 as we need it for the plugin GUI to be generated
if(NOT Qt5Core_FOUND)
message(FATAL_ERROR "Qt 5 is Needed for plugin ${PLUGIN_NAME}Plugin.")
endif()
set(CMP_TOP_HEADER_FILE "")
set(VERSION_HEADER_FILE_NAME "${PLUGIN_NAME}Version.h")
set(VERSION_SOURCE_FILE_NAME "${PLUGIN_NAME}Version.cpp")
cmpRevisionString( GENERATED_HEADER_FILE_PATH "${VERSION_HEADER_FILE_NAME}"
GENERATED_SOURCE_FILE_PATH "${VERSION_SOURCE_FILE_NAME}"
NAMESPACE "${PLUGIN_NAME}"
PROJECT_NAME "${PLUGIN_NAME}"
EXPORT_MACRO "")
set(${PLUGIN_NAME}_Project_SRCS "")
include(${SIMPLProj_SOURCE_DIR}/Source/SIMPLib/SIMPLibMacros.cmake)
## YOU MUST INCLUDE THIS FILE TO USE ITK !!!
## Then do not forget to add "${ITK_LIBRARIES}" to the target_link_libraries below
# --------------------------------------------------------------------
# ITK Include
option(${PLUGIN_NAME}_ENABLE_SCIFIO "Enable SCIFIO ITK Modules" OFF)
set(DREAM3D_ADDITIONAL_ITK_MODULES
ITKIOImageBase
ITKImageNoise
ITKIOBMP
ITKIOJPEG
ITKIONRRD
ITKIOTIFF
ITKIOMeta
ITKIOPNG
ITKIOIPL
ITKIONIFTI
ITKIOGIPL
ITKIOVTK
ITKIOStimulate
ITKIOBioRad
ITKIOGE
ITKIOMRC
ITKTestKernel
)
if(${${PLUGIN_NAME}_ENABLE_SCIFIO})
message(STATUS "${PLUGIN_NAME} Enabling SCIFIO Module")
set( DREAM3D_ADDITIONAL_ITK_MODULES
${DREAM3D_ADDITIONAL_ITK_MODULES}
SCIFIO
)
set(DREAM3D_ADDITIONAL_INSTALL_ITK_DIRECTORIES
jre
jars
)
endif()
set_property(GLOBAL APPEND PROPERTY DREAM3D_ADDITIONAL_ITK_MODULES ${DREAM3D_ADDITIONAL_ITK_MODULES})
set_property(GLOBAL APPEND PROPERTY DREAM3D_ADDITIONAL_INSTALL_ITK_DIRECTORIES ${DREAM3D_ADDITIONAL_INSTALL_ITK_DIRECTORIES})
include(${CMP_SOURCE_DIR}/ITKSupport/IncludeITK.cmake)
#-------
# Start writing this header file
set(AllFiltersHeaderFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h_tmp)
file(WRITE ${AllFiltersHeaderFile} "#ifndef _${PLUGIN_NAME}_Filters_H_\n#define _${PLUGIN_NAME}_Filters_H_\n\n")
# --------------------------------------------------------------------
# Create a File that will register all of the DREAM3D Filters
set(RegisterKnownFiltersFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp_tmp)
file(WRITE ${RegisterKnownFiltersFile} "/* This file was AUTO GENERATED During the CMake Run. DO NOT EDIT THIS FILE. Edit the CMake files that generate this file */\n")
file(APPEND ${RegisterKnownFiltersFile} "/* The CMake code that generates this file is located in ${CMAKE_CURRENT_LIST_FILE}*/\n")
file(APPEND ${RegisterKnownFiltersFile} "/* This file will be directly included in another source file. */\n")
file(APPEND ${RegisterKnownFiltersFile} "#include \"${PLUGIN_NAME}Filters.h\"\n\n")
file(APPEND ${RegisterKnownFiltersFile} "\n//----------------------------------------------------------\n")
file(APPEND ${RegisterKnownFiltersFile} "\nvoid ${PLUGIN_NAME}Plugin::registerFilters(FilterManager* fm)\n{\n")
set(Project_SRCS "")
# Add in our Filter classes
include(${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Filters/SourceList.cmake)
# Add in our Plugin Specific FilterParameter
include(${${PLUGIN_NAME}_SOURCE_DIR}/FilterParameters/SourceList.cmake)
# -- Include all the resources
include(${${PLUGIN_NAME}_SOURCE_DIR}/Resources/SourceList.cmake)
set(${PLUGIN_NAME}_Project_SRCS ${Project_SRCS})
#-----------------------------------------------------
# Close up all the files that we just generated
file(APPEND ${AllFiltersHeaderFile} "\n#endif\n")
file(APPEND ${RegisterKnownFiltersFile} "\n}\n")
#-----------------------------------------------------
# Add function to return all filter names in a list
file(APPEND ${RegisterKnownFiltersFile} "\n//----------------------------------------------------------\n")
file(APPEND ${RegisterKnownFiltersFile} "\nQList<QString> ${PLUGIN_NAME}Plugin::getFilters()\n{\n")
ADD_FILTER_LIST()
file(APPEND ${RegisterKnownFiltersFile} "\n}\n\n")
cmpReplaceFileIfDifferent(OLD_FILE_PATH ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h
NEW_FILE_PATH ${AllFiltersHeaderFile} )
cmpReplaceFileIfDifferent(OLD_FILE_PATH ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp
NEW_FILE_PATH ${RegisterKnownFiltersFile} )
set(AllFiltersHeaderFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h)
set(RegisterKnownFiltersFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp)
#-- Compute some directories
get_filename_component(PLUGINS_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR} DIRECTORY)
get_filename_component(PLUGINS_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR} DIRECTORY)
set(FILTER_HEADERS "#include \"${AllFiltersHeaderFile}\"")
set(FILTER_WIDGETS_TEMP_DIR ${${PLUGIN_NAME}_BINARY_DIR}/Temp)
set(FILTER_WIDGETS_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR})
set(FILTER_WIDGETS_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR})
set(FILTER_WIDGETS_DOCS_DIR ${${PLUGIN_NAME}_SOURCE_DIR}/Documentation/Filters)
set(FILTER_INCLUDE_PREFIX "${PLUGIN_NAME}")
# --------------------------------------------------------------------
# On Linux we need -fPIC for linking static and shared libraries
if(UNIX AND NOT APPLE)
set_source_files_properties(${${PLUGIN_NAME}_Project_SRCS} PROPERTIES COMPILE_FLAGS -fPIC)
endif()
# --------------------------------------------------------------------
# These headers will be MOC'ed by the build system. They should all inherit from QObject
# --------------------------------------------------------------------
set(${PLUGIN_NAME}_HDRS
${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Constants.h
)
set(${PLUGIN_NAME}_MISC_HDRS
)
cmp_IDE_SOURCE_PROPERTIES( "" "${${PLUGIN_NAME}_MOC_HDRS};${${PLUGIN_NAME}_HDRS};${${PLUGIN_NAME}_MISC_HDRS}" "${${PLUGIN_NAME}_SRCS}" "0")
# -----------------------------------------------------------------------------
# Collect all of our Generated header and source files so that they show up in the various projects
set(${PLUGIN_NAME}_GEN_HDRS
${AllFiltersHeaderFile}
${RegisterKnownFiltersFile}
)
# --------------------------------------------------------------------
# and finally this will run moc:
# QT5_WRAP_CPP( ${PLUGIN_NAME}_Generated_MOC_SRCS ${${PLUGIN_NAME}_MOC_HDRS} OPTIONS -I ${SIMPLProj_SOURCE_DIR}/Source)
set_source_files_properties( ${${PLUGIN_NAME}_Generated_MOC_SRCS} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties( ${${PLUGIN_NAME}_Generated_MOC_SRCS} PROPERTIES GENERATED TRUE)
# --------------------------------------------------------------------
#
# --------------------------------------------------------------------
set_source_files_properties( ${${PLUGIN_NAME}_MODULE_MOC_SRCS} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties( ${RegisterKnownFiltersFile} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties( ${RegisterKnownFilterParameterWidgetsFile} PROPERTIES HEADER_FILE_ONLY TRUE)
# --------------------------------------------------------------------
# Group all the generated source files in IDE's that support it. Makes it clear
# to the user of the IDE what is generated and what is not.
cmp_IDE_SOURCE_PROPERTIES( "Generated/Qt_Moc" "${${PLUGIN_NAME}_GEN_HDRS}" "${${PLUGIN_NAME}_Generated_MOC_SRCS};${${PLUGIN_NAME}_MOC_SRCS};${${PLUGIN_NAME}_GEN_SRCS}" "0")
cmp_IDE_SOURCE_PROPERTIES( "Generated/Qt_Uic" "${${PLUGIN_NAME}_Generated_UI_HDRS}" "" "0")
cmp_IDE_SOURCE_PROPERTIES( "Generated/Qt_Qrc" "${${PLUGIN_NAME}_Generated_RC_SRCS}" "" "0")
# --------------------------------------------------------------------
# Create a shared library that contains just code dependent on SIMPL but
# NOT any widget codes. This must be this way for Python bindings.
set(plug_target_name ${PLUGIN_NAME}Server)
add_library(${plug_target_name} SHARED)
#-- Configure the DLL export header file
configure_file(${SIMPLib_SOURCE_DIR}/Plugin/PluginDLLExport.h.in
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}DLLExport.h)
target_sources(${plug_target_name}
PRIVATE
# -- Add in the filter sources
${${PLUGIN_NAME}_Project_SRCS}
# -- Add in the FilterParameter source files
${${PLUGIN_NAME}_FilterParameters_SRCS}
${${PLUGIN_NAME}_FilterParameters_HDRS}
# -- Add in the plugin interface definition source files
${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Plugin.cpp
${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Plugin.h
# -- Add in our generated Version source files
${${PLUGIN_NAME}_BINARY_DIR}/${VERSION_HEADER_FILE_NAME}
${${PLUGIN_NAME}_BINARY_DIR}/${VERSION_SOURCE_FILE_NAME}
# -- Add in the DLL Export Header File
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}DLLExport.h
)
#-------------------------------
#
target_include_directories(${plug_target_name}
PUBLIC
${${PLUGIN_NAME}_BINARY_DIR}
${${PLUGIN_NAME}_SOURCE_DIR}
${PLUGINS_SOURCE_DIR}
${PLUGINS_BINARY_DIR}
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters
)
# --------------------------------------------------------------------
# Set some additional properties of the plugin like its output name
set(${plug_target_name}_install_dest "./Plugins")
if(WIN32)
set(${plug_target_name}_install_dest ".")
endif()
if(NOT APPLE AND UNIX)
set(${plug_target_name}_install_dest "lib")
endif()
PluginProperties(TARGET_NAME ${plug_target_name}
DEBUG_EXTENSION "_debug"
VERSION "${DREAM3D_VERSION}"
LIB_SUFFIX ".plugin"
FOLDER ${PLUGIN_NAME}
OUTPUT_NAME ${PLUGIN_NAME}
BINARY_DIR "${DREAM3D_BINARY_DIR}"
PLUGIN_FILE "${CMP_PLUGIN_LIST_FILE}"
INSTALL_DEST "${${plug_target_name}_install_dest}"
)
target_link_libraries(${plug_target_name}
Qt5::Core
SIMPLib
${ITK_LIBRARIES}
)
if(MSVC)
set_target_properties(${plug_target_name} PROPERTIES LINK_FLAGS_DEBUG "/INCREMENTAL:NO" )
endif()
if(${${PLUGIN_NAME}_ENABLE_SCIFIO})
target_compile_definitions(${PLUGIN_NAME} PUBLIC "ITK_IMAGE_PROCESSING_HAVE_SCIFIO")
endif()
if(BUILD_TESTING)
include(${${PLUGIN_NAME}_SOURCE_DIR}/Test/CMakeLists.txt)
endif()
# --------------------------------------------------------------------
# If Python Wrapping is enabled then generate the Python module code
if(SIMPL_WRAP_PYTHON)
include("${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Pybind11/cmake/WrappingFunctions.cmake")
string(TOLOWER ${PLUGIN_NAME} PLUGIN_NAME_lower)
CreatePybind11Module(MODULE_NAME ${PLUGIN_NAME}
SOURCE_DIR "${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Filters"
PATH_TO_STRIP "${PLUGIN_NAME}/${PLUGIN_NAME}Filters"
OUTPUT_PATH "${${PLUGIN_NAME}_BINARY_DIR}/Wrapping/PythonCore"
BINARY_DIR "${${PLUGIN_NAME}_BINARY_DIR}"
MODULE_TEMPLATE_FILE "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Pybind11/Templates/PluginModuleCodeTemplate.in.cpp"
MODULE_LINK_LIBRARIES ${plug_target_name} ${ITK_LIBRARIES}
)
endif()
#-------------------------------------------------------------------------------
#- This installs all the prebuilt pipeline files.
if(EXISTS ${${PLUGIN_NAME}_SOURCE_DIR}/ExamplePipelines/${PLUGIN_NAME})
#-------------------------------------------------------------------------------
#- This copies all the Prebuilt Pipeline files into the Build directory
add_custom_target(${PLUGIN_NAME}ExamplePipelinesCopy ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${${PLUGIN_NAME}_SOURCE_DIR}/ExamplePipelines/${PLUGIN_NAME}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/PrebuiltPipelines/Examples/${PLUGIN_NAME}
COMMENT "Copying ${PLUGIN_NAME} Example Pipelines into Binary Directory")
set_target_properties(${PLUGIN_NAME}ExamplePipelinesCopy PROPERTIES FOLDER ZZ_COPY_FILES)
if(APPLE)
set(INSTALL_DESTINATION "${DREAM3D_PACKAGE_DEST_PREFIX}/Resources/PrebuiltPipelines/Examples")
else()
set(INSTALL_DESTINATION "${DREAM3D_PACKAGE_DEST_PREFIX}/PrebuiltPipelines/Examples")
endif()
install(DIRECTORY ${${PLUGIN_NAME}_SOURCE_DIR}/ExamplePipelines/${PLUGIN_NAME}
DESTINATION ${INSTALL_DESTINATION}
COMPONENT Applications )
endif()
#-------------------------------------------------------------------------------
#- This installs all the Data files.
if(EXISTS ${${PLUGIN_NAME}_SOURCE_DIR}/Data/${PLUGIN_NAME})
#-------------------------------------------------------------------------------
# Copy the Data Folder to the build directory
add_custom_target(${PLUGIN_NAME}DataFolderCopy ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${${PLUGIN_NAME}_SOURCE_DIR}/Data
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/Data
COMMENT "Copying ${PLUGIN_NAME} Data Folder into Binary Directory")
set_target_properties(${PLUGIN_NAME}DataFolderCopy PROPERTIES FOLDER ZZ_COPY_FILES)
if(APPLE)
set(INSTALL_DESTINATION "${DREAM3D_PACKAGE_DEST_PREFIX}/Resources/Data")
else()
set(INSTALL_DESTINATION "${DREAM3D_PACKAGE_DEST_PREFIX}")
endif()
install(DIRECTORY ${${PLUGIN_NAME}_SOURCE_DIR}/Data/${PLUGIN_NAME}
DESTINATION Data
COMPONENT Applications )
endif()
# -- Include the GUI Plugin codes
include(${${PLUGIN_NAME}_SOURCE_DIR}/Gui/CMakeLists.txt)