From f58f28cedd13525c0ab886a16c0d22342644be32 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 30 Aug 2022 12:28:35 -0400 Subject: [PATCH 1/2] 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")) From 73a461625acd40cb83f27f5213ad4fd57a214dca Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Tue, 30 Aug 2022 12:28:59 -0400 Subject: [PATCH 2/2] Fix FindTBB.cmake for MSVC 2022. --- thrust/cmake/FindTBB.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thrust/cmake/FindTBB.cmake b/thrust/cmake/FindTBB.cmake index 2ee350d3e..01e53d5e7 100644 --- a/thrust/cmake/FindTBB.cmake +++ b/thrust/cmake/FindTBB.cmake @@ -236,11 +236,12 @@ if (WIN32 AND MSVC) set(COMPILER_PREFIX "vc11") elseif(MSVC_VERSION EQUAL 1800) set(COMPILER_PREFIX "vc12") - elseif(MSVC_VERSION GREATER_EQUAL 1900 AND MSVC_VERSION LESS_EQUAL 1929) + elseif(MSVC_VERSION GREATER_EQUAL 1900 AND MSVC_VERSION LESS_EQUAL 1939) # 1900-1925 actually spans three Visual Studio versions: # 1900 = VS 14.0 (v140 toolset) a.k.a. MSVC 2015 # 1910-1919 = VS 15.0 (v141 toolset) a.k.a. MSVC 2017 # 1920-1929 = VS 16.0 (v142 toolset) a.k.a. MSVC 2019 + # 1930-1939 = VS 17.0 (v143 toolset) a.k.a. MSVC 2022 # # But these are binary compatible and TBB's open source distribution only # ships a single vs14 lib (as of 2020.0)