-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
342 lines (272 loc) · 14.7 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
336
337
338
339
340
341
#--////////////////////////////////////////////////////////////////////////////
#-- Copyright (c) 2014 William Lenthe
#-- Copyright (c) 2014 DREAM3D Consortium
#--
#-- Redistribution and use in source and binary forms, with or without modification,
#-- are permitted provided that the following conditions are met:
#--
#-- Redistributions of source code must retain the above copyright notice, this
#-- list of conditions and the following disclaimer.
#--
#-- Redistributions in binary form must reproduce the above copyright notice, this
#-- list of conditions and the following disclaimer in the documentation and/or
#-- other materials provided with the distribution.
#--
#-- Neither the name of William Lenthe or any of the DREAM3D Consortium contributors
#-- may be used to endorse or promote products derived from this software without
#-- specific prior written permission.
#--
#-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
#-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
#-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
#-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
#-- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#--////////////////////////////////////////////////////////////////////////////
set(PLUGIN_NAME ImageProcessing)
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(ImageProcessing_BINARY_DIR "${DREAM3DProj_BINARY_DIR}/Plugins/${PLUGIN_NAME}")
# --------------------------------------------------------------------
# Look for ITK as it is required.
if(NOT SIMPL_USE_ITK)
set(PluginNumFilters "-100")
set(DREAM3D_ENABLE_${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
# SIMPL Itself has ITK (at least it should if we are doing this) which means by
# this point ITK is actually found. So let's add some additional Modules that are
# going to be needed.
get_property(ITK_VERSION_MAJOR GLOBAL PROPERTY ITK_VERSION_MAJOR)
if(ITK_VERSION_MAJOR EQUAL 4)
# Put ITK 4 Specific Modules in here
set_property(GLOBAL PROPERTY ADDITIONAL_ITK_MODULES ""
)
elseif(ITK_VERSION_MAJOR EQUAL 5)
# Put ITK 5 Specific Modules in here
set_property(GLOBAL PROPERTY ADDITIONAL_ITK_MODULES
ITKWatersheds
ITKSpatialObjects
ITKStatistics
ITKTransform
)
endif()
include( ${CMP_SOURCE_DIR}/ITKSupport/IncludeITK.cmake)
# --------------------------------------------------------------------
# What image bit depth should be used
# --------------------------------------------------------------------
set(${PLUGIN_NAME}_BitDepth "8" CACHE STRING "Bitdepth for ${PLUGIN_NAME} filters (8, 16, or 32)")
CONFIGURE_FILE(${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Config.h.in
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Config.h
)
#-------
# 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} "\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)
# -- 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} "\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
${ITK_INCLUDE_DIRS}
)
# --------------------------------------------------------------------
# Set up the target and install rules for this plugin
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}"
ANACONDA_INSTALL ${DREAM3D_ANACONDA}
)
target_link_libraries(${plug_target_name}
Qt5::Core
SIMPLib
${ITK_LIBRARIES}
)
if(MSVC)
target_compile_options(${plug_target_name} PRIVATE "/bigobj")
endif()
if(SIMPL_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/Binding/CreatePybind11Module.cmake)
CreatePybind11Plugin(PLUGIN_NAME ${PLUGIN_NAME} PLUGIN_TARGET ${plug_target_name})
endif()
#-------------------------------------------------------------------------------
#- This installs all the prebuilt pipeline files.
if(EXISTS ${${PLUGIN_NAME}_SOURCE_DIR}/ExamplePipelines)
#-------------------------------------------------------------------------------
#- 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
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/PrebuiltPipelines/Examples
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()
if(DREAM3D_ANACONDA)
set(INSTALL_DESTINATION "share/DREAM3D/PrebuiltPipelines/Examples")
endif()
install(DIRECTORY ${${PLUGIN_NAME}_SOURCE_DIR}/ExamplePipelines/
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)
set(INSTALL_DESTINATION "Data")
if(DREAM3D_ANACONDA)
set(INSTALL_DESTINATION "share/DREAM3D/Data")
endif()
install(DIRECTORY ${${PLUGIN_NAME}_SOURCE_DIR}/Data/
DESTINATION ${INSTALL_DESTINATION}
COMPONENT Applications
)
endif()
# -- Include the GUI Plugin codes
include(${${PLUGIN_NAME}_SOURCE_DIR}/Gui/CMakeLists.txt)