CMakeLists.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. ctkVTKScalarsToColorsUtils.cpp
  52. ctkVTKScalarsToColorsUtils.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. ctkVTKSliceView.h
  87. ctkVTKSliceView_p.h
  88. ctkVTKSurfaceMaterialPropertyWidget.h
  89. ctkVTKTextPropertyWidget.h
  90. ctkVTKThresholdWidget.h
  91. ctkVTKThumbnailView.h
  92. )
  93. # UI files
  94. set(KIT_UI_FORMS
  95. Resources/UI/ctkVTKScalarBarWidget.ui
  96. Resources/UI/ctkVTKTextPropertyWidget.ui
  97. Resources/UI/ctkVTKPropertyWidget.ui
  98. Resources/UI/ctkVTKThresholdWidget.ui
  99. )
  100. # Resources
  101. set(KIT_resources
  102. Resources/ctkVTKWidgets.qrc
  103. )
  104. # Set VTK_LIBRARIES variable
  105. if(${VTK_VERSION_MAJOR} GREATER 5)
  106. set(VTK_LIBRARIES
  107. vtkChartsCore
  108. vtkCommonMath
  109. vtkFiltersSources
  110. vtkImagingGeneral
  111. vtkImagingStatistics
  112. vtkInteractionWidgets
  113. vtkRenderingContext2D
  114. vtkViewsContext2D
  115. vtkGUISupportQt
  116. )
  117. if(TARGET vtkRenderingContext${VTK_RENDERING_BACKEND})
  118. list(APPEND VTK_LIBRARIES vtkRenderingContext${VTK_RENDERING_BACKEND})
  119. endif()
  120. if(TARGET vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  121. list(APPEND VTK_LIBRARIES vtkRenderingGL2PS${VTK_RENDERING_BACKEND})
  122. endif()
  123. if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  124. set(VTK_LIBRARIES ${VTK_LIBRARIES} vtkWrappingPythonCore)
  125. endif()
  126. else()
  127. set(VTK_LIBRARIES
  128. QVTK
  129. )
  130. endif()
  131. if(CTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS)
  132. set(CTK_USE_CHARTS 1)
  133. endif()
  134. if(${CTK_USE_CHARTS})
  135. set(KIT_SRCS
  136. ctkVTKChartView.cpp
  137. ctkVTKChartView.h
  138. ctkVTKVolumePropertyWidget.cpp
  139. ctkVTKVolumePropertyWidget.h
  140. ctkVTKScalarsToColorsView.cpp
  141. ctkVTKScalarsToColorsView.h
  142. ctkVTKScalarsToColorsWidget.cpp
  143. ctkVTKScalarsToColorsWidget.h
  144. ${KIT_SRCS})
  145. set(KIT_MOC_SRCS
  146. ctkVTKChartView.h
  147. ctkVTKVolumePropertyWidget.h
  148. ctkVTKScalarsToColorsView.h
  149. ctkVTKScalarsToColorsWidget.h
  150. ${KIT_MOC_SRCS})
  151. set(KIT_UI_FORMS
  152. Resources/UI/ctkVTKVolumePropertyWidget.ui
  153. Resources/UI/ctkVTKScalarsToColorsWidget.ui
  154. ${KIT_UI_FORMS})
  155. if(${VTK_VERSION_MAJOR} GREATER 5)
  156. set(VTK_LIBRARIES
  157. vtkChartsCore
  158. ${VTK_LIBRARIES})
  159. else()
  160. set(VTK_LIBRARIES
  161. vtkCharts
  162. ${VTK_LIBRARIES})
  163. endif()
  164. add_definitions(-DCTK_USE_CHARTS)
  165. endif()
  166. # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
  167. # The following macro will read the target libraries from the file 'target_libraries.cmake'
  168. ctkFunctionGetTargetLibraries(KIT_target_libraries)
  169. # If we use QtTessting, we add all the dependencies
  170. if(CTK_USE_QTTESTING)
  171. list(APPEND KIT_SRCS
  172. ctkVTKRenderViewEventPlayer.cpp
  173. ctkVTKRenderViewEventPlayer.h
  174. ctkVTKRenderViewEventTranslator.cpp
  175. ctkVTKRenderViewEventTranslator.h
  176. )
  177. list(APPEND KIT_MOC_SRCS
  178. ctkVTKRenderViewEventPlayer.h
  179. ctkVTKRenderViewEventTranslator.h
  180. )
  181. list(APPEND KIT_target_libraries QtTesting)
  182. endif()
  183. # Prefer QVTKOpenGLWidget to QVTKWidget when using Qt5
  184. set(_use_qvtkopenglwidget 1)
  185. if(CTK_QT_VERSION VERSION_LESS "5"
  186. OR VTK_VERSION VERSION_LESS "8"
  187. OR (NOT VTK_RENDERING_BACKEND STREQUAL "OpenGL2"))
  188. set(_use_qvtkopenglwidget 0)
  189. endif()
  190. if(_use_qvtkopenglwidget)
  191. add_definitions(-DCTK_USE_QVTKOPENGLWIDGET)
  192. endif()
  193. ctkMacroBuildLib(
  194. NAME ${PROJECT_NAME}
  195. EXPORT_DIRECTIVE ${KIT_export_directive}
  196. SRCS ${KIT_SRCS}
  197. MOC_SRCS ${KIT_MOC_SRCS}
  198. UI_FORMS ${KIT_UI_FORMS}
  199. TARGET_LIBRARIES ${KIT_target_libraries}
  200. RESOURCES ${KIT_resources}
  201. LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  202. )
  203. if(_use_qvtkopenglwidget)
  204. target_compile_definitions(
  205. ${PROJECT_NAME}
  206. INTERFACE
  207. CTK_USE_QVTKOPENGLWIDGET
  208. )
  209. endif()
  210. if(CTK_WRAP_PYTHONQT_LIGHT)
  211. ctkMacroBuildLibWrapper(
  212. TARGET ${PROJECT_NAME}
  213. SRCS ${KIT_SRCS}
  214. WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
  215. )
  216. endif()
  217. # Plugins
  218. if(CTK_BUILD_QTDESIGNER_PLUGINS)
  219. add_subdirectory(Plugins)
  220. endif()
  221. # Testing
  222. if(BUILD_TESTING)
  223. add_subdirectory(Testing)
  224. endif()