/VTK/Examples/CMakeLists.txt

https://github.com/certik/paraview · CMake · 176 lines · 137 code · 13 blank · 26 comment · 0 complexity · 0b5ac919f92541c33a635d5091d4df06 MD5 · raw file

  1. # VTK examples now require CMake 2.0 or higher.
  2. CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
  3. # Choose behavior based on whether we are building inside the VTK tree.
  4. IF(VTK_BINARY_DIR)
  5. # We are building in the VTK tree. Add tests for some examples.
  6. # Test the build system examples. These tests can be run only
  7. # when the configuration type is known when running the test.
  8. IF(BUILD_TESTING AND VTK_TEST_CONFIG_TYPE_KNOWN)
  9. # If multiple configuration types are available we must add the test
  10. # in a way that will use the configuration given for testing. When
  11. # CTest 2.2 and higher is used to drive the tests it evaluates the
  12. # ADD_TEST commands stored in the test files using standard cmake
  13. # language evaluation. The variable CTEST_CONFIGURATION_TYPE expands
  14. # to the configuration specified for testing (Debug, Release, etc.).
  15. # This variable must be stored in the test string and evaluated at
  16. # testing time, so the dollar must be stored in a way that will not be
  17. # evaluated immediately. In CMake 2.2 and higher this can be done
  18. # with an escaped dollar but we must support older CMake versions
  19. # syntactically.
  20. IF(CMAKE_CONFIGURATION_TYPES)
  21. # We need to pass the configuration type on the test command line.
  22. SET(DOLLAR "$")
  23. SET(VTK_EXAMPLE_TEST_CONFIG_TYPE -C "${DOLLAR}{CTEST_CONFIGURATION_TYPE}")
  24. SET(VTK_EXAMPLE_TEST_RUN_DIR "${EXECUTABLE_OUTPUT_PATH}/${DOLLAR}{CTEST_CONFIGURATION_TYPE}")
  25. ELSE(CMAKE_CONFIGURATION_TYPES)
  26. # There is only one configuration type so it need not be passed.
  27. SET(VTK_EXAMPLE_TEST_CONFIG_TYPE)
  28. SET(VTK_EXAMPLE_TEST_RUN_DIR "${EXECUTABLE_OUTPUT_PATH}")
  29. ENDIF(CMAKE_CONFIGURATION_TYPES)
  30. # Add a test to build the vtkLocal example.
  31. ADD_TEST(Example-vtkLocal ${CMAKE_CTEST_COMMAND}
  32. ${VTK_EXAMPLE_TEST_CONFIG_TYPE}
  33. --build-and-test
  34. ${VTK_SOURCE_DIR}/Examples/Build/vtkLocal
  35. ${VTK_BINARY_DIR}/Examples/Build/vtkLocal
  36. --build-two-config
  37. --build-generator ${CMAKE_GENERATOR}
  38. --build-makeprogram ${CMAKE_MAKE_PROGRAM}
  39. --build-project VTKLOCAL
  40. --build-run-dir ${VTK_EXAMPLE_TEST_RUN_DIR}
  41. --build-options -DVTK_DIR:PATH=${VTK_BINARY_DIR}
  42. --test-command "${VTK_BINARY_DIR}/Examples/Build/vtkLocal/bin/vtkLocalTest"
  43. )
  44. # Add a test to build the vtkMy example.
  45. ADD_TEST(Example-vtkMy ${CMAKE_CTEST_COMMAND}
  46. ${VTK_EXAMPLE_TEST_CONFIG_TYPE}
  47. --build-and-test
  48. ${VTK_SOURCE_DIR}/Examples/Build/vtkMy
  49. ${VTK_BINARY_DIR}/Examples/Build/vtkMy
  50. --build-two-config
  51. --build-generator ${CMAKE_GENERATOR}
  52. --build-makeprogram ${CMAKE_MAKE_PROGRAM}
  53. --build-project VTKMY
  54. --build-run-dir ${VTK_EXAMPLE_TEST_RUN_DIR}
  55. --build-options -DVTK_DIR:PATH=${VTK_BINARY_DIR}
  56. --test-command "${VTK_BINARY_DIR}/Examples/Build/vtkMy/bin/vtkmyEx1"
  57. )
  58. ENDIF(BUILD_TESTING AND VTK_TEST_CONFIG_TYPE_KNOWN)
  59. # Build the examples as a separate project using a custom target.
  60. # Make sure it uses the same build configuration as VTK.
  61. IF(CMAKE_CONFIGURATION_TYPES)
  62. SET(VTKExamples_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
  63. ELSE(CMAKE_CONFIGURATION_TYPES)
  64. SET(VTKExamples_CONFIG_TYPE)
  65. ENDIF(CMAKE_CONFIGURATION_TYPES)
  66. ADD_CUSTOM_COMMAND(
  67. OUTPUT ${VTK_BINARY_DIR}/VTKExamples
  68. COMMAND ${CMAKE_CTEST_COMMAND}
  69. ARGS ${VTKExamples_CONFIG_TYPE}
  70. --build-and-test
  71. ${VTK_SOURCE_DIR}/Examples
  72. ${VTK_BINARY_DIR}/Examples/All
  73. --build-noclean
  74. --build-two-config
  75. --build-project VTKExamples
  76. --build-generator ${CMAKE_GENERATOR}
  77. --build-makeprogram ${CMAKE_MAKE_PROGRAM}
  78. --build-options -DVTK_DIR:PATH=${VTK_BINARY_DIR}
  79. -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
  80. -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
  81. -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
  82. -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
  83. -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
  84. -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
  85. -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
  86. -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
  87. -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
  88. -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
  89. -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
  90. -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
  91. -DEXECUTABLE_OUTPUT_PATH:PATH=${EXECUTABLE_OUTPUT_PATH}
  92. -DLIBRARY_OUTPUT_PATH:PATH=${LIBRARY_OUTPUT_PATH}
  93. )
  94. ADD_CUSTOM_TARGET(VTKExamplesTarget ALL DEPENDS ${VTK_BINARY_DIR}/VTKExamples)
  95. # Make sure the target builds after the rest of VTK.
  96. ADD_DEPENDENCIES(VTKExamplesTarget
  97. vtkCommon
  98. vtkFiltering
  99. vtkImaging
  100. vtkGraphics
  101. vtkGenericFiltering
  102. vtkIO
  103. )
  104. IF(VTK_USE_RENDERING)
  105. ADD_DEPENDENCIES(VTKExamplesTarget vtkRendering)
  106. ADD_DEPENDENCIES(VTKExamplesTarget vtkVolumeRendering)
  107. ADD_DEPENDENCIES(VTKExamplesTarget vtkHybrid)
  108. ADD_DEPENDENCIES(VTKExamplesTarget vtkWidgets)
  109. ENDIF(VTK_USE_RENDERING)
  110. IF(VTK_USE_PARALLEL)
  111. ADD_DEPENDENCIES(VTKExamplesTarget vtkParallel)
  112. ENDIF(VTK_USE_PARALLEL)
  113. IF(VTK_USE_QVTK)
  114. ADD_DEPENDENCIES(VTKExamplesTarget QVTK)
  115. ENDIF(VTK_USE_QVTK)
  116. IF(VTK_USE_MFC)
  117. ADD_DEPENDENCIES(VTKExamplesTarget vtkMFC)
  118. ENDIF(VTK_USE_MFC)
  119. ELSE(VTK_BINARY_DIR)
  120. # We are building outside the VTK tree. Build the examples directly.
  121. PROJECT(VTKExamples)
  122. # Find and load the VTK configuration.
  123. FIND_PACKAGE(VTK)
  124. IF(NOT VTK_DIR)
  125. MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
  126. ENDIF(NOT VTK_DIR)
  127. INCLUDE(${VTK_USE_FILE})
  128. # Most examples require rendering support.
  129. IF(VTK_USE_RENDERING)
  130. SUBDIRS(
  131. AMR/Cxx
  132. MultiBlock/Cxx
  133. GUI/Motif
  134. DataManipulation/Cxx
  135. ImageProcessing/Cxx
  136. Medical/Cxx
  137. Modelling/Cxx
  138. Rendering/Cxx
  139. Tutorial/Step1/Cxx
  140. Tutorial/Step2/Cxx
  141. Tutorial/Step3/Cxx
  142. Tutorial/Step4/Cxx
  143. Tutorial/Step5/Cxx
  144. Tutorial/Step6/Cxx
  145. )
  146. IF(VTK_USE_PARALLEL)
  147. SUBDIRS(ParallelProcessing)
  148. ENDIF(VTK_USE_PARALLEL)
  149. IF(VTK_USE_INFOVIS)
  150. SUBDIRS(Infovis/Cxx)
  151. ENDIF(VTK_USE_INFOVIS)
  152. IF(VTK_USE_QVTK)
  153. SUBDIRS(GUI/Qt)
  154. ENDIF(VTK_USE_QVTK)
  155. IF(WIN32)
  156. SUBDIRS(GUI/Win32/SimpleCxx)
  157. IF(VTK_USE_MFC)
  158. SUBDIRS(GUI/Win32/SampleMFC)
  159. SUBDIRS(GUI/Win32/vtkMFC)
  160. ENDIF(VTK_USE_MFC)
  161. ENDIF(WIN32)
  162. ENDIF(VTK_USE_RENDERING)
  163. ENDIF(VTK_BINARY_DIR)