-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
236 lines (190 loc) · 10.5 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
#--////////////////////////////////////////////////////////////////////////////
#-- Your License or copyright can go here
#--////////////////////////////////////////////////////////////////////////////
project(CellularAutomata)
set(PLUGIN_NAME CellularAutomata)
# --------------------------------------------------------------------
# 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 "${PLUGIN_NAME}Plugin.h")
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 "${PROJECT_NAME}"
EXPORT_MACRO "")
configure_file(${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Config.h.in
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Config.h)
set(${PLUGIN_NAME}_Project_SRCS "")
include(${DREAM3DProj_SOURCE_DIR}/Source/DREAM3DLib/DREAM3DLibMacros.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} "\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 FilterParameterWidgets
include(${${PLUGIN_NAME}_SOURCE_DIR}/FilterParameterWidgets/SourceList.cmake)
#-----------------------------------------------------
# Include any extra Widgets that this plugin needs
include(${${PLUGIN_NAME}_SOURCE_DIR}/Widgets/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)
#--------------------------
include_directories( ${HDF5_INCLUDE_DIR} )
include_directories( ${PROJECT_CODE_DIR} )
include_directories( ${QtSupport_BINARY_DIR} )
include_directories( ${QtSupport_SOURCE_DIR} )
get_filename_component(PLUGINS_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR} DIRECTORY)
get_filename_component(PLUGINS_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR} DIRECTORY)
include_directories( ${${PLUGIN_NAME}_BINARY_DIR} )
include_directories( ${${PLUGIN_NAME}_SOURCE_DIR})
include_directories( ${PLUGINS_SOURCE_DIR} )
include_directories( ${PLUGINS_BINARY_DIR} )
# ******************************************************************************
# Create our custom executable that will generate most of our QFilterWidget
# classes from information stored in the Filters themselves.
# Read the file back into a string so we can configure our file
file(READ ${FilterWidget_GEN_HDRS_File} ${PLUGIN_NAME}Widget_GEN_HDRS)
file(READ ${FilterWidget_GEN_SRCS_File} ${PLUGIN_NAME}Widget_GEN_SRCS)
# 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
${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Plugin.h
${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Constants.h
)
set(${PLUGIN_NAME}_SRCS
${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Plugin.cpp
)
set(${PLUGIN_NAME}_MISC_HDRS
${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Constants.h
)
cmp_IDE_SOURCE_PROPERTIES( "${PLUGIN_NAME}/" "${${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}
${AllFilterParameterWidgetsHeaderFile}
${RegisterKnownFilterParameterWidgetsFile}
${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Config.h
"${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Version.h"
"${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Version.cpp"
)
# --------------------------------------------------------------------
#
# --------------------------------------------------------------------
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")
# --------------------------------------------------------------------
#
# --------------------------------------------------------------------
set(${PLUGIN_NAME}_MODULE_SRCS
${${PLUGIN_NAME}_Project_SRCS} # These sources come from the SourceList.cmake file and include .h/.cpp/moc/uic files
${${PLUGIN_NAME}_HDRS}
${${PLUGIN_NAME}_SRCS}
${${PLUGIN_NAME}_MODULE_MOC_SRCS}
${${PLUGIN_NAME}_MISC_HDRS}
# -- Add in the Filter Parameter Widgets
${${PLUGIN_NAME}_ParameterWidgets_HDRS}
${${PLUGIN_NAME}_ParameterWidgets_SRCS}
${${PLUGIN_NAME}_ParameterWidgets_UIS}
${${PLUGIN_NAME}_ParameterWidgets_Generated_MOC_SRCS}
${${PLUGIN_NAME}_ParameterWidgets_Generated_UI_HDRS}
# -- Add in the plain Widgets
${${PLUGIN_NAME}_Widgets_HDRS}
${${PLUGIN_NAME}_Widgets_SRCS}
${${PLUGIN_NAME}_Widgets_UIS}
${${PLUGIN_NAME}_Widgets_Generated_MOC_SRCS}
${${PLUGIN_NAME}_Widgets_Generated_UI_HDRS}
${${PLUGIN_NAME}_GEN_HDRS}
# -- Add in the miscellaneous resources (license, plugin info, ...)
${${PLUGIN_NAME}_Generated_RC_SRCS}
# -- Add in our Generated Version Files
${${PLUGIN_NAME}_BINARY_DIR}/${VERSION_HEADER_FILE_NAME}
${${PLUGIN_NAME}_BINARY_DIR}/${VERSION_SOURCE_FILE_NAME}
)
# --------------------------------------------------------------------
# Setup output Directory for the plugin
if(NOT MSVC)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DREAM3DProj_BINARY_DIR}/Bin/Plugins )
endif()
add_library(${PLUGIN_NAME} MODULE ${${PLUGIN_NAME}_MODULE_SRCS})
target_link_libraries(${PLUGIN_NAME}
Qt5::Core
DREAM3DLib
Qt5::Gui
Qt5::Widgets
QtSupportLib
DREAM3DWidgetsLib
)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES FOLDER ${PLUGIN_NAME}Plugin)
qt5_use_modules(${PROJECT_NAME} Core Gui Widgets)
# --------------------------------------------------------------------
# Set some additional properties of the plugin like its output name
PluginProperties(${PLUGIN_NAME} "_debug" "${DREAM3D_VERSION}"
"${DREAM3D_BINARY_DIR}" "${CMP_PLUGIN_LIST_FILE}")
# --------------------------------------------------------------------
# Put back the output directory
if(NOT MSVC)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DREAM3DProj_BINARY_DIR}/Bin )
endif()
if(${DREAM3D_BUILD_TESTING})
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/Test ${PROJECT_BINARY_DIR}/Test)
endif()