forked from dream3d/DREAM3DReview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
323 lines (261 loc) · 14.3 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
set(PLUGIN_NAME DREAM3DReview)
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(DREAM3DReview_BINARY_DIR "${DREAM3DProj_BINARY_DIR}/Plugins/${PLUGIN_NAME}")
# --------------------------------------------------------------------
# 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()
# --------------------------------------------------------------------
# Include TDMS support
include(${${PLUGIN_NAME}_SOURCE_DIR}/TDMSSupport/SourceList.cmake)
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.
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
ITKOptimizersv4
ITKMetricsv4
ITKRegistrationMethodsv4
ITKIOTransformBase
)
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} "\n//----------------------------------------------------------\n")
file(APPEND ${RegisterKnownFiltersFile} "\nvoid ${PLUGIN_NAME}Plugin::registerFilters(FilterManager* fm)\n{\n")
# --------------------------------------------------------------------
# Generate a file with all of our MOC'ed sources and headers
set(FilterWidget_GEN_HDRS_File ${${PLUGIN_NAME}_BINARY_DIR}/FilterWidget_GEN_HDRS_File.cmake)
set(FilterWidget_GEN_SRCS_File ${${PLUGIN_NAME}_BINARY_DIR}/FilterWidget_GEN_SRCS_File.cmake)
file(WRITE ${FilterWidget_GEN_HDRS_File})
file(WRITE ${FilterWidget_GEN_SRCS_File})
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)
# Remove the temp files that we no longer need
file(REMOVE ${FilterWidget_GEN_HDRS_File})
file(REMOVE ${FilterWidget_GEN_SRCS_File})
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
EbsdLib
OrientationLib
${ITK_LIBRARIES}
)
# --------------------------------------------------------------------
# If Testing is enabled, turn on the Unit Tests
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_ENABLE_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}
)
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()
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)
#-------------------------------------------------------------------------------
# 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
DESTINATION Data
COMPONENT Applications )
endif()
# -- Include the GUI Plugin codes
include(${${PLUGIN_NAME}_SOURCE_DIR}/Gui/CMakeLists.txt)