summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-10 13:49:36 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-10-10 13:49:46 (GMT)
commiteebbe36ae65ab18f96a06b34ae7ccf523f6f69e2 (patch)
tree5f7d3700b2e7acbb3810453a4beb67b63baefda7
parent6edcb1490a777b6d96dfd34212dbf2bc8bdcdf42 (diff)
parent13f3382b1c11318d6f1f7ad6756a5a353e76d2b3 (diff)
downloadCMake-eebbe36ae65ab18f96a06b34ae7ccf523f6f69e2.zip
CMake-eebbe36ae65ab18f96a06b34ae7ccf523f6f69e2.tar.gz
CMake-eebbe36ae65ab18f96a06b34ae7ccf523f6f69e2.tar.bz2
Merge topic 'Intel-Fortran-warn-errors'
13f3382b1c Intel/IntelLLVM: Fortran has distinct "-Werror"-like flag ab8a0a106e COMPILE_WARNING_AS_ERROR: Fix internal formatting of options table Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7758
-rw-r--r--Modules/Compiler/Intel.cmake14
-rw-r--r--Modules/Compiler/IntelLLVM.cmake12
-rw-r--r--Modules/Compiler/NVHPC.cmake2
-rw-r--r--Modules/Compiler/NVIDIA-CUDA.cmake2
-rw-r--r--Source/cmLocalGenerator.cxx10
5 files changed, 29 insertions, 11 deletions
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 20989d2..642e58a 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -13,7 +13,11 @@ include(Compiler/CMakeCommonCompilerMacros)
if(CMAKE_HOST_WIN32)
# MSVC-like
macro(__compiler_intel lang)
- set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all")
+ if("x${lang}" STREQUAL "xFortran")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-warn:errors")
+ else()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all")
+ endif()
endmacro()
else()
# GNU-like
@@ -25,7 +29,6 @@ else()
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
- set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all")
set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}")
if(CMAKE_${lang}_COMPILER_ARG1)
@@ -35,7 +38,9 @@ else()
endif()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
- if(NOT "x${lang}" STREQUAL "xFortran")
+ if("x${lang}" STREQUAL "xFortran")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-warn" "errors")
+ else()
# Precompile Headers
set(CMAKE_PCH_EXTENSION .pchi)
set(CMAKE_LINK_PCH ON)
@@ -43,6 +48,9 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch)
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Wno-pch-messages -pch-use <PCH_FILE> -include <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Wno-pch-messages -pch-create <PCH_FILE> -include <PCH_HEADER>)
+
+ # COMPILE_WARNING_AS_ERROR
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror-all")
endif()
endmacro()
endif()
diff --git a/Modules/Compiler/IntelLLVM.cmake b/Modules/Compiler/IntelLLVM.cmake
index 3f22efd..30de1a9 100644
--- a/Modules/Compiler/IntelLLVM.cmake
+++ b/Modules/Compiler/IntelLLVM.cmake
@@ -27,7 +27,9 @@ endmacro()
if(CMAKE_HOST_WIN32)
# MSVC-like
macro(__compiler_intel_llvm lang)
- if(NOT "x${lang}" STREQUAL "xFortran")
+ if("x${lang}" STREQUAL "xFortran")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-warn:errors")
+ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch)
set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX")
endif()
@@ -51,7 +53,6 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
- set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
@@ -90,7 +91,9 @@ else()
list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
endif()
- if(NOT "x${lang}" STREQUAL "xFortran")
+ if("x${lang}" STREQUAL "xFortran")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-warn" "errors")
+ else()
# Precompile Headers
set(CMAKE_PCH_EXTENSION .pch)
set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
@@ -98,6 +101,9 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_INVALID_PCH -Winvalid-pch)
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
+
+ # COMPILE_WARNING_AS_ERROR
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror")
endif()
endmacro()
endif()
diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake
index 957dacd..474ac80 100644
--- a/Modules/Compiler/NVHPC.cmake
+++ b/Modules/Compiler/NVHPC.cmake
@@ -13,5 +13,5 @@ include(Compiler/PGI)
macro(__compiler_nvhpc lang)
# Logic specific to NVHPC.
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
- set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror all-warnings")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror" "all-warnings")
endmacro()
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake
index 2b8a1ea..c8dcd2a 100644
--- a/Modules/Compiler/NVIDIA-CUDA.cmake
+++ b/Modules/Compiler/NVIDIA-CUDA.cmake
@@ -31,7 +31,7 @@ endif()
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89)
# Starting in 10.2, nvcc supported treating all warnings as errors
- set(CMAKE_CUDA_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror all-warnings")
+ set(CMAKE_CUDA_COMPILE_OPTIONS_WARNING_AS_ERROR "-Werror" "all-warnings")
endif()
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89)
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index defcba3..2a50dd3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1030,10 +1030,14 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
// Add Warning as errors flags
if (!this->GetCMakeInstance()->GetIgnoreWarningAsError()) {
const cmValue wError = target->GetProperty("COMPILE_WARNING_AS_ERROR");
- const cmValue wErrorFlag = this->Makefile->GetDefinition(
+ const cmValue wErrorOpts = this->Makefile->GetDefinition(
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_WARNING_AS_ERROR"));
- if (wError.IsOn() && wErrorFlag.IsSet()) {
- flags.emplace_back(wErrorFlag);
+ if (wError.IsOn() && wErrorOpts.IsSet()) {
+ std::string wErrorFlags;
+ this->AppendCompileOptions(wErrorFlags, *wErrorOpts);
+ if (!wErrorFlags.empty()) {
+ flags.emplace_back(std::move(wErrorFlags));
+ }
}
}