From f58f28cedd13525c0ab886a16c0d22342644be32 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 30 Aug 2022 12:28:35 -0400 Subject: [PATCH] Only generate per-dialect targets when needed. --- cmake/ThrustBuildCompilerTargets.cmake | 7 ++----- cmake/ThrustBuildTargetList.cmake | 8 +++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmake/ThrustBuildCompilerTargets.cmake b/cmake/ThrustBuildCompilerTargets.cmake index bf0b31ed4..aed0ec170 100644 --- a/cmake/ThrustBuildCompilerTargets.cmake +++ b/cmake/ThrustBuildCompilerTargets.cmake @@ -6,11 +6,9 @@ # - Interface target providing compiler-specific options needed to build # Thrust's tests, examples, etc. # -# thrust.compiler_interface_cpp11 -# thrust.compiler_interface_cpp14 -# thrust.compiler_interface_cpp17 +# thrust.compiler_interface_cppXX # - Interface targets providing compiler-specific options that should only be -# applied to certain dialects of C++. +# applied to certain dialects of C++. May not be defined for all dialects. # # thrust.promote_cudafe_warnings # - Interface target that adds warning promotion for NVCC cudafe invocations. @@ -175,7 +173,6 @@ function(thrust_build_compiler_targets) # These targets are used for dialect-specific options: add_library(thrust.compiler_interface_cpp11 INTERFACE) add_library(thrust.compiler_interface_cpp14 INTERFACE) - add_library(thrust.compiler_interface_cpp17 INTERFACE) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # C4127: conditional expression is constant diff --git a/cmake/ThrustBuildTargetList.cmake b/cmake/ThrustBuildTargetList.cmake index 3868287b4..f4adaf546 100644 --- a/cmake/ThrustBuildTargetList.cmake +++ b/cmake/ThrustBuildTargetList.cmake @@ -163,9 +163,15 @@ function(_thrust_add_target_to_target_list target_name host device dialect prefi target_link_libraries(${target_name} INTERFACE thrust.compiler_interface - thrust.compiler_interface_cpp${dialect} ) + # dialect-specific interface: + if (TARGET thrust.compiler_interface_cpp${dialect}) + target_link_libraries(${target_name} INTERFACE + thrust.compiler_interface_cpp${dialect} + ) + endif() + # Workaround Github issue #1174. cudafe promote TBB header warnings to # errors, even when they're -isystem includes. if ((NOT host STREQUAL "TBB") OR (NOT device STREQUAL "CUDA"))