From 18c56691324ecfb7eca07727b2c6d6c931866ed0 Mon Sep 17 00:00:00 2001 From: Piotr Winter Date: Thu, 8 Dec 2022 23:33:14 +0100 Subject: [PATCH] Added fconstexpr options to cmake. (#63) --- examples/CMakeLists.txt | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1b51412..81ff83b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,23 +22,20 @@ foreach (example IN LISTS examples) add_executable(${example} ${example}.cpp) target_link_libraries(${example} PRIVATE ctpg::ctpg) if (CTPG_WARNING_FLAGS) - if (MSVC) - target_compile_options( - ${example} - PRIVATE - /W4 /WX + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(${example} PRIVATE /W4 /WX /wd4459 # declaration of 'identifier' hides global declaration ) else () target_compile_options(${example} PRIVATE -Wall -Wextra -pedantic -Werror) endif () endif () - if (MSVC) - target_compile_options( - ${example} - PRIVATE - /EHsc - /constexpr:steps100000000 - ) - endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${example} PRIVATE -fconstexpr-steps=1000000000) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${example} PRIVATE -fconstexpr-ops-limit=1000000000) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(${example} PRIVATE /EHsc /constexpr:steps1000000000) + endif() + endforeach ()