diff options
author | rtk0c <[email protected]> | 2022-05-30 16:38:45 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 16:38:45 -0700 |
commit | 366ef5a5450c6e0e680c924c3454943a9ae9814d (patch) | |
tree | 87ef5741bae89aaac6f502130b339fa7cd7be525 /buildtools/cmake/Exceptions.cmake | |
parent | 66ee4d47d55516ff55f72dfe2de1fb16c04dcb5b (diff) |
Changeset: 55 Buildsystem cleanup: add "projectized" targets
Diffstat (limited to 'buildtools/cmake/Exceptions.cmake')
-rw-r--r-- | buildtools/cmake/Exceptions.cmake | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/buildtools/cmake/Exceptions.cmake b/buildtools/cmake/Exceptions.cmake new file mode 100644 index 0000000..89e7e69 --- /dev/null +++ b/buildtools/cmake/Exceptions.cmake @@ -0,0 +1,31 @@ +function(target_flag_exceptions_msvc TARGET_NAME ENABLED) + if(ENABLED) + target_compile_options(${TARGET_NAME} PRIVATE /EHsc) + else() + target_compile_options(${TARGET_NAME} PRIVATE /EH-) + endif() +endfunction() + +function(target_flag_exceptions_gcc TARGET_NAME ENABLED) + if(ENABLED) + target_compile_options(${TARGET_NAME} PRIVATE -fexceptions) + else() + target_compile_options(${TARGET_NAME} PRIVATE -fno-exceptions) + endif() +endfunction() + +function(target_flag_exceptions TARGET_NAME ENABLED) + if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + target_flag_exceptions_msvc(${TARGET_NAME} ${ENABLED}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC") + target_flag_exceptions_msvc(${TARGET_NAME} ${ENABLED}) + elseif(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "GNU") + target_flag_exceptions_gcc(${TARGET_NAME} ${ENABLED}) + endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_flag_exceptions_gcc(${TARGET_NAME} ${ENABLED}) + else() + message(FATAL "target_flag_exceptions(): Unknown compiler ${CMAKE_CXX_COMPILER_ID}") + endif() +endfunction() |