|
| 1 | +#--//////////////////////////////////////////////////////////////////////////// |
| 2 | +#-- Your License or copyright can go here |
| 3 | +#--//////////////////////////////////////////////////////////////////////////// |
| 4 | + |
| 5 | +project(ZeissImport) |
| 6 | + |
| 7 | +set(PLUGIN_NAME ZeissImport) |
| 8 | + |
| 9 | +# -------------------------------------------------------------------- |
| 10 | +# Look for Qt 4 as we need it for the plugin GUI to be generated |
| 11 | +if(NOT QT4_FOUND) |
| 12 | + message(FATAL_ERROR "Qt 4 is Needed for this ${PLUGIN_NAME}Plugin.") |
| 13 | +endif() |
| 14 | +include( ${QT_USE_FILE} ) |
| 15 | + |
| 16 | + |
| 17 | +set(${PLUGIN_NAME}_Project_SRCS "") |
| 18 | + |
| 19 | +include(${DREAM3DProj_SOURCE_DIR}/Source/DREAM3DLib/DREAM3DLibMacros.cmake) |
| 20 | +#------- |
| 21 | +# Start writing this header file |
| 22 | +set(AllFiltersHeaderFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h_tmp) |
| 23 | +file(WRITE ${AllFiltersHeaderFile} "#ifndef _${PLUGIN_NAME}_Filters_H_\n#define _${PLUGIN_NAME}_Filters_H_\n\n") |
| 24 | + |
| 25 | +# -------------------------------------------------------------------- |
| 26 | +# Create a File that will register all of the DREAM3D Filters |
| 27 | +set(RegisterKnownFiltersFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp_tmp) |
| 28 | +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") |
| 29 | +file(APPEND ${RegisterKnownFiltersFile} "/* The CMake code that generates this file is located in ${CMAKE_CURRENT_LIST_FILE}*/\n") |
| 30 | +file(APPEND ${RegisterKnownFiltersFile} "/* This file will be directly included in another source file. */\n") |
| 31 | +file(APPEND ${RegisterKnownFiltersFile} "#include \"${PLUGIN_NAME}Filters.h\"\n\n") |
| 32 | +file(APPEND ${RegisterKnownFiltersFile} "\nvoid ${PLUGIN_NAME}Plugin::registerFilters(FilterManager* fm)\n{\n") |
| 33 | + |
| 34 | +# -------------------------------------------------------------------- |
| 35 | +# Generate a file with all of our MOC'ed sources and headers |
| 36 | +set(FilterWidget_GEN_HDRS_File ${${PLUGIN_NAME}_BINARY_DIR}/FilterWidget_GEN_HDRS_File.cmake) |
| 37 | +set(FilterWidget_GEN_SRCS_File ${${PLUGIN_NAME}_BINARY_DIR}/FilterWidget_GEN_SRCS_File.cmake) |
| 38 | +file(WRITE ${FilterWidget_GEN_HDRS_File}) |
| 39 | +file(WRITE ${FilterWidget_GEN_SRCS_File}) |
| 40 | + |
| 41 | +set(Project_SRCS "") |
| 42 | + |
| 43 | +# Add in our Filter classes |
| 44 | +include(${${PLUGIN_NAME}_SOURCE_DIR}/${PLUGIN_NAME}Filters/SourceList.cmake) |
| 45 | +# Add in our Plugin Specific FilterParameterWidgets |
| 46 | +include(${${PLUGIN_NAME}_SOURCE_DIR}/FilterParameterWidgets/SourceList.cmake) |
| 47 | +#----------------------------------------------------- |
| 48 | +# Include any extra Widgets that this plugin needs |
| 49 | +include(${${PLUGIN_NAME}_SOURCE_DIR}/Widgets/SourceList.cmake) |
| 50 | + |
| 51 | +set(${PLUGIN_NAME}_Project_SRCS ${Project_SRCS}) |
| 52 | + |
| 53 | +#----------------------------------------------------- |
| 54 | +# Close up all the files that we just generated |
| 55 | +file(APPEND ${AllFiltersHeaderFile} "\n#endif\n") |
| 56 | +file(APPEND ${RegisterKnownFiltersFile} "\n }\n") |
| 57 | + |
| 58 | +cmpReplaceFileIfDifferent(OLD_FILE_PATH ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h |
| 59 | + NEW_FILE_PATH ${AllFiltersHeaderFile} ) |
| 60 | + |
| 61 | +cmpReplaceFileIfDifferent(OLD_FILE_PATH ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp |
| 62 | + NEW_FILE_PATH ${RegisterKnownFiltersFile} ) |
| 63 | + |
| 64 | +set(AllFiltersHeaderFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/${PLUGIN_NAME}Filters.h) |
| 65 | +set(RegisterKnownFiltersFile ${${PLUGIN_NAME}_BINARY_DIR}/${PLUGIN_NAME}Filters/RegisterKnownFilters.cpp) |
| 66 | + |
| 67 | +#-------------------------- |
| 68 | +include_directories( ${HDF5_INCLUDE_DIR} ) |
| 69 | +include_directories( ${PROJECT_CODE_DIR} ) |
| 70 | +include_directories( ${QtSupport_BINARY_DIR} ) |
| 71 | +include_directories( ${QtSupport_SOURCE_DIR} ) |
| 72 | + |
| 73 | + |
| 74 | +get_filename_component(PLUGINS_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR} DIRECTORY) |
| 75 | +get_filename_component(PLUGINS_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR} DIRECTORY) |
| 76 | + |
| 77 | +include_directories( ${${PLUGIN_NAME}_BINARY_DIR} ) |
| 78 | +include_directories( ${${PLUGIN_NAME}_SOURCE_DIR}) |
| 79 | +include_directories( ${PLUGINS_SOURCE_DIR} ) |
| 80 | +include_directories( ${PLUGINS_BINARY_DIR} ) |
| 81 | + |
| 82 | +# ****************************************************************************** |
| 83 | +# Create our custom executable that will generate most of our QFilterWidget |
| 84 | +# classes from information stored in the Filters themselves. |
| 85 | +# Read the file back into a string so we can configure our file |
| 86 | +file(READ ${FilterWidget_GEN_HDRS_File} ${PLUGIN_NAME}Widget_GEN_HDRS) |
| 87 | +file(READ ${FilterWidget_GEN_SRCS_File} ${PLUGIN_NAME}Widget_GEN_SRCS) |
| 88 | + |
| 89 | +# Remove the temp files that we no longer need |
| 90 | +file(REMOVE ${FilterWidget_GEN_HDRS_File}) |
| 91 | +file(REMOVE ${FilterWidget_GEN_SRCS_File}) |
| 92 | + |
| 93 | + |
| 94 | +set(FILTER_HEADERS "#include \"${AllFiltersHeaderFile}\"") |
| 95 | +set(FILTER_WIDGETS_TEMP_DIR ${${PLUGIN_NAME}_BINARY_DIR}/Temp) |
| 96 | +set(FILTER_WIDGETS_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR}) |
| 97 | +set(FILTER_WIDGETS_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR}) |
| 98 | +set(FILTER_WIDGETS_DOCS_DIR ${${PLUGIN_NAME}_SOURCE_DIR}/Documentation/Filters) |
| 99 | +set(FILTER_INCLUDE_PREFIX "${PLUGIN_NAME}") |
| 100 | + |
| 101 | +# -------------------------------------------------------------------- |
| 102 | +# On Linux we need -fPIC for linking static and shared libraries |
| 103 | +if(UNIX AND NOT APPLE) |
| 104 | + set_source_files_properties(${${PLUGIN_NAME}_Project_SRCS} PROPERTIES COMPILE_FLAGS -fPIC) |
| 105 | +endif() |
| 106 | + |
| 107 | +# -------------------------------------------------------------------- |
| 108 | +# These headers will be MOC'ed by the build system. They should all inherit from QObject |
| 109 | +# -------------------------------------------------------------------- |
| 110 | +set(${PLUGIN_NAME}_HDRS |
| 111 | + ${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Plugin.h |
| 112 | + ${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Constants.h |
| 113 | +) |
| 114 | + |
| 115 | +set(${PLUGIN_NAME}_SRCS |
| 116 | + ${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Plugin.cpp |
| 117 | +) |
| 118 | + |
| 119 | +set(${PLUGIN_NAME}_MISC_HDRS |
| 120 | + ${PROJECT_SOURCE_DIR}/${PLUGIN_NAME}Constants.h |
| 121 | +) |
| 122 | +cmp_IDE_SOURCE_PROPERTIES( "${PLUGIN_NAME}/" "${${PLUGIN_NAME}_HDRS};${${PLUGIN_NAME}_MISC_HDRS}" "${${PLUGIN_NAME}_SRCS}" "0") |
| 123 | + |
| 124 | +# ----------------------------------------------------------------------------- |
| 125 | +# Collect all of our Generated header and source files so that they show up in the various projects |
| 126 | +set(${PLUGIN_NAME}_GEN_HDRS |
| 127 | + ${AllFiltersHeaderFile} |
| 128 | + ${RegisterKnownFiltersFile} |
| 129 | + ${AllFilterParameterWidgetsHeaderFile} |
| 130 | + ${RegisterKnownFilterParameterWidgetsFile} |
| 131 | +) |
| 132 | + |
| 133 | +# -------------------------------------------------------------------- |
| 134 | +# |
| 135 | +# -------------------------------------------------------------------- |
| 136 | +set_source_files_properties( ${${PLUGIN_NAME}_MODULE_MOC_SRCS} PROPERTIES HEADER_FILE_ONLY TRUE) |
| 137 | +set_source_files_properties( ${RegisterKnownFiltersFile} PROPERTIES HEADER_FILE_ONLY TRUE) |
| 138 | +set_source_files_properties( ${RegisterKnownFilterParameterWidgetsFile} PROPERTIES HEADER_FILE_ONLY TRUE) |
| 139 | + |
| 140 | +# -------------------------------------------------------------------- |
| 141 | +# Group all the generated source files in IDE's that support it. Makes it clear |
| 142 | +# to the user of the IDE what is generated and what is not. |
| 143 | +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") |
| 144 | +cmp_IDE_SOURCE_PROPERTIES( "Generated/Qt_Uic" "${${PLUGIN_NAME}_Generated_UI_HDRS}" "" "0") |
| 145 | +cmp_IDE_SOURCE_PROPERTIES( "Generated/Qt_Qrc" "${${PLUGIN_NAME}_Generated_RC_SRCS}" "" "0") |
| 146 | + |
| 147 | + |
| 148 | +# -------------------------------------------------------------------- |
| 149 | +# |
| 150 | +# -------------------------------------------------------------------- |
| 151 | +include(${ZeissImport_SOURCE_DIR}/ZeissXml/SourceList.cmake) |
| 152 | + |
| 153 | + |
| 154 | +# -------------------------------------------------------------------- |
| 155 | +# |
| 156 | +# -------------------------------------------------------------------- |
| 157 | +set(${PLUGIN_NAME}_MODULE_SRCS |
| 158 | + ${${PLUGIN_NAME}_Project_SRCS} # These sources come from the SourceList.cmake file and include .h/.cpp/moc/uic files |
| 159 | + ${${PLUGIN_NAME}_HDRS} |
| 160 | + ${${PLUGIN_NAME}_SRCS} |
| 161 | + ${${PLUGIN_NAME}_MODULE_MOC_SRCS} |
| 162 | + ${${PLUGIN_NAME}_MISC_HDRS} |
| 163 | + # -- Add in the Filter Parameter Widgets |
| 164 | + ${${PLUGIN_NAME}_ParameterWidgets_HDRS} |
| 165 | + ${${PLUGIN_NAME}_ParameterWidgets_SRCS} |
| 166 | + ${${PLUGIN_NAME}_ParameterWidgets_UIS} |
| 167 | + ${${PLUGIN_NAME}_ParameterWidgets_Generated_MOC_SRCS} |
| 168 | + ${${PLUGIN_NAME}_ParameterWidgets_Generated_UI_HDRS} |
| 169 | + # -- Add in the plain Widgets |
| 170 | + ${${PLUGIN_NAME}_Widgets_HDRS} |
| 171 | + ${${PLUGIN_NAME}_Widgets_SRCS} |
| 172 | + ${${PLUGIN_NAME}_Widgets_UIS} |
| 173 | + ${${PLUGIN_NAME}_Widgets_Generated_MOC_SRCS} |
| 174 | + ${${PLUGIN_NAME}_Widgets_Generated_UI_HDRS} |
| 175 | + ${${PLUGIN_NAME}_GEN_HDRS} |
| 176 | + ${ZeissXml_SRCS} |
| 177 | + ${ZeissXml_HDRS} |
| 178 | +) |
| 179 | + |
| 180 | +# -------------------------------------------------------------------- |
| 181 | +# Setup output Directory for the plugin |
| 182 | +if(NOT MSVC) |
| 183 | + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DREAM3DProj_BINARY_DIR}/Bin/Plugins ) |
| 184 | +endif() |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | +add_library(${PLUGIN_NAME} MODULE ${${PLUGIN_NAME}_MODULE_SRCS}) |
| 189 | +target_link_libraries(${PLUGIN_NAME} |
| 190 | + ${QT_QTCORE_LIBRARY} |
| 191 | + DREAM3DLib |
| 192 | + ${QT_QTGUI_LIBRARY} |
| 193 | + QtSupport |
| 194 | + DREAM3DWidgetsLib |
| 195 | + ${QT_QTXML_LIBRARY} |
| 196 | + ) |
| 197 | +SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES FOLDER ${PLUGIN_NAME}Plugin) |
| 198 | + |
| 199 | +# -------------------------------------------------------------------- |
| 200 | +# Set some additional properties of the plugin like its output name |
| 201 | +PluginProperties(${PLUGIN_NAME} "_debug" "${DREAM3D_VERSION}" |
| 202 | + "${DREAM3D_BINARY_DIR}" "${CMP_PLUGIN_LIST_FILE}") |
| 203 | + |
| 204 | + |
| 205 | +# -------------------------------------------------------------------- |
| 206 | +# Put back the output directory |
| 207 | +if(NOT MSVC) |
| 208 | + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DREAM3DProj_BINARY_DIR}/Bin ) |
| 209 | +endif() |
| 210 | + |
| 211 | + |
0 commit comments