change the way tbb is imported

This commit is contained in:
Caitlin Ross 2021-03-23 09:03:25 -04:00
parent 21b36a6429
commit 53833334c4
4 changed files with 69 additions and 33 deletions

@ -89,6 +89,19 @@ else()
set_and_check(VTKm_CMAKE_MODULE_PATH "@PACKAGE_VTKm_INSTALL_CMAKE_MODULE_DIR@")
endif()
include(CMakeFindDependencyMacro)
set(CMAKE_MODULE_PATH_save_vtkm "${CMAKE_MODULE_PATH}")
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}")
if (VTKm_ENABLE_TBB)
find_dependency(TBB)
if (NOT TBB_FOUND)
set(VTKm_FOUND 0)
list(APPEND VTKm_NOT_FOUND_REASON "TBB not found: ${TBB_NOT_FOUND_MESSAGE}")
endif()
endif()
# Load the library exports, but only if not compiling VTK-m itself
set_and_check(VTKm_CONFIG_DIR "@PACKAGE_VTKm_INSTALL_CONFIG_DIR@")
set(VTKM_FROM_INSTALL_DIR FALSE)
@ -113,7 +126,8 @@ endif()
# VTKm requires some CMake Find modules not included with CMake, so
# include the CMake modules distributed with VTKm.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_save_vtkm} ${VTKm_CMAKE_MODULE_PATH})
unset(CMAKE_MODULE_PATH_save_vtkm)
if(VTKm_ENABLE_CUDA)
if (CMAKE_VERSION VERSION_LESS 3.13)

@ -43,38 +43,11 @@ endfunction()
if(VTKm_ENABLE_TBB AND NOT TARGET vtkm::tbb)
find_package(TBB REQUIRED)
add_library(vtkm::tbb UNKNOWN IMPORTED GLOBAL)
set_target_properties(vtkm::tbb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${TBB_INCLUDE_DIRS}")
if(EXISTS "${TBB_LIBRARY_RELEASE}")
vtkm_extract_real_library("${TBB_LIBRARY_RELEASE}" real_path)
set_property(TARGET vtkm::tbb APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(vtkm::tbb PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION_RELEASE "${real_path}"
)
elseif(EXISTS "${TBB_LIBRARY}")
#When VTK-m is mixed with OSPray we could use the OSPray FindTBB file
#which doesn't define TBB_LIBRARY_RELEASE but instead defined only
#TBB_LIBRARY
vtkm_extract_real_library("${TBB_LIBRARY}" real_path)
set_property(TARGET vtkm::tbb APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(vtkm::tbb PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION_RELEASE "${real_path}"
)
endif()
if(EXISTS "${TBB_LIBRARY_DEBUG}")
vtkm_extract_real_library("${TBB_LIBRARY_DEBUG}" real_path)
set_property(TARGET vtkm::tbb APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(vtkm::tbb PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION_DEBUG "${real_path}"
)
endif()
add_library(vtkmTBB INTERFACE)
add_library(vtkm::tbb ALIAS vtkmTBB)
target_link_libraries(vtkmTBB INTERFACE TBB::tbb)
set_target_properties(vtkmTBB PROPERTIES EXPORT_NAME tbb)
install(TARGETS vtkmTBB EXPORT ${VTKm_EXPORT_NAME})
endif()

@ -0,0 +1,47 @@
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.txt for details.
##
## This software is distributed WITHOUT ANY WARRANTY; without even
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
if (NOT (DEFINED VTKm_BUILD_CMAKE_BASE_DIR AND
DEFINED VTKm_INSTALL_CONFIG_DIR AND
DEFINED VTKm_CMAKE_MODULE_PATH))
message(FATAL_ERROR
"VTKmInstallCMakePackage is missing input variables")
endif()
set(vtkm_cmake_module_files)
if(VTKm_ENABLE_TBB)
list(APPEND vtkm_cmake_module_files FindTBB.cmake)
endif()
set(vtkm_cmake_build_dir ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR})
foreach (vtkm_cmake_module_file IN LISTS vtkm_cmake_module_files)
configure_file(
"${VTKm_CMAKE_MODULE_PATH}/${vtkm_cmake_module_file}"
"${vtkm_cmake_build_dir}/${vtkm_cmake_module_file}"
COPYONLY)
list(APPEND vtkm_cmake_files_to_install
"${vtkm_cmake_module_file}")
endforeach()
foreach (vtkm_cmake_file IN LISTS vtkm_cmake_files_to_install)
if (IS_ABSOLUTE "${vtkm_cmake_file}")
file(RELATIVE_PATH vtkm_cmake_subdir_root "${vtkm_cmake_build_dir}" "${vtkm_cmake_file}")
get_filename_component(vtkm_cmake_subdir "${vtkm_cmake_subdir_root}" DIRECTORY)
set(vtkm_cmake_original_file "${vtkm_cmake_file}")
else ()
get_filename_component(vtkm_cmake_subdir "${vtkm_cmake_file}" DIRECTORY)
set(vtkm_cmake_original_file "${VTKm_CMAKE_MODULE_PATH}/${vtkm_cmake_file}")
endif ()
install(
FILES "${vtkm_cmake_original_file}"
DESTINATION "${VTKm_INSTALL_CONFIG_DIR}/${vtkm_cmake_subdir}"
COMPONENT "development")
endforeach ()

@ -269,6 +269,8 @@ write_basic_package_version_file(
VERSION ${VTKm_VERSION}
COMPATIBILITY ExactVersion )
include(VTKmInstallCMakePackage)
# Install the readme and license files.
if (NOT VTKm_NO_INSTALL_README_LICENSE)
install(FILES ${VTKm_SOURCE_DIR}/README.md