Commit fe7fc7e9 authored by Brad King's avatar Brad King

ENH: Setting up build of examples to always be an outside project. An in-tree...

ENH: Setting up build of examples to always be an outside project.  An in-tree build will produce a custom target that builds it as an outside project using ctest --build-and-test.  Once VTK is built the examples will be built.  The output paths are setup to put the examples in the VTK bin directory so DLL builds will work out of the box.
parent 70e49d7b
......@@ -452,11 +452,21 @@ IF(BUILD_TESTING)
ENDIF(VTK_USE_PATENTED)
ENDIF(BUILD_TESTING)
# Examples.
# Include the examples if they are enabled. Note that the in-tree
# build adds tests and a custom target to build the examples project
# in a separate build tree. The examples are not directly included in
# the VTK build. Doing so will not work because they are designed to
# be built out-of-tree.
IF(BUILD_EXAMPLES)
# Temporarily disable examples until we can get in-tree building
# to work again.
#SUBDIRS(Examples)
# The examples tree now requires CMake 2.0 or higher.
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.9)
# Temporarily disable examples until they are all working.
# SUBDIRS(Examples)
ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.9)
MESSAGE(
"Warning: The BUILD_EXAMPLES option now requires CMake 2.0 or higher "
"and is being ignored.")
ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.9)
ENDIF(BUILD_EXAMPLES)
#-----------------------------------------------------------------------------
......
PROJECT (AMR)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(HierarchicalBox HierarchicalBox.cxx)
......
PROJECT(VTKExamples)
# VTK examples now require CMake 2.0 or higher.
CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
MESSAGE(FATAL_ERROR "VTKExamples requires CMake 2.0 or higher.")
ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
# Tell the examples where to find VTK.
# Choose behavior based on whether we are building inside the VTK tree.
IF(VTK_BINARY_DIR)
# Building inside the VTK tree. Directly specify the location.
SET(VTK_DIR ${VTK_BINARY_DIR})
# Prevent the UseVTK.cmake file from duplicating build settings in
# this tree.
SET(VTK_USE_FILE_INCLUDED 1)
ENDIF(VTK_BINARY_DIR)
# Load the VTK configuration.
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})
# Build most examples.
SUBDIRS(
#AMR/Cxx
DataManipulation/Cxx
Medical/Cxx
Modelling/Cxx
#MultiBlock/Cxx
)
# Build optional examples.
IF (VTK_USE_RENDERING)
SUBDIRS(Rendering/Cxx
Tutorial/Step1/Cxx
Tutorial/Step2/Cxx
Tutorial/Step3/Cxx
Tutorial/Step4/Cxx
Tutorial/Step5/Cxx
Tutorial/Step6/Cxx
)
ENDIF (VTK_USE_RENDERING)
IF (VTK_USE_PARALLEL)
SUBDIRS(ParallelProcessing)
ENDIF (VTK_USE_PARALLEL)
IF(VTK_USE_QVTK)
SUBDIRS(GUI/Qt)
ENDIF(VTK_USE_QVTK)
IF(VTK_USE_MFC)
SUBDIRS(GUI/Win32/vtkMFC)
ENDIF(VTK_USE_MFC)
# Test the build system examples.
IF(VTK_BINARY_DIR AND BUILD_TESTING)
IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.8)
# We are building in the VTK tree. Add tests for some examples.
# Test the build system examples.
IF(BUILD_TESTING)
ADD_TEST(Example-vtkLocal ${CMAKE_CTEST_COMMAND}
--build-and-test
${VTK_SOURCE_DIR}/Examples/Build/vtkLocal
......@@ -77,5 +34,104 @@ IF(VTK_BINARY_DIR AND BUILD_TESTING)
--test-command
${VTK_BINARY_DIR}/Examples/Build/vtkMy/bin/vtkmyEx1
)
ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.8)
ENDIF(VTK_BINARY_DIR AND BUILD_TESTING)
ENDIF(BUILD_TESTING)
# Build the examples as a separate project using a custom target.
# Make sure it uses the same build configuration as VTK.
IF(CMAKE_CONFIGURATION_TYPES)
SET(VTKExamples_CONFIG_TYPE -C "$(ConfigurationName)")
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(VTKExamples_CONFIG_TYPE)
ENDIF(CMAKE_CONFIGURATION_TYPES)
ADD_CUSTOM_COMMAND(
OUTPUT ${VTK_BINARY_DIR}/VTKExamples
COMMAND ${CMAKE_CTEST_COMMAND}
ARGS ${VTKExamples_CONFIG_TYPE}
--build-and-test
${VTK_SOURCE_DIR}/Examples
${VTK_BINARY_DIR}/Examples/All
--build-noclean
--build-two-config
--build-project VTKExamples
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${MAKEPROGRAM}
--build-options -DVTK_DIR:PATH=${VTK_BINARY_DIR}
-DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
-DEXECUTABLE_OUTPUT_PATH:PATH=${EXECUTABLE_OUTPUT_PATH}
-DLIBRARY_OUTPUT_PATH:PATH=${LIBRARY_OUTPUT_PATH}
)
ADD_CUSTOM_TARGET(VTKExamples ALL DEPENDS ${VTK_BINARY_DIR}/VTKExamples)
# Make sure the target builds after the rest of VTK.
ADD_DEPENDENCIES(VTKExamples
vtkCommon
vtkFiltering
vtkImaging
vtkGraphics
vtkGenericFiltering
vtkIO
)
IF(VTK_USE_RENDERING)
ADD_DEPENDENCIES(VTKExamples vtkRendering)
ENDIF(VTK_USE_RENDERING)
IF(VTK_USE_PATENTED)
ADD_DEPENDENCIES(VTKExamples vtkPatented)
ENDIF(VTK_USE_PATENTED)
IF(VTK_USE_HYBRID)
ADD_DEPENDENCIES(VTKExamples vtkHybrid)
ENDIF(VTK_USE_HYBRID)
IF(VTK_USE_PARALLEL)
ADD_DEPENDENCIES(VTKExamples vtkParallel)
ENDIF(VTK_USE_PARALLEL)
ELSE(VTK_BINARY_DIR)
# We are building outside the VTK tree. Build the examples directly.
PROJECT(VTKExamples)
# Find and load the VTK configuration.
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
INCLUDE(${VTK_USE_FILE})
# Most examples require rendering support.
IF(VTK_USE_RENDERING)
SUBDIRS(
#AMR/Cxx
#MultiBlock/Cxx
DataManipulation/Cxx
Medical/Cxx
Modelling/Cxx
Rendering/Cxx
Tutorial/Step1/Cxx
Tutorial/Step2/Cxx
Tutorial/Step3/Cxx
Tutorial/Step4/Cxx
Tutorial/Step5/Cxx
)
IF(VTK_USE_HYBRID)
SUBDIRS(Tutorial/Step6/Cxx)
ENDIF(VTK_USE_HYBRID)
IF(VTK_USE_PARALLEL)
SUBDIRS(ParallelProcessing)
ENDIF(VTK_USE_PARALLEL)
IF(VTK_USE_QVTK)
SUBDIRS(GUI/Qt)
ENDIF(VTK_USE_QVTK)
IF(VTK_USE_MFC)
SUBDIRS(GUI/Win32/vtkMFC)
ENDIF(VTK_USE_MFC)
ENDIF(VTK_USE_RENDERING)
ENDIF(VTK_BINARY_DIR)
PROJECT (DataManipulation)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
IF(VTK_USE_RENDERING)
ADD_EXECUTABLE(Arrays Arrays.cxx)
ADD_EXECUTABLE(Cube Cube.cxx)
ADD_EXECUTABLE(SGrid SGrid.cxx)
ADD_EXECUTABLE(RGrid RGrid.cxx)
TARGET_LINK_LIBRARIES(Arrays vtkRendering)
TARGET_LINK_LIBRARIES(Cube vtkRendering)
TARGET_LINK_LIBRARIES(SGrid vtkRendering)
TARGET_LINK_LIBRARIES(RGrid vtkRendering)
ENDIF(VTK_USE_RENDERING)
ADD_EXECUTABLE(Arrays Arrays.cxx)
ADD_EXECUTABLE(Cube Cube.cxx)
ADD_EXECUTABLE(SGrid SGrid.cxx)
ADD_EXECUTABLE(RGrid RGrid.cxx)
TARGET_LINK_LIBRARIES(Arrays vtkRendering)
TARGET_LINK_LIBRARIES(Cube vtkRendering)
TARGET_LINK_LIBRARIES(SGrid vtkRendering)
TARGET_LINK_LIBRARIES(RGrid vtkRendering)
PROJECT (Medical)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
IF(VTK_USE_RENDERING)
ADD_EXECUTABLE(Medical1 Medical1.cxx)
ADD_EXECUTABLE(Medical2 Medical2.cxx)
ADD_EXECUTABLE(Medical3 Medical3.cxx)
TARGET_LINK_LIBRARIES(Medical1 vtkRendering vtkIO)
TARGET_LINK_LIBRARIES(Medical2 vtkRendering vtkIO)
TARGET_LINK_LIBRARIES(Medical3 vtkRendering vtkIO)
ENDIF(VTK_USE_RENDERING)
ADD_EXECUTABLE(Medical1 Medical1.cxx)
ADD_EXECUTABLE(Medical2 Medical2.cxx)
ADD_EXECUTABLE(Medical3 Medical3.cxx)
TARGET_LINK_LIBRARIES(Medical1 vtkRendering vtkIO)
TARGET_LINK_LIBRARIES(Medical2 vtkRendering vtkIO)
TARGET_LINK_LIBRARIES(Medical3 vtkRendering vtkIO)
PROJECT (finance)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
IF(VTK_USE_RENDERING)
ADD_EXECUTABLE(finance finance.cxx)
TARGET_LINK_LIBRARIES(finance vtkRendering)
ENDIF(VTK_USE_RENDERING)
ADD_EXECUTABLE(finance finance.cxx)
TARGET_LINK_LIBRARIES(finance vtkRendering)
PROJECT (MultiBlock)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(MultiBlock MultiBlock.cxx)
......
PROJECT (Rendering)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cylinder Cylinder.cxx)
......
PROJECT (Step1)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone Cone.cxx)
......
PROJECT (Step2)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone2 Cone2.cxx)
......
PROJECT (Step3)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone3 Cone3.cxx)
......
PROJECT (Step4)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone4 Cone4.cxx)
......
PROJECT (Step5)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone5 Cone5.cxx)
......
PROJECT (Step6)
FIND_PACKAGE(VTK)
IF(NOT VTK_DIR)
MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
ENDIF(NOT VTK_DIR)
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_HYBRID)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_HYBRID.")
ENDIF(NOT VTK_USE_HYBRID)
INCLUDE(${VTK_USE_FILE})
ADD_EXECUTABLE(Cone6 Cone6.cxx)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment