Commit 8b9c78b1 authored by Ben Boeckel's avatar Ben Boeckel

cmake: use the new module system

parent aca94453
#[==[.md
# vtk-config.cmake
This file is used by CMake when finding VTK. It provides the [VTK module
API][] as well as some VTK-specific APIs.
The following variables are provided by this module:
* `VTK_VERSION`: The version of VTK found.
* `VTK_LEGACY_REMOVE`: Whether VTK's deprecated APIs are
compiled out or not.
* `VTK_HAS_VTKm`: If VTK provides VTK-m.
* `VTK_WRAP_PYTHON`: If VTK itself provides Python wrapping. If so, the
Python parts of the module API are available.
* `VTK_WRAP_JAVA`: If VTK itself provides Java wrapping. If so, the
Java parts of the module API are available.
* `VTK_LIBRARIES`: The list of modules specified by `COMPONENTS` and
`OPTIONAL_COMPONENTS`. This may be used in `MODULES` arguments in the API
(e.g., `vtk_module_autoinit`). All modules are also targets and may be
linked to using `target_link_libraries`.
[VTK module API]: TODO: Link to hosted documentation.
#]==]
set(CMAKE_MODULE_PATH_save "${CMAKE_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}")
set("${CMAKE_FIND_PACKAGE_NAME}_VERSION" "@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.@VTK_BUILD_VERSION@")
set("${CMAKE_FIND_PACKAGE_NAME}_LEGACY_REMOVE" "@VTK_LEGACY_REMOVE@")
set("${CMAKE_FIND_PACKAGE_NAME}_HAS_VTKm" "@vtk_has_vtkm@")
if (${CMAKE_FIND_PACKAGE_NAME}_HAS_VTKm)
find_package(VTKm
PATHS "${CMAKE_CURRENT_LIST_DIR}/vtkm"
NO_DEFAULT_PATH)
if (NOT VTKm_FOUND)
set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 0)
endif ()
endif ()
unset("${CMAKE_FIND_PACKAGE_NAME}_FOUND")
include("${CMAKE_CURRENT_LIST_DIR}/vtkCMakeBackports.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-vtk-module-properties.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-vtk-module-find-packages.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkExternalData.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkModule.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkEncodeString.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkHashSource.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkObjectFactory.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleJson.cmake")
set("${CMAKE_FIND_PACKAGE_NAME}_WRAP_PYTHON" "@VTK_WRAP_PYTHON@")
if (${CMAKE_FIND_PACKAGE_NAME}_WRAP_PYTHON)
include("${CMAKE_CURRENT_LIST_DIR}/vtkmodules-vtk-python-module-properties.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleWrapPython.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vtk-python.cmake")
else ()
set("${CMAKE_FIND_PACKAGE_NAME}_PYTHONPATH")
endif ()
set("${CMAKE_FIND_PACKAGE_NAME}_WRAP_JAVA" "@VTK_WRAP_JAVA@")
if (${CMAKE_FIND_PACKAGE_NAME}_WRAP_JAVA)
include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleWrapJava.cmake")
endif ()
set(_vtk_components_to_check)
foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
# It was already not-found (likely due to `find-package` failures).
elseif (TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}")
list(APPEND _vtk_components_to_check
"${_vtk_component}")
else ()
set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 0)
list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_NOT_FOUND_MESSAGE"
"The ${_vtk_component} component is not available.")
endif ()
endforeach ()
unset(_vtk_component)
while (_vtk_components_to_check)
list(GET _vtk_components_to_check 0 _vtk_component)
list(REMOVE_AT _vtk_components_to_check 0)
if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
# We've already made a determiniation.
continue ()
endif ()
get_property(_vtk_dependencies
TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}"
PROPERTY "INTERFACE_vtk_module_depends")
string(REPLACE "${CMAKE_FIND_PACKAGE_NAME}::" "" _vtk_dependencies "${_vtk_dependencies}")
set(_vtk_all_dependencies_checked TRUE)
foreach (_vtk_dependency IN LISTS _vtk_dependencies)
if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_dependency}_FOUND")
if (NOT ${CMAKE_FIND_PACKAGE_NAME}_${_vtk_dependency}_FOUND)
set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 0)
list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_NOT_FOUND_MESSAGE"
"Failed to find the ${_vtk_dependency} component.")
endif ()
else ()
# Check its dependencies.
list(APPEND _vtk_components_to_check
"${_vtk_dependency}")
set(_vtk_all_found FALSE)
endif ()
endforeach ()
if (NOT DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
if (_vtk_all_dependencies_checked)
set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 1)
else ()
list(APPEND _vtk_components_to_check
"${_vtk_component}")
endif ()
endif ()
unset(_vtk_all_dependencies_checked)
unset(_vtk_dependency)
unset(_vtk_dependencies)
endwhile ()
unset(_vtk_component)
unset(_vtk_components_to_check)
set(_vtk_missing_components)
foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
if (NOT ${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND AND ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_vtk_component})
list(APPEND _vtk_missing_components
"${_vtk_component}")
endif ()
endforeach ()
if (_vtk_missing_components)
list(REMOVE_DUPLICATES _vtk_missing_components)
list(SORT _vtk_missing_components)
string(REPLACE ";" ", " _vtk_missing_components "${_vtk_missing_components}")
set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 0)
set("${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE"
"Could not find the ${CMAKE_FIND_PACKAGE_NAME} package with the following required components: ${_vtk_missing_components}.")
endif ()
unset(_vtk_missing_components)
set("${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES")
if (NOT DEFINED "${CMAKE_FIND_PACKAGE_NAME}_FOUND")
# If nothing went wrong, we've successfully found the package.
set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1)
# Build the `_LIBRARIES` variable.
foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES"
"${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}")
endforeach ()
unset(_vtk_component)
endif ()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_save}")
unset(CMAKE_MODULE_PATH_save)
......@@ -16,28 +16,32 @@ endif()
if(BUILD_TESTING OR VTK_WRAP_PYTHON)
# Need PYTHON_EXECUTABLE for HeaderTesting or python wrapping
find_package(PythonInterp ${VTK_PYTHON_VERSION} QUIET)
find_package(PythonInterp "${VTK_PYTHON_VERSION}" QUIET)
mark_as_advanced(PYTHON_EXECUTABLE)
endif()
if(VTK_WRAP_PYTHON)
set(VTK_WRAP_PYTHON_EXE vtkWrapPython)
set(VTK_WRAP_PYTHON_INIT_EXE vtkWrapPythonInit)
set(VTK_WRAP_PYTHON_EXE VTK::WrapPython)
set(VTK_WRAP_PYTHON_INIT_EXE VTK::WrapPythonInit)
endif()
include(CMakeDependentOption)
cmake_dependent_option(VTK_USE_TK "Build VTK with Tk support" OFF
"VTK_WRAP_PYTHON" OFF)
option(VTK_WRAP_JAVA "Should VTK Java wrapping be built?" OFF)
if(VTK_WRAP_JAVA)
set(VTK_WRAP_JAVA3_INIT_DIR "${VTK_SOURCE_DIR}/Wrapping/Java")
# Wrapping executables.
set(VTK_WRAP_JAVA_EXE vtkWrapJava)
set(VTK_PARSE_JAVA_EXE vtkParseJava)
set(VTK_WRAP_JAVA_EXE VTK::WrapJava)
set(VTK_PARSE_JAVA_EXE VTK::ParseJava)
# Java package location.
set(VTK_JAVA_JAR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vtk.jar)
set(VTK_JAVA_HOME ${VTK_BINARY_DIR}/java/vtk)
file(MAKE_DIRECTORY ${VTK_JAVA_HOME})
set(VTK_JAVA_JAR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vtk.jar")
set(VTK_JAVA_HOME "${VTK_BINARY_DIR}/java/vtk")
file(MAKE_DIRECTORY "${VTK_JAVA_HOME}")
endif()
if(VTK_WRAP_PYTHON OR VTK_WRAP_JAVA OR VTK_WRAP_HIERARCHY)
set(VTK_WRAP_HIERARCHY_EXE vtkWrapHierarchy)
set(VTK_WRAP_HIERARCHY_EXE VTK::WrapHierarchy)
endif()
This diff is collapsed.
......@@ -197,7 +197,7 @@ endings.
### Documentation
On a machine with `doxygen` installed, configure a build with
`BUILD_DOCUMENTATION=ON` and run the `DoxygenDoc` target. To create the
`VTK_BUILD_DOCUMENTATION=ON` and run the `DoxygenDoc` target. To create the
documentation tarball, run:
```sh
......
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