Use CMakePackageConfigHelpers to make config files
This is a little tricky since they don't seem to have considered that you will have files in both the source and build directory or that the file locations will not match exactly with the install locations.
This commit is contained in:
parent
c3ac545d91
commit
5d67b918dc
@ -24,13 +24,7 @@
|
||||
# VTKm_INCLUDE_DIRS - Directories containing VTK-m and dependent headers
|
||||
# VTKm_LIBRARIES - The libraries required when using VTK-m
|
||||
|
||||
# This file should be installed in the include directory.
|
||||
# Find the root directory.
|
||||
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_install_dir "${_dir}/.." ABSOLUTE)
|
||||
|
||||
# The VTKm include file directories.
|
||||
set(VTKm_INCLUDE_DIRS "@VTKm_INCLUDE_DIRS_CONFIG@")
|
||||
@PACKAGE_INIT@
|
||||
|
||||
# The VTKm version number
|
||||
set(VTKm_MAJOR_VERSION "@VTKm_MAJOR_VERSION@")
|
||||
@ -38,9 +32,24 @@ set(VTKm_MINOR_VERSION "@VTKm_MINOR_VERSION@")
|
||||
set(VTKm_PATCH_VERSION "@VTKm_PATCH_VERSION@")
|
||||
set(VTKm_VERSION "@VTKm_VERSION@")
|
||||
|
||||
# This is true when the package is still in the build directory (not installed)
|
||||
if(CMAKE_CURRENT_LIST_DIR STREQUAL "@VTKm_BINARY_DIR@/@VTKm_INSTALL_CONFIG_DIR@")
|
||||
set(VTKm_PACKAGE_IN_BUILD)
|
||||
endif()
|
||||
|
||||
# The VTKm include file directories.
|
||||
set_and_check(VTKm_INCLUDE_DIRS "@PACKAGE_VTKm_INSTALL_INCLUDE_DIR@")
|
||||
if(VTKm_PACKAGE_IN_BUILD)
|
||||
set(VTKm_INCLUDE_DIRS ${VTKm_INCLUDE_DIRS} "@VTKm_SOURCE_DIR@")
|
||||
endif()
|
||||
|
||||
set(VTKm_REQUIRED_BOOST_VERSION "@VTKm_REQUIRED_BOOST_VERSION@")
|
||||
|
||||
set(VTKm_CMAKE_MODULE_PATH "@VTKm_CMAKE_MODULE_PATH_CONFIG@")
|
||||
if(NOT VTKm_PACKAGE_IN_BUILD)
|
||||
set_and_check(VTKm_CMAKE_MODULE_PATH "@PACKAGE_VTKm_INSTALL_CMAKE_MODULE_DIR@")
|
||||
else()
|
||||
set(VTKm_CMAKE_MODULE_PATH "@VTKm_SOURCE_DIR@/CMake")
|
||||
endif()
|
||||
|
||||
set(VTKm_ENABLE_CUDA "@VTKm_ENABLE_CUDA@")
|
||||
set(VTKm_ENABLE_TBB "@VTKm_ENABLE_TBB@")
|
||||
@ -71,3 +80,5 @@ endif()
|
||||
# This should be specified to any target with the CMake command target_compile_options
|
||||
# that uses VTK-m.
|
||||
set(VTKm_COMPILE_OPTIONS "@VTKm_COMPILE_OPTIONS@")
|
||||
|
||||
check_required_components(VTKm)
|
||||
|
@ -238,34 +238,19 @@ endif(VTKm_BUILD_EXAMPLES)
|
||||
# Ready files for find_package
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Configuration for build directory.
|
||||
set(VTKm_INCLUDE_DIRS_CONFIG "${VTKm_SOURCE_DIR};${VTKm_BINARY_DIR}")
|
||||
set(VTKm_CMAKE_MODULE_PATH_CONFIG "${VTKm_SOURCE_DIR}/CMake")
|
||||
configure_file(
|
||||
configure_package_config_file(
|
||||
${VTKm_SOURCE_DIR}/CMake/VTKmConfig.cmake.in
|
||||
${VTKm_BINARY_DIR}/VTKmConfig.cmake
|
||||
@ONLY IMMEDIATE
|
||||
${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfig.cmake
|
||||
INSTALL_DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
|
||||
PATH_VARS VTKm_INSTALL_INCLUDE_DIR VTKm_INSTALL_CMAKE_MODULE_DIR
|
||||
)
|
||||
|
||||
# Configuration for install.
|
||||
set(VTKm_INCLUDE_DIRS_CONFIG "\${_install_dir}/${VTKm_INSTALL_INCLUDE_DIR}")
|
||||
set(VTKm_CMAKE_MODULE_PATH_CONFIG "\${_install_dir}/${VTKm_INSTALL_CMAKE_MODULE_DIR}")
|
||||
configure_file(
|
||||
${VTKm_SOURCE_DIR}/CMake/VTKmConfig.cmake.in
|
||||
${VTKm_BINARY_DIR}/VTKmConfig.cmake.install
|
||||
@ONLY IMMEDIATE
|
||||
)
|
||||
install(FILES ${VTKm_BINARY_DIR}/VTKmConfig.cmake.install
|
||||
DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
|
||||
RENAME VTKmConfig.cmake
|
||||
)
|
||||
|
||||
# Create supplemental version configuration file.
|
||||
write_basic_package_version_file(
|
||||
${VTKm_BINARY_DIR}/VTKmConfigVersion.cmake
|
||||
${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfigVersion.cmake
|
||||
VERSION ${VTKm_VERSION}
|
||||
COMPATIBILITY ExactVersion )
|
||||
install(FILES ${VTKm_BINARY_DIR}/VTKmConfigVersion.cmake
|
||||
install(
|
||||
FILES ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmConfigVersion.cmake
|
||||
DESTINATION ${VTKm_INSTALL_CONFIG_DIR}
|
||||
)
|
||||
|
||||
|
5
vtkm/internal/CMakeLists.txt
Normal file → Executable file
5
vtkm/internal/CMakeLists.txt
Normal file → Executable file
@ -31,11 +31,12 @@ set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB})
|
||||
|
||||
set(VTKM_ENABLE_OPENGL_INTEROP ${VTKm_ENABLE_OPENGL_INTEROP})
|
||||
|
||||
vtkm_get_kit_name(kit_name kit_dir)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Configure.h
|
||||
${CMAKE_BINARY_DIR}/include/${kit_dir}/Configure.h
|
||||
@ONLY)
|
||||
vtkm_install_headers(
|
||||
vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/Configure.h)
|
||||
vtkm/internal ${CMAKE_BINARY_DIR}/include/${kit_dir}/Configure.h)
|
||||
|
||||
unset(VTKM_ENABLE_OPENGL_INTEROP)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user