From 049d0cca8c5beceee19fcf9c087b801224c44f7d Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Fri, 9 Dec 2022 18:46:56 -0500 Subject: [PATCH] cmake: namespace vtkm export targets --- CMake/VTKmCPUVectorization.cmake | 8 +- CMake/VTKmCompilerFlags.cmake | 26 +++++-- CMake/VTKmConfig.cmake.in | 32 +++++--- CMake/VTKmDIYUtils.cmake | 26 +++++-- CMake/VTKmDeviceAdapters.cmake | 30 ++++---- CMake/VTKmRenderingContexts.cmake | 5 +- CMake/VTKmWrappers.cmake | 75 +++++++++++++++++-- CMakeLists.txt | 2 + .../vtkm-cmake-targets-namespaces.md | 42 +++++++++++ examples/CMakeLists.txt | 23 +++++- examples/clipping/CMakeLists.txt | 4 +- examples/contour_tree/CMakeLists.txt | 6 +- .../contour_tree_augmented/CMakeLists.txt | 6 +- .../contour_tree_distributed/CMakeLists.txt | 8 +- examples/cosmotools/CMakeLists.txt | 4 +- examples/demo/CMakeLists.txt | 4 +- examples/game_of_life/CMakeLists.txt | 2 +- examples/hello_worklet/CMakeLists.txt | 4 +- examples/histogram/CMakeLists.txt | 4 +- examples/ising/CMakeLists.txt | 4 +- examples/lagrangian/CMakeLists.txt | 4 +- examples/lagrangian_structures/CMakeLists.txt | 2 +- examples/logistic_map/CMakeLists.txt | 4 +- examples/mesh_quality/CMakeLists.txt | 4 +- examples/multi_backend/CMakeLists.txt | 4 +- examples/oscillator/CMakeLists.txt | 4 +- examples/particle_advection/CMakeLists.txt | 4 +- .../polyline_archimedean_helix/CMakeLists.txt | 6 +- examples/redistribute_points/CMakeLists.txt | 4 +- examples/smoke_test/CMakeLists.txt | 4 +- examples/streamline_mpi/CMakeLists.txt | 4 +- examples/temporal_advection/CMakeLists.txt | 4 +- examples/tetrahedra/CMakeLists.txt | 6 +- vtkm/cont/CMakeLists.txt | 12 +-- vtkm/cont/cuda/internal/CMakeLists.txt | 2 +- vtkm/cont/cuda/vtkm.module | 2 +- vtkm/cont/openmp/internal/CMakeLists.txt | 2 +- vtkm/cont/openmp/vtkm.module | 2 +- vtkm/cont/tbb/internal/CMakeLists.txt | 2 +- vtkm/cont/tbb/vtkm.module | 2 +- vtkm/exec/cuda/vtkm.module | 2 +- vtkm/exec/openmp/vtkm.module | 2 +- vtkm/exec/tbb/vtkm.module | 2 +- vtkm/filter/CMakeLists.txt | 2 +- vtkm/thirdparty/diy/CMakeLists.txt | 3 +- vtkm/thirdparty/lcl/CMakeLists.txt | 3 +- vtkm/thirdparty/lodepng/CMakeLists.txt | 2 +- vtkm/thirdparty/loguru/CMakeLists.txt | 3 +- vtkm/thirdparty/optionparser/CMakeLists.txt | 3 +- vtkm/worklet/testing/CMakeLists.txt | 2 +- 50 files changed, 285 insertions(+), 132 deletions(-) create mode 100644 docs/changelog/vtkm-cmake-targets-namespaces.md diff --git a/CMake/VTKmCPUVectorization.cmake b/CMake/VTKmCPUVectorization.cmake index 87628f7f0..a80484451 100644 --- a/CMake/VTKmCPUVectorization.cmake +++ b/CMake/VTKmCPUVectorization.cmake @@ -62,6 +62,12 @@ if(TARGET vtkm_vectorization_flags) endif() add_library(vtkm_vectorization_flags INTERFACE) +set_target_properties( + vtkm_vectorization_flags + PROPERTIES + EXPORT_NAME vectorization_flags + ) + if(NOT VTKm_INSTALL_ONLY_LIBRARIES) install(TARGETS vtkm_vectorization_flags EXPORT ${VTKm_EXPORT_NAME}) endif() @@ -193,7 +199,7 @@ target_compile_options(vtkm_vectorization_flags INTERFACE $<$:${flags}> ) -if(TARGET vtkm::cuda AND flags AND NOT CMAKE_CUDA_HOST_COMPILER) +if(TARGET vtkm_cuda AND flags AND NOT CMAKE_CUDA_HOST_COMPILER) # Also propagate down these optimizations when building host side code # with cuda. To be safe we only do this when we know the C++ and CUDA # host compiler are from the same vendor diff --git a/CMake/VTKmCompilerFlags.cmake b/CMake/VTKmCompilerFlags.cmake index a145f4cb9..d37ba3a69 100644 --- a/CMake/VTKmCompilerFlags.cmake +++ b/CMake/VTKmCompilerFlags.cmake @@ -30,6 +30,11 @@ endif() # vtkm_compiler_flags is used by all the vtkm targets and consumers of VTK-m # The flags on vtkm_compiler_flags are needed when using/building vtk-m add_library(vtkm_compiler_flags INTERFACE) +set_target_properties( + vtkm_compiler_flags + PROPERTIES + EXPORT_NAME compiler_flags + ) # When building libraries/tests that are part of the VTK-m repository # inherit the properties from vtkm_vectorization_flags. @@ -50,12 +55,12 @@ target_compile_features(vtkm_compiler_flags INTERFACE cxx_std_14) # they don't use. if(VTKM_COMPILER_IS_MSVC) target_compile_options(vtkm_compiler_flags INTERFACE $<$:/Gy>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler="/Gy">) endif() elseif(NOT (VTKM_COMPILER_IS_PGI OR VTKM_COMPILER_IS_XL)) #can't find an equivalant PGI/XL flag target_compile_options(vtkm_compiler_flags INTERFACE $<$:-ffunction-sections>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler=-ffunction-sections>) endif() endif() @@ -63,7 +68,7 @@ endif() # Enable large object support so we can have 2^32 addressable sections if(VTKM_COMPILER_IS_MSVC) target_compile_options(vtkm_compiler_flags INTERFACE $<$:/bigobj>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_compiler_flags INTERFACE $<$:-Xcompiler="/bigobj">) endif() endif() @@ -79,6 +84,11 @@ target_include_directories(vtkm_compiler_flags INTERFACE # vtkm_developer_flags is used ONLY BY libraries that are built as part of this # repository add_library(vtkm_developer_flags INTERFACE) +set_target_properties( + vtkm_developer_flags + PROPERTIES + EXPORT_NAME developer_flags + ) # Additional warnings just for Clang 3.5+, and AppleClang 7+ # about failures to vectorize. @@ -101,7 +111,7 @@ if(VTKM_COMPILER_IS_MSVC) #Setup MSVC warnings with CUDA and CXX target_compile_options(vtkm_developer_flags INTERFACE $<$:${cxx_flags}>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:${cuda_flags} -Xcudafe=--diag_suppress=1394,--diag_suppress=766>) endif() @@ -109,7 +119,7 @@ if(VTKM_COMPILER_IS_MSVC) # In VS2013 the C4127 warning has a bug in the implementation and # generates false positive warnings for lots of template code target_compile_options(vtkm_developer_flags INTERFACE $<$:-wd4127>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:-Xcompiler=-wd4127>) endif() endif() @@ -165,7 +175,7 @@ elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG) endif() target_compile_options(vtkm_developer_flags INTERFACE $<$:${cxx_flags}>) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) target_compile_options(vtkm_developer_flags INTERFACE $<$:${cuda_flags}>) endif() endif() @@ -176,10 +186,10 @@ function(setup_cuda_flags) endfunction() #common warnings for all platforms when building cuda -if ((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda)) +if ((TARGET vtkm_cuda) OR (TARGET vtkm::kokkos_cuda)) setup_cuda_flags() endif() if(NOT VTKm_INSTALL_ONLY_LIBRARIES) - install(TARGETS vtkm_compiler_flags vtkm_developer_flags EXPORT ${VTKm_EXPORT_NAME}) + vtkm_install_targets(TARGETS vtkm_compiler_flags vtkm_developer_flags) endif() diff --git a/CMake/VTKmConfig.cmake.in b/CMake/VTKmConfig.cmake.in index cffbab5c9..8c29b3eb6 100644 --- a/CMake/VTKmConfig.cmake.in +++ b/CMake/VTKmConfig.cmake.in @@ -10,22 +10,22 @@ # When this file is run by CMake through the find_package command, the # following targets will exist: -# vtkm_cont Target that contains most of VTK-m +# vtkm::cont Target that contains most of VTK-m # -# vtkm_rendering Target that contains all the rendering code +# vtkm::rendering Target that contains all the rendering code # -# vtkm_filter Target that contains all of VTK-m pre-built filters +# vtkm::filter Target that contains all of VTK-m pre-built filters # -# vtkm_source Target that contains all of VTK-m pre-built sources +# vtkm::source Target that contains all of VTK-m pre-built sources # -# vtkm::tbb Target that contains tbb related link information -# implicitly linked to by `vtkm_cont` if tbb is enabled +# vtkm::tbb Target that contains tbb related link information +# implicitly linked to by `vtkm_cont` if tbb is enabled # -# vtkm::openmp Target that contains openmp related link information -# implicitly linked to by `vtkm_cont` if openmp is enabled +# vtkm::openmp Target that contains openmp related link information +# implicitly linked to by `vtkm_cont` if openmp is enabled # -# vtkm::cuda Target that contains cuda related link information -# implicitly linked to by `vtkm_cont` if cuda is enabled +# vtkm::cuda Target that contains cuda related link information +# implicitly linked to by `vtkm_cont` if cuda is enabled # # The following local variables will also be defined: # @@ -47,7 +47,6 @@ # VTKm_ENABLE_OSMESA_CONTEXT Will be enabled if VTK-m rendering was built with a osmesa context # VTKm_ENABLE_EGL_CONTEXT Will be enabled if VTK-m rendering was built with a EGL context # -# if (CMAKE_VERSION VERSION_LESS "3.12") message(FATAL_ERROR "VTK-m requires CMake 3.12+") @@ -109,11 +108,20 @@ set(VTKM_FROM_INSTALL_DIR FALSE) if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "@VTKm_BINARY_DIR@") set(VTKM_FROM_INSTALL_DIR TRUE) include(${VTKm_CONFIG_DIR}/VTKmTargets.cmake) + + if(DEFINED PACKAGE_FIND_VERSION AND PACKAGE_FIND_VERSION VERSION_LESS 2.0) + add_library(vtkm_cont ALIAS vtkm::cont) + add_library(vtkm_filter ALIAS vtkm::filter) + add_library(vtkm_io ALIAS vtkm::io) + add_library(vtkm_rendering ALIAS vtkm::rendering) + add_library(vtkm_source ALIAS vtkm::source) + add_library(vtkm_worklet ALIAS vtkm::worklet) + endif() endif() # Once we can require CMake 3.15 for all cuda builds we can # replace this with setting `cuda_architecture_flags` as part of the -# EXPORT_PROPERTIES of the vtkm_cuda target +# EXPORT_PROPERTIES of the vtkm::cuda target if(VTKm_ENABLE_CUDA AND VTKM_FROM_INSTALL_DIR) # Canonical way of setting CUDA arch if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) diff --git a/CMake/VTKmDIYUtils.cmake b/CMake/VTKmDIYUtils.cmake index 1594ba1fe..d88082397 100644 --- a/CMake/VTKmDIYUtils.cmake +++ b/CMake/VTKmDIYUtils.cmake @@ -8,6 +8,14 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ +macro(vtkm_diy_get_general_target target) + if(CMAKE_PROJECT_NAME STREQUAL "VTKm") + set(${target} "vtkm_diy") + else() + set(${target} "vtkm::diy") + endif() +endmacro() + macro(_vtkm_diy_target flag target) set(${target} "vtkmdiympi") if (NOT ${flag}) @@ -19,7 +27,8 @@ function(vtkm_diy_init_target) set(vtkm_diy_default_flag "${VTKm_ENABLE_MPI}") _vtkm_diy_target(vtkm_diy_default_flag vtkm_diy_default_target) - set_target_properties(vtkm_diy PROPERTIES + vtkm_diy_get_general_target(diy_target) + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack ${vtkm_diy_default_flag} vtkm_diy_target ${vtkm_diy_default_target}) endfunction() @@ -30,30 +39,33 @@ function(vtkm_diy_use_mpi_push) if (NOT ARGC EQUAL 0) set(topval ${ARGV0}) endif() - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (APPEND stack ${topval}) _vtkm_diy_target(topval target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() function(vtkm_diy_use_mpi value) - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (REMOVE_AT stack -1) list (APPEND stack ${value}) _vtkm_diy_target(value target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() function(vtkm_diy_use_mpi_pop) - get_target_property(stack vtkm_diy vtkm_diy_use_mpi_stack) + vtkm_diy_get_general_target(diy_target) + get_target_property(stack ${diy_target} vtkm_diy_use_mpi_stack) list (GET stack -1 value) list (REMOVE_AT stack -1) _vtkm_diy_target(value target) - set_target_properties(vtkm_diy PROPERTIES + set_target_properties(${diy_target} PROPERTIES vtkm_diy_use_mpi_stack "${stack}" vtkm_diy_target "${target}") endfunction() diff --git a/CMake/VTKmDeviceAdapters.cmake b/CMake/VTKmDeviceAdapters.cmake index 257f2f767..e87f05357 100644 --- a/CMake/VTKmDeviceAdapters.cmake +++ b/CMake/VTKmDeviceAdapters.cmake @@ -41,38 +41,39 @@ function(vtkm_extract_real_library library real_library) endif() endfunction() -if(VTKm_ENABLE_TBB AND NOT TARGET vtkm::tbb) +if(VTKm_ENABLE_TBB AND NOT TARGET vtkm_tbb) # Skip find_package(TBB) if we already have it if (NOT TARGET TBB::tbb) find_package(TBB REQUIRED) endif() - add_library(vtkmTBB INTERFACE) - add_library(vtkm::tbb ALIAS vtkmTBB) - target_link_libraries(vtkmTBB INTERFACE TBB::tbb) - target_compile_definitions(vtkmTBB INTERFACE "TBB_VERSION_MAJOR=${TBB_VERSION_MAJOR}") - set_target_properties(vtkmTBB PROPERTIES EXPORT_NAME vtkm::tbb) - install(TARGETS vtkmTBB EXPORT ${VTKm_EXPORT_NAME}) + add_library(vtkm_tbb INTERFACE) + target_link_libraries(vtkm_tbb INTERFACE TBB::tbb) + target_compile_definitions(vtkm_tbb INTERFACE "TBB_VERSION_MAJOR=${TBB_VERSION_MAJOR}") + set_target_properties(vtkm_tbb PROPERTIES EXPORT_NAME tbb) + install(TARGETS vtkm_tbb EXPORT ${VTKm_EXPORT_NAME}) endif() -if(VTKm_ENABLE_OPENMP AND NOT TARGET vtkm::openmp) +if(VTKm_ENABLE_OPENMP AND NOT TARGET vtkm_openmp) find_package(OpenMP 4.0 REQUIRED COMPONENTS CXX QUIET) - add_library(vtkm::openmp INTERFACE IMPORTED GLOBAL) + add_library(vtkm_openmp INTERFACE) + set_target_properties(vtkm_openmp PROPERTIES EXPORT_NAME openmp) if(OpenMP_CXX_FLAGS) - set_property(TARGET vtkm::openmp + set_property(TARGET vtkm_openmp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${OpenMP_CXX_FLAGS}>) if(VTKm_ENABLE_CUDA) string(REPLACE ";" "," openmp_cuda_flags "-Xcompiler=${OpenMP_CXX_FLAGS}") - set_property(TARGET vtkm::openmp + set_property(TARGET vtkm_openmp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${openmp_cuda_flags}>) endif() endif() if(OpenMP_CXX_LIBRARIES) - set_target_properties(vtkm::openmp PROPERTIES + set_target_properties(vtkm_openmp PROPERTIES INTERFACE_LINK_LIBRARIES "${OpenMP_CXX_LIBRARIES}") endif() + install(TARGETS vtkm_openmp EXPORT ${VTKm_EXPORT_NAME}) endif() if(VTKm_ENABLE_CUDA) @@ -84,10 +85,9 @@ if(VTKm_ENABLE_CUDA) message(FATAL_ERROR "VTK-m CUDA support requires version 9.2+") endif() - if(NOT TARGET vtkm::cuda) + if(NOT TARGET vtkm_cuda) add_library(vtkm_cuda INTERFACE) - add_library(vtkm::cuda ALIAS vtkm_cuda) - set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda) + set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME cuda) install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME}) # Reserve `requires_static_builds` to potential work around issues diff --git a/CMake/VTKmRenderingContexts.cmake b/CMake/VTKmRenderingContexts.cmake index 6987fc40c..bb5dfbaa2 100644 --- a/CMake/VTKmRenderingContexts.cmake +++ b/CMake/VTKmRenderingContexts.cmake @@ -92,10 +92,9 @@ endif() #----------------------------------------------------------------------------- if(VTKm_ENABLE_RENDERING AND NOT TARGET vtkm_rendering_gl_context) add_library(vtkm_rendering_gl_context INTERFACE) + if(NOT VTKm_INSTALL_ONLY_LIBRARIES) - install(TARGETS vtkm_rendering_gl_context - EXPORT ${VTKm_EXPORT_NAME} - ) + vtkm_install_targets(TARGETS vtkm_rendering_gl_context) endif() endif() diff --git a/CMake/VTKmWrappers.cmake b/CMake/VTKmWrappers.cmake index 4ed03d715..3284a6279 100644 --- a/CMake/VTKmWrappers.cmake +++ b/CMake/VTKmWrappers.cmake @@ -197,7 +197,7 @@ endfunction() # # If VTK-m was built with CMake 3.18+ and you are using CMake 3.18+ and have # a cmake_minimum_required of 3.18 or have set policy CMP0105 to new, this will -# return an empty string as the `vtkm::cuda` target will correctly propagate +# return an empty string as the `vtkm_cuda` target will correctly propagate # all the necessary flags. # # This is required for CMake < 3.18 as they don't support the `$` @@ -211,11 +211,11 @@ endfunction() # function(vtkm_get_cuda_flags settings_var) - if(TARGET vtkm::cuda) + if(TARGET vtkm_cuda) if(POLICY CMP0105) cmake_policy(GET CMP0105 does_device_link) get_property(arch_flags - TARGET vtkm::cuda + TARGET vtkm_cuda PROPERTY INTERFACE_LINK_OPTIONS) if(arch_flags AND CMP0105 STREQUAL "NEW") return() @@ -223,7 +223,7 @@ function(vtkm_get_cuda_flags settings_var) endif() get_property(arch_flags - TARGET vtkm::cuda + TARGET vtkm_cuda PROPERTY cuda_architecture_flags) set(${settings_var} "${${settings_var}} ${arch_flags}" PARENT_SCOPE) endif() @@ -259,6 +259,66 @@ function(vtkm_add_drop_unused_function_flags uses_vtkm_target) endif() endfunction() +#----------------------------------------------------------------------------- +# This function takes a target name and returns the mangled version of its name +# in a form that complies with the VTK-m export target naming scheme. +macro(vtkm_target_mangle output target) + string(REPLACE "vtkm_" "" ${output} ${target}) +endmacro() + +#----------------------------------------------------------------------------- +# Enable VTK-m targets to be installed. +# +# This function decorates the `install` CMake function mangling the exported +# target names to comply with the VTK-m exported target names scheme. Use this +# function instead of the canonical CMake `install` function for VTK-m targets. +# +# Signature: +# vtkm_install_targets( +# TARGETS +# [EXPORT ] +# [ARGS ] +# ) +# +# Usage: +# add_library(vtkm_library) +# vtkm_install_targets(TARGETS vtkm_library ARGS COMPONENT core) +# +# TARGETS: List of targets to be installed. +# +# EXPORT: [OPTIONAL] The name of the export set to which this target will be +# added. If omitted vtkm_install_targets will use the value of +# VTKm_EXPORT_NAME by default. +# +# ARGS: [OPTIONAL] Any argument other than `TARGETS` and `EXPORT` accepted +# by the `install` CMake function: +# +# +function(vtkm_install_targets) + set(oneValueArgs EXPORT) + set(multiValueArgs TARGETS ARGS) + cmake_parse_arguments(VTKm_INSTALL "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(export_name ${VTKm_EXPORT_NAME}) + if(VTKm_INSTALL_EXPORT) + set(export_name ${VTKm_INSTALL_EXPORT}) + endif() + + if(NOT DEFINED VTKm_INSTALL_TARGETS) + message(FATAL_ERROR "vtkm_install_targets invoked without TARGETS arguments.") + endif() + + if(DEFINED VTKm_INSTALL_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "vtkm_install_targets missing ARGS keyword prepending install arguments") + endif() + + foreach(tgt IN LISTS VTKm_INSTALL_TARGETS) + vtkm_target_mangle(tgt_mangled ${tgt}) + set_target_properties(${tgt} PROPERTIES EXPORT_NAME ${tgt_mangled}) + endforeach() + + install(TARGETS ${VTKm_INSTALL_TARGETS} EXPORT ${export_name} ${VTKm_INSTALL_ARGS}) +endfunction(vtkm_install_targets) #----------------------------------------------------------------------------- # Add a relevant information to target that wants to use VTK-m. @@ -301,7 +361,7 @@ endfunction() # # If VTK-m was built with CMake 3.18+ and you are using CMake 3.18+ and have # a cmake_minimum_required of 3.18 or have set policy CMP0105 to new, this will -# return an empty string as the `vtkm::cuda` target will correctly propagate +# return an empty string as the `vtkm_cuda` target will correctly propagate # all the necessary flags. # # Note: calling `vtkm_add_target_information` multiple times with @@ -374,7 +434,7 @@ function(vtkm_add_target_information uses_vtkm_target) endforeach() endif() - if((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda)) + if((TARGET vtkm_cuda) OR (TARGET vtkm::kokkos_cuda)) set_source_files_properties(${VTKm_TI_DEVICE_SOURCES} PROPERTIES LANGUAGE "CUDA") elseif(TARGET vtkm::kokkos_hip) set_source_files_properties(${VTKm_TI_DEVICE_SOURCES} PROPERTIES LANGUAGE "HIP") @@ -513,8 +573,7 @@ function(vtkm_library) endif() #install the library itself - install(TARGETS ${lib_name} - EXPORT ${VTKm_EXPORT_NAME} + vtkm_install_targets(TARGETS ${lib_name} ARGS ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR} LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR} RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR} diff --git a/CMakeLists.txt b/CMakeLists.txt index fc9c766d3..31572a24b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,9 +412,11 @@ if(NOT VTKm_INSTALL_ONLY_LIBRARIES) # Create and install exports for external projects export(EXPORT ${VTKm_EXPORT_NAME} + NAMESPACE vtkm:: FILE ${VTKm_BUILD_CMAKE_BASE_DIR}/${VTKm_INSTALL_CONFIG_DIR}/VTKmTargets.cmake ) install(EXPORT ${VTKm_EXPORT_NAME} + NAMESPACE vtkm:: DESTINATION ${VTKm_INSTALL_CONFIG_DIR} FILE VTKmTargets.cmake ) diff --git a/docs/changelog/vtkm-cmake-targets-namespaces.md b/docs/changelog/vtkm-cmake-targets-namespaces.md new file mode 100644 index 000000000..ad1101855 --- /dev/null +++ b/docs/changelog/vtkm-cmake-targets-namespaces.md @@ -0,0 +1,42 @@ +# VTK-m namespace for its exported CMake targets + +VTK-m exported CMake targets are now prefixed with the `vtkm::` namespace. + +## What it means for VTK-m users + +VTK-m users will now need to prepend a `vtkm::` prefix when they refer to a +VTK-m CMake target in their projects as shown below: + +``` +add_executable(example example.cxx) +# Before: +target_link_libraries(example vtkm_cont vtkm_rendering) +# Now: +target_link_libraries(example vtkm::cont vtkm::rendering) +``` + +For compatibility purposes we still provide additional exported targets with the +previous naming scheme, in the form of `vtkm_TARGET`, when VTK-m is found +using: + +``` +# With any version less than 2.0 +find_package(VTK-m 1.9) + +add_executable(example example.cxx) +# This is still valid +target_link_libraries(example vtkm_cont vtkm_rendering) +``` + +Use with care since we might remove those targets in future releases. + +## What it means for VTK-m developers + +While VTK-m exported targets are now prefixed with the `vtkm::` prefix, internal +target names are still in the form of `vtkm_TARGET`. + +To perform this name transformation in VTK-m targets a new CMake function has +been provided that decorates the canonical `install` routine. Use this functions +instead of `install` when creating new `VTK-m` targets, further information can +be found at the `vtkm_install_targets` function header at +`CMake/VTKmWrappers.cmake`. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 26b66c494..e291ee6a6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,10 +8,27 @@ ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -#add the directory that contains the VTK-m config file to the cmake -#path so that our examples can find VTK-m - if(VTKm_ENABLE_EXAMPLES) + # VTKm examples expects vtkm libraries to be namespaced with the prefix vtkm::. + # However as the examples are also built as just another part of the VTK-m code + # those prefix are not added to the targets (This happens during the + # installation). To workaround this issue here, we create IMPORTED libs linking + # to the vtkm libraries used by the examples with expected the vtkm:: prefix. + vtkm_module_get_list(module_list) + foreach(tgt IN LISTS module_list) + if(TARGET ${tgt}) + # The reason of creating this phony IMPORTED libraries instead of making + # ALIAS libraries is that ALIAS libraries are GLOBAL whereas IMPORTED are + # local at the directory level where they are created. We do not want these + # phony targets to be visible outside of the example directory. + vtkm_target_mangle(tgt_name_mangled ${tgt}) + add_library("vtkm::${tgt_name_mangled}" INTERFACE IMPORTED) + target_link_libraries("vtkm::${tgt_name_mangled}" INTERFACE ${tgt}) + endif() + endforeach() + + #add the directory that contains the VTK-m config file to the cmake + #path so that our examples can find VTK-m set(CMAKE_PREFIX_PATH ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR}) add_subdirectory(clipping) add_subdirectory(contour_tree) diff --git a/examples/clipping/CMakeLists.txt b/examples/clipping/CMakeLists.txt index d057a70d3..d4e08d711 100644 --- a/examples/clipping/CMakeLists.txt +++ b/examples/clipping/CMakeLists.txt @@ -13,7 +13,7 @@ project(Clipping CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_contour AND TARGET vtkm_io) +if(TARGET vtkm::filter_contour AND TARGET vtkm::io) add_executable(Clipping Clipping.cxx) - target_link_libraries(Clipping PRIVATE vtkm_filter_contour vtkm_io) + target_link_libraries(Clipping PRIVATE vtkm::filter_contour vtkm::io) endif() diff --git a/examples/contour_tree/CMakeLists.txt b/examples/contour_tree/CMakeLists.txt index 338de0d6a..94e4a9c74 100644 --- a/examples/contour_tree/CMakeLists.txt +++ b/examples/contour_tree/CMakeLists.txt @@ -13,10 +13,10 @@ project(ContourTree CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if (TARGET vtkm_filter_scalar_topology) +if (TARGET vtkm::filter_scalar_topology) add_executable(ContourTreeMesh2D ContourTreeMesh2D.cxx) - target_link_libraries(ContourTreeMesh2D vtkm_filter_core vtkm_filter_scalar_topology) + target_link_libraries(ContourTreeMesh2D vtkm::filter_core vtkm::filter_scalar_topology) add_executable(ContourTreeMesh3D ContourTreeMesh3D.cxx) - target_link_libraries(ContourTreeMesh3D vtkm_filter_core vtkm_filter_scalar_topology) + target_link_libraries(ContourTreeMesh3D vtkm::filter_core vtkm::filter_scalar_topology) endif() diff --git a/examples/contour_tree_augmented/CMakeLists.txt b/examples/contour_tree_augmented/CMakeLists.txt index ad680fa09..68a4d0bc5 100644 --- a/examples/contour_tree_augmented/CMakeLists.txt +++ b/examples/contour_tree_augmented/CMakeLists.txt @@ -55,7 +55,7 @@ cmake_minimum_required(VERSION 3.12...3.15 FATAL_ERROR) # Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(NOT TARGET vtkm_io OR NOT TARGET vtkm_filter_scalar_topology) +if(NOT TARGET vtkm::io OR NOT TARGET vtkm::filter_scalar_topology) # Libraries needed are not built. return() endif() @@ -64,7 +64,7 @@ endif() # Serial #################################### add_executable(ContourTree_Augmented ContourTreeApp.cxx) -target_link_libraries(ContourTree_Augmented vtkm_filter_scalar_topology vtkm_io) +target_link_libraries(ContourTree_Augmented vtkm::filter_scalar_topology vtkm::io) vtkm_add_target_information(ContourTree_Augmented DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) @@ -84,7 +84,7 @@ endif() #################################### if (VTKm_ENABLE_MPI) add_executable(ContourTree_Augmented_MPI ContourTreeApp.cxx) - target_link_libraries(ContourTree_Augmented_MPI vtkm_filter_scalar_topology vtkm_io MPI::MPI_CXX) + target_link_libraries(ContourTree_Augmented_MPI vtkm::filter_scalar_topology vtkm::io MPI::MPI_CXX) vtkm_add_target_information(ContourTree_Augmented_MPI MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) diff --git a/examples/contour_tree_distributed/CMakeLists.txt b/examples/contour_tree_distributed/CMakeLists.txt index 525c5bf7c..cfa47b349 100644 --- a/examples/contour_tree_distributed/CMakeLists.txt +++ b/examples/contour_tree_distributed/CMakeLists.txt @@ -58,9 +58,9 @@ find_package(VTKm REQUIRED QUIET) #################################### # MPI #################################### -if (VTKm_ENABLE_MPI AND TARGET vtkm_filter_scalar_topology AND TARGET vtkm_io) +if (VTKm_ENABLE_MPI AND TARGET vtkm::filter_scalar_topology AND TARGET vtkm::io) add_executable(ContourTree_Distributed ContourTreeApp.cxx) - target_link_libraries(ContourTree_Distributed vtkm_filter_scalar_topology vtkm_io MPI::MPI_CXX) + target_link_libraries(ContourTree_Distributed vtkm::filter_scalar_topology vtkm::io MPI::MPI_CXX) vtkm_add_target_information(ContourTree_Distributed MODIFY_CUDA_FLAGS DEVICE_SOURCES ContourTreeApp.cxx) @@ -78,11 +78,11 @@ if (VTKm_ENABLE_MPI AND TARGET vtkm_filter_scalar_topology AND TARGET vtkm_io) endif() add_executable(TreeCompiler TreeCompilerApp.cxx) - target_link_libraries(TreeCompiler vtkm_filter_core) + target_link_libraries(TreeCompiler vtkm::filter_core) vtkm_add_target_information(TreeCompiler DROP_UNUSED_SYMBOLS) add_executable(BranchCompiler BranchCompilerApp.cxx) - target_link_libraries(BranchCompiler vtkm_filter) + target_link_libraries(BranchCompiler vtkm::filter) vtkm_add_target_information(BranchCompiler DROP_UNUSED_SYMBOLS) configure_file(split_data_2d.py split_data_2d.py COPYONLY) diff --git a/examples/cosmotools/CMakeLists.txt b/examples/cosmotools/CMakeLists.txt index 489715342..6a4ad951c 100644 --- a/examples/cosmotools/CMakeLists.txt +++ b/examples/cosmotools/CMakeLists.txt @@ -15,8 +15,8 @@ find_package(VTKm REQUIRED QUIET) add_executable(CosmoCenterFinder CosmoCenterFinder.cxx) add_executable(CosmoHaloFinder CosmoHaloFinder.cxx) -target_link_libraries(CosmoCenterFinder PRIVATE vtkm_filter_core) -target_link_libraries(CosmoHaloFinder PRIVATE vtkm_filter_core) +target_link_libraries(CosmoCenterFinder PRIVATE vtkm::filter_core) +target_link_libraries(CosmoHaloFinder PRIVATE vtkm::filter_core) vtkm_add_target_information(CosmoCenterFinder CosmoHaloFinder DROP_UNUSED_SYMBOLS diff --git a/examples/demo/CMakeLists.txt b/examples/demo/CMakeLists.txt index 1084eef18..d088a37cc 100644 --- a/examples/demo/CMakeLists.txt +++ b/examples/demo/CMakeLists.txt @@ -13,7 +13,7 @@ project(VTKmDemo CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_rendering AND TARGET vtkm_filter_contour AND TARGET vtkm_source) +if(TARGET vtkm::rendering AND TARGET vtkm::filter_contour AND TARGET vtkm::source) add_executable(Demo Demo.cxx) - target_link_libraries(Demo PRIVATE vtkm_rendering vtkm_filter_contour vtkm_source) + target_link_libraries(Demo PRIVATE vtkm::rendering vtkm::filter_contour vtkm::source) endif() diff --git a/examples/game_of_life/CMakeLists.txt b/examples/game_of_life/CMakeLists.txt index c15a41642..61ade086c 100644 --- a/examples/game_of_life/CMakeLists.txt +++ b/examples/game_of_life/CMakeLists.txt @@ -19,7 +19,7 @@ if(TARGET OpenGL::GL AND TARGET GLEW::GLEW) add_executable(GameOfLife GameOfLife.cxx LoadShaders.h) - target_link_libraries(GameOfLife PRIVATE vtkm_filter OpenGL::GL GLEW::GLEW GLUT::GLUT) + target_link_libraries(GameOfLife PRIVATE vtkm::filter_core OpenGL::GL GLEW::GLEW GLUT::GLUT) vtkm_add_target_information(GameOfLife DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES GameOfLife.cxx) diff --git a/examples/hello_worklet/CMakeLists.txt b/examples/hello_worklet/CMakeLists.txt index b9b69f2ab..f5d87197f 100644 --- a/examples/hello_worklet/CMakeLists.txt +++ b/examples/hello_worklet/CMakeLists.txt @@ -13,9 +13,9 @@ project(HelloWorklet CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_io) +if(TARGET vtkm::io) add_executable(HelloWorklet HelloWorklet.cxx) - target_link_libraries(HelloWorklet PRIVATE vtkm_filter_core vtkm_io) + target_link_libraries(HelloWorklet PRIVATE vtkm::filter_core vtkm::io) vtkm_add_target_information(HelloWorklet DROP_UNUSED_SYMBOLS diff --git a/examples/histogram/CMakeLists.txt b/examples/histogram/CMakeLists.txt index 4f366fd03..81210e81a 100644 --- a/examples/histogram/CMakeLists.txt +++ b/examples/histogram/CMakeLists.txt @@ -12,12 +12,12 @@ project(Histogram CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if (VTKm_ENABLE_MPI AND vtkm_filter_density_estimate) +if (VTKm_ENABLE_MPI AND vtkm::filter_density_estimate) # TODO: this example desperately needs to be updated. The histogram filter has # improved immensely since this has originally been written, and the code can # be simplified a lot, which will make it more illustrative of using VTK-m. add_executable(Histogram Histogram.cxx HistogramMPI.h HistogramMPI.cxx) - target_link_libraries(Histogram PRIVATE vtkm_filter_density_estimate MPI::MPI_CXX) + target_link_libraries(Histogram PRIVATE vtkm::filter_density_estimate MPI::MPI_CXX) vtkm_add_target_information(Histogram DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES HistogramMPI.cxx) diff --git a/examples/ising/CMakeLists.txt b/examples/ising/CMakeLists.txt index 31ac175ae..b0c45c1ae 100644 --- a/examples/ising/CMakeLists.txt +++ b/examples/ising/CMakeLists.txt @@ -13,9 +13,9 @@ project(IsingModel CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_rendering) +if(TARGET vtkm::rendering) add_executable(Ising Ising.cxx) - target_link_libraries(Ising PRIVATE vtkm_worklet vtkm_rendering) + target_link_libraries(Ising PRIVATE vtkm::worklet vtkm::rendering) vtkm_add_target_information(Ising DROP_UNUSED_SYMBOLS diff --git a/examples/lagrangian/CMakeLists.txt b/examples/lagrangian/CMakeLists.txt index 2f7877e66..341f78584 100644 --- a/examples/lagrangian/CMakeLists.txt +++ b/examples/lagrangian/CMakeLists.txt @@ -12,7 +12,7 @@ cmake_minimum_required(VERSION 3.12...3.15 FATAL_ERROR) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_flow) +if(TARGET vtkm::filter_flow) add_executable(Lagrangian lagrangian.cxx ABCfield.h) - target_link_libraries(Lagrangian PRIVATE vtkm_filter_flow) + target_link_libraries(Lagrangian PRIVATE vtkm::filter_flow) endif() diff --git a/examples/lagrangian_structures/CMakeLists.txt b/examples/lagrangian_structures/CMakeLists.txt index a64aa0187..80406f8f3 100644 --- a/examples/lagrangian_structures/CMakeLists.txt +++ b/examples/lagrangian_structures/CMakeLists.txt @@ -16,7 +16,7 @@ project(ParticleAdvection CXX) find_package(VTKm REQUIRED QUIET) add_executable(ftle LagrangianStructures.cxx) -target_link_libraries(ftle PRIVATE vtkm_cont vtkm_worklet) +target_link_libraries(ftle PRIVATE vtkm::cont vtkm::worklet) vtkm_add_target_information(ftle DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES LagrangianStructures.cxx) diff --git a/examples/logistic_map/CMakeLists.txt b/examples/logistic_map/CMakeLists.txt index 65f74d4f5..0f478c640 100644 --- a/examples/logistic_map/CMakeLists.txt +++ b/examples/logistic_map/CMakeLists.txt @@ -12,9 +12,9 @@ project(LogisticMap CXX) find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_io) +if(TARGET vtkm::io) add_executable(LogisticMap LogisticMap.cxx) - target_link_libraries(LogisticMap PRIVATE vtkm_io) + target_link_libraries(LogisticMap PRIVATE vtkm::io) vtkm_add_target_information(LogisticMap DROP_UNUSED_SYMBOLS diff --git a/examples/mesh_quality/CMakeLists.txt b/examples/mesh_quality/CMakeLists.txt index 28da130ea..66abdb9ee 100644 --- a/examples/mesh_quality/CMakeLists.txt +++ b/examples/mesh_quality/CMakeLists.txt @@ -25,7 +25,7 @@ project(MeshQuality CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_mesh_info AND TARGET vtkm_io) +if(TARGET vtkm::filter_mesh_info AND TARGET vtkm::io) add_executable(MeshQuality MeshQuality.cxx) - target_link_libraries(MeshQuality PRIVATE vtkm_filter_mesh_info vtkm_io) + target_link_libraries(MeshQuality PRIVATE vtkm::filter_mesh_info vtkm::io) endif() diff --git a/examples/multi_backend/CMakeLists.txt b/examples/multi_backend/CMakeLists.txt index f46dd8a0a..67cdcba9f 100644 --- a/examples/multi_backend/CMakeLists.txt +++ b/examples/multi_backend/CMakeLists.txt @@ -26,9 +26,9 @@ set(srcs IOGenerator.cxx ) -if(TARGET vtkm_filter_vector_analysis) +if(TARGET vtkm::filter_vector_analysis) add_executable(MultiBackend ${srcs} ${headers}) - target_link_libraries(MultiBackend PRIVATE vtkm_filter_vector_analysis Threads::Threads) + target_link_libraries(MultiBackend PRIVATE vtkm::filter_vector_analysis Threads::Threads) vtkm_add_target_information(MultiBackend DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS diff --git a/examples/oscillator/CMakeLists.txt b/examples/oscillator/CMakeLists.txt index 671f40b23..fff62c3a8 100644 --- a/examples/oscillator/CMakeLists.txt +++ b/examples/oscillator/CMakeLists.txt @@ -13,7 +13,7 @@ project(Oscillator CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_source) +if(TARGET vtkm::source) add_executable(Oscillator Oscillator.cxx) - target_link_libraries(Oscillator PRIVATE vtkm_source) + target_link_libraries(Oscillator PRIVATE vtkm::source) endif() diff --git a/examples/particle_advection/CMakeLists.txt b/examples/particle_advection/CMakeLists.txt index c31242629..d270561e2 100644 --- a/examples/particle_advection/CMakeLists.txt +++ b/examples/particle_advection/CMakeLists.txt @@ -13,7 +13,7 @@ project(ParticleAdvection CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_flow AND TARGET vtkm_io) +if(TARGET vtkm::filter_flow AND TARGET vtkm::io) add_executable(Particle_Advection ParticleAdvection.cxx) - target_link_libraries(Particle_Advection PRIVATE vtkm_filter_flow vtkm_io) + target_link_libraries(Particle_Advection PRIVATE vtkm::filter_flow vtkm::io) endif() diff --git a/examples/polyline_archimedean_helix/CMakeLists.txt b/examples/polyline_archimedean_helix/CMakeLists.txt index e9cdaf95b..53852397b 100644 --- a/examples/polyline_archimedean_helix/CMakeLists.txt +++ b/examples/polyline_archimedean_helix/CMakeLists.txt @@ -12,13 +12,13 @@ project(PolyLineArchimedeanHelix CXX) find_package(VTKm REQUIRED QUIET) -if (TARGET vtkm_rendering) +if (TARGET vtkm::rendering) # TODO: This example should be changed from using the Tube worklet to using - # the Tube filter (in the vtkm_filter_geometry_refinement library). Then + # the Tube filter (in the vtkm::filter_geometry_refinement library). Then # compiling it would no longer require a device compiler and the example # would generally be simpler. add_executable(PolyLineArchimedeanHelix PolyLineArchimedeanHelix.cxx) - target_link_libraries(PolyLineArchimedeanHelix PRIVATE vtkm_rendering) + target_link_libraries(PolyLineArchimedeanHelix PRIVATE vtkm::rendering) vtkm_add_target_information(PolyLineArchimedeanHelix DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS diff --git a/examples/redistribute_points/CMakeLists.txt b/examples/redistribute_points/CMakeLists.txt index 4cd0fe949..34a073e0a 100644 --- a/examples/redistribute_points/CMakeLists.txt +++ b/examples/redistribute_points/CMakeLists.txt @@ -13,9 +13,9 @@ project(RedistributePoints CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_io AND TARGET vtkm_filter_entity_extraction) +if(TARGET vtkm::io AND TARGET vtkm::filter_entity_extraction) add_executable(RedistributePoints RedistributePoints.cxx RedistributePoints.h main.cxx) - target_link_libraries(RedistributePoints PRIVATE vtkm_io vtkm_filter_entity_extraction) + target_link_libraries(RedistributePoints PRIVATE vtkm::io vtkm::filter_entity_extraction) vtkm_add_target_information(RedistributePoints DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS diff --git a/examples/smoke_test/CMakeLists.txt b/examples/smoke_test/CMakeLists.txt index e18827d5c..d28f63352 100644 --- a/examples/smoke_test/CMakeLists.txt +++ b/examples/smoke_test/CMakeLists.txt @@ -14,9 +14,9 @@ include(CTest) find_package(VTKm REQUIRED) -if(TARGET vtkm_source) +if(TARGET vtkm::source) add_executable(smoke_test smoke_test.cxx) - target_link_libraries(smoke_test PRIVATE vtkm_source) + target_link_libraries(smoke_test PRIVATE vtkm::source) # Only add this test when this a standalone project if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) diff --git a/examples/streamline_mpi/CMakeLists.txt b/examples/streamline_mpi/CMakeLists.txt index b114a9f9a..8a298a146 100644 --- a/examples/streamline_mpi/CMakeLists.txt +++ b/examples/streamline_mpi/CMakeLists.txt @@ -13,8 +13,8 @@ project(StreamlineMPI CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if (VTKm_ENABLE_MPI AND TARGET vtkm_io AND TARGET vtkm_filter_flow) +if (VTKm_ENABLE_MPI AND TARGET vtkm::io AND TARGET vtkm::filter_flow) add_executable(StreamlineMPI StreamlineMPI.cxx) target_compile_definitions(StreamlineMPI PRIVATE "MPI_ENABLED") - target_link_libraries(StreamlineMPI PRIVATE vtkm_filter_flow vtkm_io MPI::MPI_CXX) + target_link_libraries(StreamlineMPI PRIVATE vtkm::filter_flow vtkm::io MPI::MPI_CXX) endif() diff --git a/examples/temporal_advection/CMakeLists.txt b/examples/temporal_advection/CMakeLists.txt index 9f7f86edc..6a2abfdf0 100644 --- a/examples/temporal_advection/CMakeLists.txt +++ b/examples/temporal_advection/CMakeLists.txt @@ -15,10 +15,10 @@ project(TemporalAdvection CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_flow AND TARGET vtkm_io) +if(TARGET vtkm::filter_flow AND TARGET vtkm::io) add_executable(Temporal_Advection TemporalAdvection.cxx) vtkm_add_target_information(Temporal_Advection DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS DEVICE_SOURCES TemporalAdvection.cxx) - target_link_libraries(Temporal_Advection PRIVATE vtkm_filter_flow vtkm_io) + target_link_libraries(Temporal_Advection PRIVATE vtkm::filter_flow vtkm::io) endif() diff --git a/examples/tetrahedra/CMakeLists.txt b/examples/tetrahedra/CMakeLists.txt index a86a76934..efc3630ad 100644 --- a/examples/tetrahedra/CMakeLists.txt +++ b/examples/tetrahedra/CMakeLists.txt @@ -13,10 +13,10 @@ project(Tetrahedra CXX) #Find the VTK-m package find_package(VTKm REQUIRED QUIET) -if(TARGET vtkm_filter_geometry_refinement AND TARGET vtkm_io) +if(TARGET vtkm::filter_geometry_refinement AND TARGET vtkm::io) add_executable(Tetrahedralize Tetrahedralize.cxx) - target_link_libraries(Tetrahedralize PRIVATE vtkm_filter_geometry_refinement vtkm_io) + target_link_libraries(Tetrahedralize PRIVATE vtkm::filter_geometry_refinement vtkm::io) add_executable(Triangulate Triangulate.cxx) - target_link_libraries(Triangulate PRIVATE vtkm_filter_geometry_refinement vtkm_io) + target_link_libraries(Triangulate PRIVATE vtkm::filter_geometry_refinement vtkm::io) endif() diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index 79607520c..17273aee9 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -271,14 +271,14 @@ add_subdirectory(internal) add_subdirectory(arg) set(backends ) -if(TARGET vtkm::tbb) - list(APPEND backends vtkm::tbb) +if(TARGET vtkm_tbb) + list(APPEND backends vtkm_tbb) endif() -if(TARGET vtkm::cuda) - list(APPEND backends vtkm::cuda) +if(TARGET vtkm_cuda) + list(APPEND backends vtkm_cuda) endif() -if(TARGET vtkm::openmp) - list(APPEND backends vtkm::openmp) +if(TARGET vtkm_openmp) + list(APPEND backends vtkm_openmp) endif() if(TARGET vtkm::kokkos) list(APPEND backends vtkm::kokkos) diff --git a/vtkm/cont/cuda/internal/CMakeLists.txt b/vtkm/cont/cuda/internal/CMakeLists.txt index 5a55f36e3..c62b4924d 100644 --- a/vtkm/cont/cuda/internal/CMakeLists.txt +++ b/vtkm/cont/cuda/internal/CMakeLists.txt @@ -24,7 +24,7 @@ set(headers vtkm_declare_headers(${headers}) -if (TARGET vtkm::cuda) +if (TARGET vtkm_cuda) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CudaAllocator.cu ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmCuda.cu diff --git a/vtkm/cont/cuda/vtkm.module b/vtkm/cont/cuda/vtkm.module index a740664e7..91722717b 100644 --- a/vtkm/cont/cuda/vtkm.module +++ b/vtkm/cont/cuda/vtkm.module @@ -6,4 +6,4 @@ DEPENDS vtkm_cont TEST_DEPENDS vtkm_worklet - vtkm::cuda + vtkm_cuda diff --git a/vtkm/cont/openmp/internal/CMakeLists.txt b/vtkm/cont/openmp/internal/CMakeLists.txt index dd04a8af7..0774f6bb6 100644 --- a/vtkm/cont/openmp/internal/CMakeLists.txt +++ b/vtkm/cont/openmp/internal/CMakeLists.txt @@ -29,7 +29,7 @@ target_sources(vtkm_cont PRIVATE ) #----------------------------------------------------------------------------- -if (TARGET vtkm::openmp) +if (TARGET vtkm_openmp) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmOpenMP.cxx ${CMAKE_CURRENT_SOURCE_DIR}/ParallelRadixSortOpenMP.cxx diff --git a/vtkm/cont/openmp/vtkm.module b/vtkm/cont/openmp/vtkm.module index 5533c4658..7d8ffdacc 100644 --- a/vtkm/cont/openmp/vtkm.module +++ b/vtkm/cont/openmp/vtkm.module @@ -6,4 +6,4 @@ DEPENDS vtkm_cont TEST_DEPENDS vtkm_worklet - vtkm::openmp + vtkm_openmp diff --git a/vtkm/cont/tbb/internal/CMakeLists.txt b/vtkm/cont/tbb/internal/CMakeLists.txt index 4a04356f5..16a605431 100644 --- a/vtkm/cont/tbb/internal/CMakeLists.txt +++ b/vtkm/cont/tbb/internal/CMakeLists.txt @@ -28,7 +28,7 @@ target_sources(vtkm_cont PRIVATE ) #----------------------------------------------------------------------------- -if (TARGET vtkm::tbb) +if (TARGET vtkm_tbb) target_sources(vtkm_cont PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/DeviceAdapterAlgorithmTBB.cxx ${CMAKE_CURRENT_SOURCE_DIR}/ParallelSortTBB.cxx diff --git a/vtkm/cont/tbb/vtkm.module b/vtkm/cont/tbb/vtkm.module index ff24d81ac..d1aedaafc 100644 --- a/vtkm/cont/tbb/vtkm.module +++ b/vtkm/cont/tbb/vtkm.module @@ -6,4 +6,4 @@ DEPENDS vtkm_cont TEST_DEPENDS vtkm_worklet - vtkm::tbb + vtkm_tbb diff --git a/vtkm/exec/cuda/vtkm.module b/vtkm/exec/cuda/vtkm.module index 0b608a2e2..6c16b6d6f 100644 --- a/vtkm/exec/cuda/vtkm.module +++ b/vtkm/exec/cuda/vtkm.module @@ -5,4 +5,4 @@ GROUPS DEPENDS vtkm_exec TEST_DEPENDS - vtkm::cuda + vtkm_cuda diff --git a/vtkm/exec/openmp/vtkm.module b/vtkm/exec/openmp/vtkm.module index 4f8b84898..f3a4f08cf 100644 --- a/vtkm/exec/openmp/vtkm.module +++ b/vtkm/exec/openmp/vtkm.module @@ -5,4 +5,4 @@ GROUPS DEPENDS vtkm_exec TEST_DEPENDS - vtkm::openmp + vtkm_openmp diff --git a/vtkm/exec/tbb/vtkm.module b/vtkm/exec/tbb/vtkm.module index 7b0adfc58..f53294995 100644 --- a/vtkm/exec/tbb/vtkm.module +++ b/vtkm/exec/tbb/vtkm.module @@ -5,4 +5,4 @@ GROUPS DEPENDS vtkm_exec TEST_DEPENDS - vtkm::tbb + vtkm_tbb diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 1e590b716..af945fd15 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -47,4 +47,4 @@ target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_core ) -install(TARGETS vtkm_filter EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_filter) diff --git a/vtkm/thirdparty/diy/CMakeLists.txt b/vtkm/thirdparty/diy/CMakeLists.txt index ce29dfb34..610548e5f 100644 --- a/vtkm/thirdparty/diy/CMakeLists.txt +++ b/vtkm/thirdparty/diy/CMakeLists.txt @@ -82,6 +82,7 @@ endif() include(VTKmDIYUtils) add_library(vtkm_diy INTERFACE) + vtkm_diy_init_target() target_include_directories(vtkm_diy INTERFACE $ @@ -113,7 +114,7 @@ else() endif() #----------------------------------------------------------------------------- -install(TARGETS vtkm_diy EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_diy) ## Install headers if (NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/thirdparty/lcl/CMakeLists.txt b/vtkm/thirdparty/lcl/CMakeLists.txt index bbfe16784..df45b77ee 100644 --- a/vtkm/thirdparty/lcl/CMakeLists.txt +++ b/vtkm/thirdparty/lcl/CMakeLists.txt @@ -18,8 +18,7 @@ target_include_directories(vtkm_lcl INTERFACE $ $) -install(TARGETS vtkm_lcl - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_lcl) ## Install headers if(NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/thirdparty/lodepng/CMakeLists.txt b/vtkm/thirdparty/lodepng/CMakeLists.txt index 3db33f6d6..a4b8c29c7 100644 --- a/vtkm/thirdparty/lodepng/CMakeLists.txt +++ b/vtkm/thirdparty/lodepng/CMakeLists.txt @@ -15,4 +15,4 @@ set_target_properties(vtkm_lodepng PROPERTIES POSITION_INDEPENDENT_CODE ON) # This will not install anything but it is needed for CMake <= 3.21 since it # does not fully support $ in target_link_library. -install(TARGETS vtkm_lodepng EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_lodepng) diff --git a/vtkm/thirdparty/loguru/CMakeLists.txt b/vtkm/thirdparty/loguru/CMakeLists.txt index 0b996afc9..e75b2a7e1 100644 --- a/vtkm/thirdparty/loguru/CMakeLists.txt +++ b/vtkm/thirdparty/loguru/CMakeLists.txt @@ -20,5 +20,4 @@ target_include_directories(vtkm_loguru INTERFACE target_link_libraries(vtkm_loguru INTERFACE ${CMAKE_DL_LIBS} Threads::Threads) -install(TARGETS vtkm_loguru - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_loguru) diff --git a/vtkm/thirdparty/optionparser/CMakeLists.txt b/vtkm/thirdparty/optionparser/CMakeLists.txt index 668cf867e..8037c9adb 100644 --- a/vtkm/thirdparty/optionparser/CMakeLists.txt +++ b/vtkm/thirdparty/optionparser/CMakeLists.txt @@ -15,8 +15,7 @@ target_include_directories(vtkm_optionparser INTERFACE $ $) -install(TARGETS vtkm_optionparser - EXPORT ${VTKm_EXPORT_NAME}) +vtkm_install_targets(TARGETS vtkm_optionparser) ## Install headers if(NOT VTKm_INSTALL_ONLY_LIBRARIES) diff --git a/vtkm/worklet/testing/CMakeLists.txt b/vtkm/worklet/testing/CMakeLists.txt index c4676f570..8683de07d 100644 --- a/vtkm/worklet/testing/CMakeLists.txt +++ b/vtkm/worklet/testing/CMakeLists.txt @@ -53,7 +53,7 @@ vtkm_unit_tests( LIBRARIES vtkm_source vtkm_worklet vtkm_filter vtkm_io USE_VTKM_JOB_POOL ) -if (TARGET vtkm::cuda) +if (TARGET vtkm_cuda) if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0) set(problematic_cuda_srcs