Skip to content

Commit 73f22aa

Browse files
authored
Allow building with cmake --compile-no-warning-as-error. (#2401)
In CMake 3.24+, there is built-in support for adding -Werror that does not require adding -Werror explicitly, and allows it to be downgraded to a warning if the user wants that. Use this, to account for warnings that have false positives.
1 parent 9265cbb commit 73f22aa

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
100100
add_cxx_flag_if_supported(-Wmisleading-indentation)
101101
add_cxx_flag_if_supported(-Wunused-function)
102102
add_cxx_flag_if_supported(-Wunused-variable)
103-
add_cxx_flag_if_supported(-Werror)
103+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
104+
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
105+
else()
106+
add_cxx_flag_if_supported(-Werror)
107+
endif()
104108
if(NOT CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo|MinSizeRel")
105109
# Enable more warnings if not doing a release build.
106110
add_cxx_flag_if_supported(-Wall)

test_conformance/common/vulkan_wrapper/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(VULKAN_WRAPPER_SOURCES
66
)
77

88
# needed by Vulkan wrapper to compile
9+
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
910
add_cxx_flag_if_supported(-Wmisleading-indentation)
1011
add_cxx_flag_if_supported(-Wno-narrowing)
1112
add_cxx_flag_if_supported(-Wno-format)

test_conformance/extensions/cl_khr_external_semaphore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
1717
include_directories (${CLConform_INCLUDE_DIR})
1818

1919
list(APPEND CLConform_LIBRARIES vulkan_wrapper)
20+
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
2021
set(CMAKE_CXX_FLAGS "-fpermissive")
2122

2223
include_directories("../../common/vulkan_wrapper")

test_conformance/vulkan/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set (MODULE_NAME VULKAN)
22

33
list(APPEND CLConform_LIBRARIES vulkan_wrapper)
4+
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
45
set(CMAKE_CXX_FLAGS "-fpermissive")
56
if(WIN32)
67
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_WIN32_KHR")

0 commit comments

Comments
 (0)