mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 05:06:45 +00:00
[flang] Use LLVM's flags
Summary: The only difference is that LLVM_ENABLE_WERROR is set to OFF by default, but we enable this in a standalone flang build This commit fixes some windows issues with the flags Reviewers: DavidTruby, jdoerfert, sscalpone Reviewed By: DavidTruby, sscalpone Subscribers: ormris, richard.barton.arm, mehdi_amini, Meinersbur, ChinouneMehdi, tskeith, mgorny, llvm-commits Tags: #llvm, #flang Differential Revision: https://reviews.llvm.org/D78306
This commit is contained in:
parent
6c431fcf6e
commit
3862cbbc65
@ -37,11 +37,19 @@ endif()
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
include(AddFlang)
|
||||
|
||||
if (MSVC)
|
||||
set(_FLANG_ENABLE_WERROR_DEFAULT OFF)
|
||||
else ()
|
||||
set(_FLANG_ENABLE_WERROR_DEFAULT ON)
|
||||
endif()
|
||||
option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered."
|
||||
"${_FLANG_ENABLE_WERROR_DEFAULT}")
|
||||
|
||||
# Check for a standalone build and configure as appropriate from
|
||||
# there.
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
message("Building Flang as a standalone project.")
|
||||
project(Flang)
|
||||
message("Building Flang as a standalone project.")
|
||||
project(Flang)
|
||||
|
||||
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
if (NOT MSVC_IDE)
|
||||
@ -59,6 +67,8 @@ project(Flang)
|
||||
if(LLVM_ENABLE_ZLIB)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
|
||||
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include(AddLLVM)
|
||||
@ -76,7 +86,6 @@ project(Flang)
|
||||
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
|
||||
@ -239,8 +248,20 @@ configure_file(
|
||||
${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}")
|
||||
if (FLANG_ENABLE_WERROR)
|
||||
# The following is taken from llvm/cmake/modules/HandleLLVMOptions.cmake
|
||||
# Keep this up-to-date with that file
|
||||
if( MSVC )
|
||||
append("/WX" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
endif()
|
||||
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
|
||||
append("-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
append("-Wno-error" CMAKE_REQUIRED_FLAGS)
|
||||
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
|
||||
if (NOT LLVM_ENABLE_WERROR)
|
||||
message(WARNING "FLANG_ENABLE_WERROR setting is different from LLVM_ENABLE_WERROR.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Builtin check_cxx_compiler_flag doesn't seem to work correctly
|
||||
macro(check_compiler_flag flag resultVar)
|
||||
@ -250,11 +271,11 @@ endmacro()
|
||||
|
||||
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
|
||||
|
@ -1,5 +1,2 @@
|
||||
# Sources generated by tablegen have unused parameters.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
|
||||
|
||||
add_subdirectory(Dialect)
|
||||
add_subdirectory(Support)
|
||||
|
@ -90,10 +90,12 @@ target_link_libraries(logical-test
|
||||
# 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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user