CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. project(CTKVisualizationVTKWidgets)
  2. include(${VTK_USE_FILE})
  3. #
  4. # See CTK/CMake/ctkMacroBuildLib.cmake for details
  5. #
  6. set(KIT_export_directive "CTK_VISUALIZATION_VTK_WIDGETS_EXPORT")
  7. #
  8. # Add the libraries QtTesting
  9. #
  10. if(CTK_USE_QTTESTING)
  11. find_package(QtTesting REQUIRED)
  12. include_directories(
  13. ${QtTesting_INCLUDE_DIRS}
  14. ${CMAKE_BINARY_DIR} # For ctkConfig.h
  15. )
  16. endif()
  17. # Source files
  18. set(KIT_SRCS
  19. ctkVTKAbstractMatrixWidget.cpp
  20. ctkVTKAbstractMatrixWidget.h
  21. ctkVTKAbstractMatrixWidget_p.h
  22. ctkVTKAbstractView.cpp
  23. ctkVTKAbstractView.h
  24. ctkVTKAbstractView_p.h
  25. ctkVTKColorTransferFunction.cpp
  26. ctkVTKColorTransferFunction.h
  27. ctkVTKCompositeFunction.cpp
  28. ctkVTKCompositeFunction.h
  29. ctkVTKDataSetModel.cpp
  30. ctkVTKDataSetModel.h
  31. ctkVTKDataSetArrayComboBox.cpp
  32. ctkVTKDataSetArrayComboBox.h
  33. ctkVTKHistogram.cpp
  34. ctkVTKHistogram.h
  35. ctkVTKLookupTable.cpp
  36. ctkVTKLookupTable.h
  37. ctkVTKMagnifyView.cpp
  38. ctkVTKMagnifyView.h
  39. ctkVTKMagnifyView_p.h
  40. ctkVTKMatrixWidget.cpp
  41. ctkVTKMatrixWidget.h
  42. ctkVTKPiecewiseFunction.cpp
  43. ctkVTKPiecewiseFunction.h
  44. ctkVTKPropertyWidget.cpp
  45. ctkVTKPropertyWidget.h
  46. ctkVTKRenderView.cpp
  47. ctkVTKRenderView.h
  48. ctkVTKRenderView_p.h
  49. ctkVTKScalarBarWidget.cpp
  50. ctkVTKScalarBarWidget.h
  51. ctkVTKScalarsToColorsComboBox.cpp
  52. ctkVTKScalarsToColorsComboBox.h
  53. ctkVTKSliceView.cpp
  54. ctkVTKSliceView.h
  55. ctkVTKSliceView_p.h
  56. ctkVTKSurfaceMaterialPropertyWidget.cpp
  57. ctkVTKSurfaceMaterialPropertyWidget.h
  58. ctkVTKTextPropertyWidget.cpp
  59. ctkVTKTextPropertyWidget.h
  60. ctkVTKThresholdWidget.cpp
  61. ctkVTKThresholdWidget.h
  62. ctkVTKThumbnailView.cpp
  63. ctkVTKThumbnailView.h
  64. ctkVTKWidgetsUtils.cpp
  65. ctkVTKWidgetsUtils.h
  66. )
  67. # Headers that should run through moc
  68. set(KIT_MOC_SRCS
  69. ctkVTKAbstractMatrixWidget_p.h
  70. ctkVTKAbstractView.h
  71. ctkVTKAbstractView_p.h
  72. ctkVTKColorTransferFunction.h
  73. ctkVTKCompositeFunction.h
  74. ctkVTKDataSetArrayComboBox.h
  75. ctkVTKDataSetModel.h
  76. ctkVTKHistogram.h
  77. ctkVTKLookupTable.h
  78. ctkVTKMagnifyView.h
  79. ctkVTKMagnifyView_p.h
  80. ctkVTKMatrixWidget.h
  81. ctkVTKPiecewiseFunction.h
  82. ctkVTKPropertyWidget.h
  83. ctkVTKRenderView.h
  84. ctkVTKRenderView_p.h
  85. ctkVTKScalarBarWidget.h
  86. ctkVTKScalarsToColorsComboBox.h
  87. ctkVTKSliceView.h
  88. ctkVTKSliceView_p.h
  89. ctkVTKSurfaceMaterialPropertyWidget.h
  90. ctkVTKTextPropertyWidget.h
  91. ctkVTKThresholdWidget.h
  92. ctkVTKThumbnailView.h
  93. )
  94. # UI files
  95. set(KIT_UI_FORMS
  96. Resources/UI/ctkVTKDiscretizableColorTransferWidget.ui
  97. Resources/UI/ctkVTKScalarBarWidget.ui
  98. Resources/UI/ctkVTKTextPropertyWidget.ui
  99. Resources/UI/ctkVTKPropertyWidget.ui
  100. Resources/UI/ctkVTKThresholdWidget.ui
  101. )
  102. # Resources
  103. set(KIT_resources
  104. Resources/ctkVTKWidgets.qrc
  105. )
  106. # Set VTK_LIBRARIES variable
  107. if(${VTK_VERSION_MAJOR} GREATER 5)
  108. set(VTK_LIBRARIES
  109. vtkChartsCore
  110. vtkCommonMath
  111. vtkFiltersSources
  112. vtkImagingGeneral
  113. vtkImagingStatistics
  114. vtkInteractionWidgets
  115. vtkRenderingContext2D
  116. vtkViewsContext2D
  117. vtkGUISupportQt
  118. )
  119. if(TARGET vtkRenderingContext${VTK_RENDERING_BACKEND})
  120. list(APPEND VTK_LIBRARIES vtkRenderingContext${VTK_RENDERING_BACKEND})
  121. endif()
  122. if(TARGET vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  123. list(APPEND VTK_LIBRARIES vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  124. endif()
  125. if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  126. set(VTK_LIBRARIES ${VTK_LIBRARIES} vtkWrappingPythonCore)
  127. endif()
  128. else()
  129. set(VTK_LIBRARIES
  130. QVTK
  131. )
  132. endif()
  133. if(CTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS)
  134. set(CTK_USE_CHARTS 1)
  135. endif()
  136. if(${CTK_USE_CHARTS})
  137. set(KIT_SRCS
  138. ctkVTKChartView.cpp
  139. ctkVTKChartView.h
  140. ctkVTKDiscretizableColorTransferWidget.h
  141. ctkVTKDiscretizableColorTransferWidget.cpp
  142. ctkVTKVolumePropertyWidget.cpp
  143. ctkVTKVolumePropertyWidget.h
  144. ctkVTKScalarsToColorsView.cpp
  145. ctkVTKScalarsToColorsView.h
  146. ctkVTKScalarsToColorsWidget.cpp
  147. ctkVTKScalarsToColorsWidget.h
  148. ${KIT_SRCS})
  149. set(KIT_MOC_SRCS
  150. ctkVTKChartView.h
  151. ctkVTKDiscretizableColorTransferWidget.h
  152. ctkVTKVolumePropertyWidget.h
  153. ctkVTKScalarsToColorsView.h
  154. ctkVTKScalarsToColorsWidget.h
  155. ${KIT_MOC_SRCS})
  156. set(KIT_UI_FORMS
  157. Resources/UI/ctkVTKVolumePropertyWidget.ui
  158. Resources/UI/ctkVTKScalarsToColorsWidget.ui
  159. ${KIT_UI_FORMS})
  160. if(${VTK_VERSION_MAJOR} GREATER 5)
  161. set(VTK_LIBRARIES
  162. vtkChartsCore
  163. ${VTK_LIBRARIES})
  164. else()
  165. set(VTK_LIBRARIES
  166. vtkCharts
  167. ${VTK_LIBRARIES})
  168. endif()
  169. add_definitions(-DCTK_USE_CHARTS)
  170. endif()
  171. # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
  172. # The following macro will read the target libraries from the file 'target_libraries.cmake'
  173. ctkFunctionGetTargetLibraries(KIT_target_libraries)
  174. # If we use QtTessting, we add all the dependencies
  175. if(CTK_USE_QTTESTING)
  176. list(APPEND KIT_SRCS
  177. ctkVTKRenderViewEventPlayer.cpp
  178. ctkVTKRenderViewEventPlayer.h
  179. ctkVTKRenderViewEventTranslator.cpp
  180. ctkVTKRenderViewEventTranslator.h
  181. )
  182. list(APPEND KIT_MOC_SRCS
  183. ctkVTKRenderViewEventPlayer.h
  184. ctkVTKRenderViewEventTranslator.h
  185. )
  186. list(APPEND KIT_target_libraries QtTesting)
  187. endif()
  188. # Prefer QVTKOpenGLWidget to QVTKWidget when using Qt5
  189. set(_use_qvtkopenglwidget 1)
  190. if(CTK_QT_VERSION VERSION_LESS "5"
  191. OR VTK_VERSION VERSION_LESS "8"
  192. OR (NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2"))
  193. set(_use_qvtkopenglwidget 0)
  194. endif()
  195. if(_use_qvtkopenglwidget)
  196. add_definitions(-DCTK_USE_QVTKOPENGLWIDGET)
  197. endif()
  198. ctkMacroBuildLib(
  199. NAME ${PROJECT_NAME}
  200. EXPORT_DIRECTIVE ${KIT_export_directive}
  201. SRCS ${KIT_SRCS}
  202. MOC_SRCS ${KIT_MOC_SRCS}
  203. UI_FORMS ${KIT_UI_FORMS}
  204. TARGET_LIBRARIES ${KIT_target_libraries}
  205. RESOURCES ${KIT_resources}
  206. LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  207. )
  208. if(_use_qvtkopenglwidget)
  209. target_compile_definitions(
  210. ${PROJECT_NAME}
  211. INTERFACE
  212. CTK_USE_QVTKOPENGLWIDGET
  213. )
  214. endif()
  215. if(CTK_WRAP_PYTHONQT_LIGHT)
  216. ctkMacroBuildLibWrapper(
  217. TARGET ${PROJECT_NAME}
  218. SRCS ${KIT_SRCS}
  219. WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  220. )
  221. endif()
  222. # Plugins
  223. if(CTK_BUILD_QTDESIGNER_PLUGINS)
  224. add_subdirectory(Plugins)
  225. endif()
  226. # Testing
  227. if(BUILD_TESTING)
  228. add_subdirectory(Testing)
  229. endif()