Commit 7ea2accb authored by Robert Maynard's avatar Robert Maynard

Correct issues when using a cuda enabled install of vtk-m.

parent 001d1b0f
......@@ -105,6 +105,12 @@ endif()
# include the CMake modules distributed with VTKm.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
if(VTKm_ENABLE_CUDA)
if (CMAKE_VERSION VERSION_LESS "3.9")
message(FATAL_ERROR "VTK-m with CUDA requires CMake 3.9+")
endif()
endif()
# This includes a host of functions used by VTK-m CMake.
include(VTKmWrappers)
include(VTKmRenderingContexts)
......@@ -116,7 +116,7 @@ if(VTKm_ENABLE_OPENMP AND NOT TARGET vtkm::openmp)
endif()
endif()
if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
if(VTKm_ENABLE_CUDA)
cmake_minimum_required(VERSION 3.9...3.14 FATAL_ERROR)
enable_language(CUDA)
......@@ -126,7 +126,7 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
list(APPEND CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
endif()
if (NOT TARGET vtkm_cuda)
if (NOT TARGET vtkm_cuda OR NOT TARGET vtkm::cuda)
add_library(vtkm_cuda INTERFACE)
set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda)
......@@ -261,10 +261,12 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
set_target_properties(vtkm_cuda PROPERTIES INTERFACE_CUDA_Architecture_Flags "${arch_flags}")
endif()
add_library(vtkm::cuda ALIAS vtkm_cuda)
if (NOT TARGET vtkm::cuda)
add_library(vtkm::cuda ALIAS vtkm_cuda)
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
endif()
endif()
endif()
......
......@@ -18,6 +18,7 @@
## this software.
##============================================================================
# -----------------------------------------------------------------------------
function(vtkm_test_install )
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
set(command_args
......@@ -59,14 +60,39 @@ function(vtkm_test_install )
endif()
endfunction()
# -----------------------------------------------------------------------------
function(vtkm_generate_install_build_options file_loc_var)
#This generated file ensures that the adaptor's CMakeCache ends up with
#the same CMAKE_PREFIX_PATH that VTK-m's does, even if that has multiple
#paths in it. It is necessary because ctest's argument parsing in the
#custom command below destroys path separators.
#Note: the generated file will become stale if these variables change.
#In that case it will need manual intervention (remove it) to fix.
file(GENERATE
OUTPUT "${${file_loc_var}}"
CONTENT
"
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING \"\")
set(CMAKE_PREFIX_PATH ${install_prefix} CACHE STRING \"\")
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE FILEPATH \"\")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING \"\")
set(CMAKE_CUDA_COMPILER ${CMAKE_CUDA_COMPILER} CACHE FILEPATH \"\")
set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} CACHE STRING \"\")
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CUDA_HOST_COMPILER} CACHE FILEPATH \"\")
"
)
endfunction()
# -----------------------------------------------------------------------------
function(test_against_installed_vtkm dir)
function(vtkm_test_against_install dir)
set(name ${dir})
set(install_prefix "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_install")
set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/${name}/")
set(build_dir "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_build/test_${name}/")
set(build_config "${build_dir}/build_options.cmake")
vtkm_generate_install_build_options(build_config)
#determine if the test is expected to compile or fail to build. We use
#this information to built the test name to make it clear to the user
......@@ -80,11 +106,7 @@ function(test_against_installed_vtkm dir)
--build-and-test ${src_dir} ${build_dir}
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-options
-DCMAKE_PREFIX_PATH:STRING=${install_prefix}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CUDA_COMPILER:FILEPATH=${CMAKE_CUDA_COMPILER}
-DCMAKE_CUDA_HOST_COMPILER:FILEPATH=${CMAKE_CUDA_HOST_COMPILER}
--build-options -C "${build_config}"
)
set_tests_properties(${build_name} PROPERTIES LABELS ${test_label} )
......
......@@ -47,6 +47,6 @@ add_subdirectory(unified_memory)
if (VTKm_ENABLE_TESTING)
# These need to be fast to build as they will
# be built each time we run the test
test_against_installed_vtkm(rendering)
test_against_installed_vtkm(histogram)
vtkm_test_against_install(rendering)
vtkm_test_against_install(histogram)
endif()
......@@ -34,7 +34,6 @@ if(TARGET vtkm_rendering)
set(srcs ${cuda_srcs})
endif()
message(STATUS "srcs: ${srcs}")
add_executable(Demo ${srcs})
target_link_libraries(Demo PRIVATE vtkm_rendering)
endif()
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