From 6ceeee6a11207b64d546336dc56182194c9787b7 Mon Sep 17 00:00:00 2001 From: Peter Heywood Date: Fri, 30 Aug 2024 12:23:57 +0100 Subject: [PATCH] MSVC: Add warning if MSVC >= 1711 that >= CUDA 12.4 is required Also moves where CheckCompilerFunctionality is included to ensure it is triggered before CUDA is attempted --- cmake/CheckCompilerFunctionality.cmake | 14 +++++++++++++- src/CMakeLists.txt | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmake/CheckCompilerFunctionality.cmake b/cmake/CheckCompilerFunctionality.cmake index 31da9b5..bd12c9d 100644 --- a/cmake/CheckCompilerFunctionality.cmake +++ b/cmake/CheckCompilerFunctionality.cmake @@ -20,8 +20,20 @@ function(flamegpu_visualiser_check_compiler_functionality) enable_language(CXX) check_language(CUDA) if(NOT CMAKE_CUDA_COMPILER) - # If using MSVC >= 1940 then CUDA <= 12.3 support requires -allow-unsupported-compiler, so warn about this + # MSVC 1911 (VS2022 17.11) requires CUDA 12.4 or greater - see https://github.com/microsoft/STL/pull/4475 if(MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL "1940") + message(WARNING + " CUDA Language Support Not Found (with MSVC ${MSVC_VERSION} >= 1941)\n" + " \n" + " The MSVC STL included with MSVC 1941 requires CUDA 12.4 or newer\n" + " If you have CUDA <= 12.3 installed you must either:\n" + " - Upgrade CUDA to >= 12.4\n" + " - Downgrade MSVC to 1940 and set the CUDAFLAGS environment variable to contain '-allow-unsupported-compiler'\n" + " - Downgrade MSVC to 1939 or older\n" + " You must then clear the CMake cache before reconfiguring\n" + ) + # If using MSVC >= 1940 then CUDA <= 12.3 support requires -allow-unsupported-compiler, so warn about this + elseif(MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL "1940") # If this is the case, then CMake >= 3.29.4 is also required, otherwise CMake does not pass -allow-unsupported-compiler along, warn as appropriate if(CMAKE_VERSION VERSION_LESS "3.29.4") message(WARNING diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54697ac..572644a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,9 @@ project(flamegpu_visualiser LANGUAGES NONE) # handle cpplint. include(${CMAKE_CURRENT_LIST_DIR}/../cmake/cpplint.cmake) +# Ensure found compilers are actually good enough / don't trigger known issues. +include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CheckCompilerFunctionality.cmake) + # Check to see if CUDA is available, and meets the required minimum version for non-lint builds if(NOT DEFINED MINIMUM_CUDA_VERSION) set(MINIMUM_CUDA_VERSION 11.0)