diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -59,6 +59,8 @@ if(LLVM_ENABLE_ZLIB) find_package(ZLIB REQUIRED) endif() + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) + option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." ON) include(CMakeParseArguments) include(AddLLVM) @@ -76,7 +78,6 @@ NO_DEFAULT_PATH) endif() - option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN @@ -235,9 +236,6 @@ ${FLANG_SOURCE_DIR}/include/flang/Config/config.h.cmake ${FLANG_BINARY_DIR}/include/flang/Config/config.h) -# Add global F18 flags. -set(CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions -pedantic -Wall -Wextra -Werror -Wcast-qual -Wimplicit-fallthrough -Wdelete-non-virtual-dtor ${CMAKE_CXX_FLAGS}") - # Builtin check_cxx_compiler_flag doesn't seem to work correctly macro(check_compiler_flag flag resultVar) unset(${resultVar} CACHE) @@ -246,11 +244,11 @@ check_compiler_flag("-Werror -Wno-deprecated-copy" CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG) if (CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") endif() check_compiler_flag("-Wstring-conversion" CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG) if (CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion") endif() # Add appropriate flags for GCC diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt --- a/flang/unittests/Evaluate/CMakeLists.txt +++ b/flang/unittests/Evaluate/CMakeLists.txt @@ -88,10 +88,12 @@ # IEEE exception flags (different use of the word "exception") # in the actual hardware floating-point status register, so ensure that # C++ exceptions are enabled for this test. -set_source_files_properties(real.cpp PROPERTIES COMPILE_FLAGS -fexceptions) +set(LLVM_REQUIRES_EH ON) +set(LLVM_REQUIRES_RTTI ON) add_executable(real-test real.cpp ) +llvm_update_compile_flags(real-test) target_link_libraries(real-test FortranEvaluateTesting diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt --- a/flang/unittests/Runtime/CMakeLists.txt +++ b/flang/unittests/Runtime/CMakeLists.txt @@ -1,11 +1,12 @@ -if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") -endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +# RuntimeTesting needs exceptions enabled +set(LLVM_REQUIRES_EH ON) +set(LLVM_REQUIRES_RTTI ON) add_library(RuntimeTesting testing.cpp ) +llvm_update_compile_flags(RuntimeTesting) add_executable(format-test format.cpp