summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2024-11-08 11:15:08 -0500
committerGitHub <noreply@github.com>2024-11-08 11:15:08 -0500
commit0f46ce82998b2b1cb68f04bef3a097ea850ad453 (patch)
treee920e317c7478d25fc3ddbab351c9f5e5542167c
parentad72ee6ff2f0077467ceeb1fa905a8ab4ef01ff5 (diff)
Fix EHa flag compiler filtering (#5524)
The previous attempt to enable Structured Exception Handling in (only) MSVC using the /EHa compiler flag caused trouble with flags defined with Cmake Generator Expressions. These expressions are not fully resolved, and they fail validation checks in check_cxx_compiler_flag(). The previous attempt at applying /EHa to only MVSC involved refactoring a direct call to target_compile_options() with a call to the Slang helper function add_supported_cxx_flags() where an additional MSVC filter was introduced, but the helper also calls check_cxx_compiler_flag() to see if flags are supported. It was okay for /EHa, but not some other flags that ended up getting newly validated. The above issue is fixed by re-implementing the change that added /EHa to only MSVC. This change goes back to adding compiler flags without the helper function with its extra validation, instead using an additional cmake generator expression to apply /EHa only to MSVC.
-rw-r--r--cmake/CompilerFlags.cmake4
-rw-r--r--cmake/SlangTarget.cmake5
-rw-r--r--tools/CMakeLists.txt2
3 files changed, 3 insertions, 8 deletions
diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake
index 5558c346b..cd9021cd0 100644
--- a/cmake/CompilerFlags.cmake
+++ b/cmake/CompilerFlags.cmake
@@ -16,10 +16,6 @@ function(add_supported_cxx_flags target)
endif()
foreach(flag ${flags})
- # /EHa enables SEH on Windows, it is not available in Linux.
- if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
- string(REGEX REPLACE "/EHa" "" flag "${flag}")
- endif()
# remove the `no-` prefix from warnings because gcc doesn't treat it as an
# error on its own
string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake
index 98517a1ba..4a3b75704 100644
--- a/cmake/SlangTarget.cmake
+++ b/cmake/SlangTarget.cmake
@@ -337,10 +337,9 @@ function(slang_add_target dir type)
)
endif()
if(ARG_EXTRA_COMPILE_OPTIONS_PRIVATE)
- add_supported_cxx_flags(
+ target_compile_options(
${target}
- PRIVATE
- ${ARG_EXTRA_COMPILE_OPTIONS_PRIVATE}
+ PRIVATE ${ARG_EXTRA_COMPILE_OPTIONS_PRIVATE}
)
endif()
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index ef4d17556..2593a60fd 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -276,7 +276,7 @@ if(SLANG_ENABLE_TESTS)
EXTRA_COMPILE_DEFINITIONS_PRIVATE
$<$<BOOL:${SLANG_ENABLE_CUDA}>:RENDER_TEST_CUDA>
$<$<BOOL:${SLANG_ENABLE_OPTIX}>:RENDER_TEST_OPTIX>
- EXTRA_COMPILE_OPTIONS_PRIVATE /EHa
+ EXTRA_COMPILE_OPTIONS_PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/EHa>
OUTPUT_NAME render-test-tool
REQUIRED_BY slang-test
FOLDER test/tools