CMakeLists.txt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. ctkVTKOpenGLNativeWidget.h
  43. ctkVTKPiecewiseFunction.cpp
  44. ctkVTKPiecewiseFunction.h
  45. ctkVTKPropertyWidget.cpp
  46. ctkVTKPropertyWidget.h
  47. ctkVTKRenderView.cpp
  48. ctkVTKRenderView.h
  49. ctkVTKRenderView_p.h
  50. ctkVTKScalarBarWidget.cpp
  51. ctkVTKScalarBarWidget.h
  52. ctkVTKScalarsToColorsComboBox.cpp
  53. ctkVTKScalarsToColorsComboBox.h
  54. ctkVTKSliceView.cpp
  55. ctkVTKSliceView.h
  56. ctkVTKSliceView_p.h
  57. ctkVTKSurfaceMaterialPropertyWidget.cpp
  58. ctkVTKSurfaceMaterialPropertyWidget.h
  59. ctkVTKTextPropertyWidget.cpp
  60. ctkVTKTextPropertyWidget.h
  61. ctkVTKThresholdWidget.cpp
  62. ctkVTKThresholdWidget.h
  63. ctkVTKThumbnailView.cpp
  64. ctkVTKThumbnailView.h
  65. ctkVTKWidgetsUtils.cpp
  66. ctkVTKWidgetsUtils.h
  67. )
  68. # Headers that should run through moc
  69. set(KIT_MOC_SRCS
  70. ctkVTKAbstractMatrixWidget_p.h
  71. ctkVTKAbstractView.h
  72. ctkVTKAbstractView_p.h
  73. ctkVTKColorTransferFunction.h
  74. ctkVTKCompositeFunction.h
  75. ctkVTKDataSetArrayComboBox.h
  76. ctkVTKDataSetModel.h
  77. ctkVTKHistogram.h
  78. ctkVTKLookupTable.h
  79. ctkVTKMagnifyView.h
  80. ctkVTKMagnifyView_p.h
  81. ctkVTKMatrixWidget.h
  82. ctkVTKOpenGLNativeWidget.h
  83. ctkVTKPiecewiseFunction.h
  84. ctkVTKPropertyWidget.h
  85. ctkVTKRenderView.h
  86. ctkVTKRenderView_p.h
  87. ctkVTKScalarBarWidget.h
  88. ctkVTKScalarsToColorsComboBox.h
  89. ctkVTKSliceView.h
  90. ctkVTKSliceView_p.h
  91. ctkVTKSurfaceMaterialPropertyWidget.h
  92. ctkVTKTextPropertyWidget.h
  93. ctkVTKThresholdWidget.h
  94. ctkVTKThumbnailView.h
  95. )
  96. # UI files
  97. set(KIT_UI_FORMS
  98. Resources/UI/ctkVTKDiscretizableColorTransferWidget.ui
  99. Resources/UI/ctkVTKScalarBarWidget.ui
  100. Resources/UI/ctkVTKTextPropertyWidget.ui
  101. Resources/UI/ctkVTKPropertyWidget.ui
  102. Resources/UI/ctkVTKThresholdWidget.ui
  103. )
  104. # Resources
  105. set(KIT_resources
  106. Resources/ctkVTKWidgets.qrc
  107. )
  108. # Set VTK_LIBRARIES variable
  109. if(${VTK_VERSION_MAJOR} GREATER 5)
  110. set(VTK_LIBRARIES
  111. vtkChartsCore
  112. vtkCommonMath
  113. vtkFiltersSources
  114. vtkImagingGeneral
  115. vtkImagingStatistics
  116. vtkInteractionWidgets
  117. vtkRenderingContext2D
  118. vtkViewsContext2D
  119. vtkGUISupportQt
  120. )
  121. if(TARGET vtkRenderingContext${VTK_RENDERING_BACKEND})
  122. list(APPEND VTK_LIBRARIES vtkRenderingContext${VTK_RENDERING_BACKEND})
  123. endif()
  124. if(TARGET vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  125. list(APPEND VTK_LIBRARIES vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  126. endif()
  127. if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  128. set(VTK_LIBRARIES ${VTK_LIBRARIES} vtkWrappingPythonCore)
  129. endif()
  130. else()
  131. set(VTK_LIBRARIES
  132. QVTK
  133. )
  134. endif()
  135. if(CTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS)
  136. set(CTK_USE_CHARTS 1)
  137. endif()
  138. if(${CTK_USE_CHARTS})
  139. set(KIT_SRCS
  140. ctkVTKChartView.cpp
  141. ctkVTKChartView.h
  142. ctkVTKDiscretizableColorTransferWidget.h
  143. ctkVTKDiscretizableColorTransferWidget.cpp
  144. ctkVTKVolumePropertyWidget.cpp
  145. ctkVTKVolumePropertyWidget.h
  146. ctkVTKScalarsToColorsView.cpp
  147. ctkVTKScalarsToColorsView.h
  148. ctkVTKScalarsToColorsWidget.cpp
  149. ctkVTKScalarsToColorsWidget.h
  150. ${KIT_SRCS})
  151. set(KIT_MOC_SRCS
  152. ctkVTKChartView.h
  153. ctkVTKDiscretizableColorTransferWidget.h
  154. ctkVTKVolumePropertyWidget.h
  155. ctkVTKScalarsToColorsView.h
  156. ctkVTKScalarsToColorsWidget.h
  157. ${KIT_MOC_SRCS})
  158. set(KIT_UI_FORMS
  159. Resources/UI/ctkVTKVolumePropertyWidget.ui
  160. Resources/UI/ctkVTKScalarsToColorsWidget.ui
  161. ${KIT_UI_FORMS})
  162. if(${VTK_VERSION_MAJOR} GREATER 5)
  163. set(VTK_LIBRARIES
  164. vtkChartsCore
  165. ${VTK_LIBRARIES})
  166. else()
  167. set(VTK_LIBRARIES
  168. vtkCharts
  169. ${VTK_LIBRARIES})
  170. endif()
  171. add_definitions(-DCTK_USE_CHARTS)
  172. endif()
  173. # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
  174. # The following macro will read the target libraries from the file 'target_libraries.cmake'
  175. ctkFunctionGetTargetLibraries(KIT_target_libraries)
  176. # If we use QtTessting, we add all the dependencies
  177. if(CTK_USE_QTTESTING)
  178. list(APPEND KIT_SRCS
  179. ctkVTKRenderViewEventPlayer.cpp
  180. ctkVTKRenderViewEventPlayer.h
  181. ctkVTKRenderViewEventTranslator.cpp
  182. ctkVTKRenderViewEventTranslator.h
  183. )
  184. list(APPEND KIT_MOC_SRCS
  185. ctkVTKRenderViewEventPlayer.h
  186. ctkVTKRenderViewEventTranslator.h
  187. )
  188. list(APPEND KIT_target_libraries QtTesting)
  189. endif()
  190. # Prefer QVTKOpenGLWidget to QVTKWidget when using Qt5
  191. set(_use_qvtkopenglwidget 1)
  192. if(CTK_QT_VERSION VERSION_LESS "5"
  193. OR VTK_VERSION VERSION_LESS "8"
  194. OR (NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2"))
  195. set(_use_qvtkopenglwidget 0)
  196. endif()
  197. if(_use_qvtkopenglwidget)
  198. add_definitions(-DCTK_USE_QVTKOPENGLWIDGET)
  199. endif()
  200. # Detect if QVTKOpenGLNativeWidget.h is available
  201. set(_has_QVTKOpenGLNativeWidget_h 0)
  202. if(_use_qvtkopenglwidget)
  203. set(_msg "Checking if QVTKOpenGLNativeWidget.h exists")
  204. message(STATUS "${_msg}")
  205. foreach(include_dir IN ITEMS ${vtkGUISupportQt_INCLUDE_DIRS})
  206. if(EXISTS "${include_dir}/QVTKOpenGLNativeWidget.h")
  207. set(_has_QVTKOpenGLNativeWidget_h 1)
  208. break()
  209. endif()
  210. endforeach()
  211. if(_has_QVTKOpenGLNativeWidget_h)
  212. message(STATUS "${_msg} - found")
  213. else()
  214. message(STATUS "${_msg} - not found")
  215. endif()
  216. endif()
  217. if(_has_QVTKOpenGLNativeWidget_h)
  218. add_definitions(-DCTK_HAS_QVTKOPENGLNATIVEWIDGET_H)
  219. endif()
  220. ctkMacroBuildLib(
  221. NAME ${PROJECT_NAME}
  222. EXPORT_DIRECTIVE ${KIT_export_directive}
  223. SRCS ${KIT_SRCS}
  224. MOC_SRCS ${KIT_MOC_SRCS}
  225. UI_FORMS ${KIT_UI_FORMS}
  226. TARGET_LIBRARIES ${KIT_target_libraries}
  227. RESOURCES ${KIT_resources}
  228. LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  229. )
  230. if(_use_qvtkopenglwidget)
  231. target_compile_definitions(
  232. ${PROJECT_NAME}
  233. INTERFACE
  234. CTK_USE_QVTKOPENGLWIDGET
  235. )
  236. endif()
  237. if(_has_QVTKOpenGLNativeWidget_h)
  238. target_compile_definitions(
  239. ${PROJECT_NAME}
  240. INTERFACE
  241. CTK_HAS_QVTKOPENGLNATIVEWIDGET_H
  242. )
  243. endif()
  244. if(CTK_WRAP_PYTHONQT_LIGHT)
  245. ctkMacroBuildLibWrapper(
  246. TARGET ${PROJECT_NAME}
  247. SRCS ${KIT_SRCS}
  248. WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  249. )
  250. endif()
  251. # Plugins
  252. if(CTK_BUILD_QTDESIGNER_PLUGINS)
  253. add_subdirectory(Plugins)
  254. endif()
  255. # Testing
  256. if(BUILD_TESTING)
  257. add_subdirectory(Testing)
  258. endif()