[flang-commits] [flang] b36bdfe - [cmake] Centralize LLVM_ENABLE_WARNINGS option

Dave Lee via flang-commits flang-commits at lists.llvm.org
Mon Sep 21 10:23:46 PDT 2020


Author: Dave Lee
Date: 2020-09-21T10:23:17-07:00
New Revision: b36bdfe5ca0c2b863248f327b03d41516b38dc11

URL: https://github.com/llvm/llvm-project/commit/b36bdfe5ca0c2b863248f327b03d41516b38dc11
DIFF: https://github.com/llvm/llvm-project/commit/b36bdfe5ca0c2b863248f327b03d41516b38dc11.diff

LOG: [cmake] Centralize LLVM_ENABLE_WARNINGS option

Configure default value of `LLVM_ENABLE_WARNINGS` in `HandleLLVMOptions.cmake`.

`LLVM_ENABLE_WARNINGS` is documented as ON by default, but `HandleLLVMOptions` assumes the default has been set somewhere else. If it has not been explicitly set, then `HandleLLVMOptions` implicitly uses OFF as a default.

This removes the various `option()` declarations in favor of a single declaration in `HandleLLVMOptions`. This will prevent the unwanted use of `-w` that is mentioned in a couple of the comments.

Reviewed By: DavidTruby, #libunwind, JDevlieghere, compnerd

Differential Revision: https://reviews.llvm.org/D87243

Added: 
    

Modified: 
    clang/CMakeLists.txt
    flang/CMakeLists.txt
    libunwind/CMakeLists.txt
    llvm/CMakeLists.txt
    llvm/cmake/modules/HandleLLVMOptions.cmake
    llvm/cmake/modules/LLVMConfig.cmake.in
    llvm/runtimes/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 3db476cffbf0..c308328c3ee4 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -105,7 +105,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
     set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
   endif()
 
-  option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
   option(LLVM_INSTALL_TOOLCHAIN_ONLY
     "Only include toolchain files in the 'install' target." OFF)
 

diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index daae9e9b1246..ceba69c55dfb 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -72,7 +72,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   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)
   if(CMAKE_COMPILER_IS_GNUCXX)
     set(USE_NO_MAYBE_UNINITIALIZED 1)

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index f4243f3d2791..7851f3e45d0c 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -73,8 +73,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_B
   endif()
 
   if (EXISTS ${LLVM_CMAKE_PATH})
-    # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions.
-    set(LLVM_ENABLE_WARNINGS ON)
     list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
     include("${LLVM_CMAKE_PATH}/AddLLVM.cmake")
     include("${LLVM_CMAKE_PATH}/HandleLLVMOptions.cmake")

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4ae7bc14d3bb..a63c1ccd6317 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -399,7 +399,6 @@ set(LLVM_TARGETS_TO_BUILD
 list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
 
 option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
-option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
 option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON)

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 09bebaf79be2..ddf2b6e3b688 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -409,6 +409,8 @@ elseif(MINGW) # FIXME: Also cygwin?
   endif()
 endif()
 
+option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
+
 if( MSVC )
   include(ChooseMSVCCRT)
 

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in
index 4453020cf4da..d8a511b69fdd 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -36,6 +36,8 @@ set(TARGET_TRIPLE "@TARGET_TRIPLE@")
 
 set(LLVM_ABI_BREAKING_CHECKS @LLVM_ABI_BREAKING_CHECKS@)
 
+set(LLVM_ENABLE_WARNINGS @LLVM_ENABLE_WARNINGS@)
+
 set(LLVM_ENABLE_EXPENSIVE_CHECKS @LLVM_ENABLE_EXPENSIVE_CHECKS@)
 
 set(LLVM_ENABLE_ASSERTIONS @LLVM_ENABLE_ASSERTIONS@)

diff  --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 04a13e48cff5..3a9046daeb93 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -105,10 +105,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
   # Avoid checking whether the compiler is working.
   set(LLVM_COMPILER_CHECKED ON)
 
-  # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
-  # resulting in unjustified successes by check_cxx_compiler_flag.
-  set(LLVM_ENABLE_WARNINGS ON)
-
   # Handle common options used by all runtimes.
   include(AddLLVM)
   include(HandleLLVMOptions)


        


More information about the flang-commits mailing list