mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 19:01:24 +00:00
Enable warnings on Windows
This commit is contained in:
parent
83e779d8f2
commit
0f833f30ed
@ -13,7 +13,7 @@ install:
|
|||||||
build_script:
|
build_script:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake ..
|
- cmake -DNXT_USE_WERROR=1 ..
|
||||||
- cmake --build .
|
- cmake --build .
|
||||||
|
|
||||||
# TODO(cwallez@chromium.org) test on more than Debug.
|
# TODO(cwallez@chromium.org) test on more than Debug.
|
||||||
|
@ -29,6 +29,7 @@ set(NXT_FLAGS "")
|
|||||||
set(NXT_DEFS "")
|
set(NXT_DEFS "")
|
||||||
set(NXT_INTERNAL_FLAGS "")
|
set(NXT_INTERNAL_FLAGS "")
|
||||||
set(NXT_INTERNAL_DEFS "")
|
set(NXT_INTERNAL_DEFS "")
|
||||||
|
set(NXT_GENERATED_FLAGS "")
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
list(APPEND NXT_DEFS "NXT_ENABLE_ASSERTS")
|
list(APPEND NXT_DEFS "NXT_ENABLE_ASSERTS")
|
||||||
@ -43,13 +44,24 @@ endif()
|
|||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
list(APPEND NXT_FLAGS "/std:c++14")
|
list(APPEND NXT_FLAGS "/std:c++14")
|
||||||
|
list(APPEND NXT_INTERNAL_FLAGS "/W4")
|
||||||
|
# Allow declarations hiding members as it is used all over NXT
|
||||||
|
list(APPEND NXT_INTERNAL_FLAGS "/wd4458")
|
||||||
|
list(APPEND NXT_INTERNAL_FLAGS "/wd4996") # Allow deprecated functions like strncpy
|
||||||
|
|
||||||
|
list(APPEND NXT_GENERATED_FLAGS "/wd4702") # Allow unreachable code
|
||||||
|
list(APPEND NXT_GENERATED_FLAGS "/wd4189") # Allow unused variable
|
||||||
|
|
||||||
|
if(NXT_USE_WERROR)
|
||||||
|
list(APPEND NXT_INTERNAL_FLAGS "/WX")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# Activate C++14 only on C++ files, not C files.
|
# Activate C++14 only on C++ files, not C files.
|
||||||
list(APPEND NXT_FLAGS "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++14>")
|
list(APPEND NXT_FLAGS "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-std=c++14>")
|
||||||
list(APPEND NXT_FLAGS "-fPIC")
|
list(APPEND NXT_FLAGS "-fPIC")
|
||||||
|
|
||||||
list(APPEND NXT_INTERNAL_FLAGS "-Wall" "-Wextra")
|
list(APPEND NXT_INTERNAL_FLAGS "-Wall" "-Wextra")
|
||||||
list(APPEND NXT_GENERATED_FLAGS "-Wno-unused-variable")
|
list(APPEND NXT_GENERATED_FLAGS "-Wno-unused-variable" "-Wno-unused-function")
|
||||||
if(NXT_USE_WERROR)
|
if(NXT_USE_WERROR)
|
||||||
list(APPEND NXT_INTERNAL_FLAGS "-Werror")
|
list(APPEND NXT_INTERNAL_FLAGS "-Werror")
|
||||||
endif()
|
endif()
|
||||||
|
@ -22,8 +22,23 @@ NXTInternalTarget("examples" sample_utils)
|
|||||||
function(add_nxt_sample target sources)
|
function(add_nxt_sample target sources)
|
||||||
add_executable(${target} ${sources})
|
add_executable(${target} ${sources})
|
||||||
target_link_libraries(${target} sample_utils)
|
target_link_libraries(${target} sample_utils)
|
||||||
target_include_directories(${target} PRIVATE ${GLM_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(${target} SYSTEM PRIVATE ${GLM_INCLUDE_DIR})
|
||||||
|
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
NXTInternaltarget("examples" ${target})
|
NXTInternaltarget("examples" ${target})
|
||||||
|
|
||||||
|
# Suppress some warnings in our sample dependencies
|
||||||
|
if (MSVC)
|
||||||
|
# nonstandard extension used: nameless struct/union -- for GLM
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS "/wd4201")
|
||||||
|
# declaration hides global declaration -- for GLM
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS "/wd4459")
|
||||||
|
# = conversion possible loss of data -- for STB image
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS "/wd4244")
|
||||||
|
# declaration hides previous declaration -- for STB image
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS "/wd4456")
|
||||||
|
# declaration hides previous declaration -- for picojson
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY COMPILE_OPTIONS "/wd4706")
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
add_nxt_sample(CHelloTriangle CHelloTriangle.cpp)
|
add_nxt_sample(CHelloTriangle CHelloTriangle.cpp)
|
||||||
|
@ -62,10 +62,7 @@ function(Generate)
|
|||||||
)
|
)
|
||||||
|
|
||||||
NXTInternalTarget("${G_FOLDER}" ${G_LIB_NAME})
|
NXTInternalTarget("${G_FOLDER}" ${G_LIB_NAME})
|
||||||
if (NOT MSVC)
|
target_compile_options(${G_LIB_NAME} PRIVATE ${NXT_GENERATED_FLAGS})
|
||||||
target_compile_options(${G_LIB_NAME} PRIVATE "-Wno-unused-variable")
|
|
||||||
target_compile_options(${G_LIB_NAME} PRIVATE "-Wno-unused-function")
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||||
|
@ -35,11 +35,10 @@ namespace backend {
|
|||||||
return std::hash<unsigned long long>()(value.to_ullong());
|
return std::hash<unsigned long long>()(value.to_ullong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO(cwallez@chromium.org): see if we can use boost's hash combined or some equivalent
|
// TODO(cwallez@chromium.org): see if we can use boost's hash combined or some equivalent
|
||||||
// this currently assumes that size_t is 64 bits
|
// this currently assumes that size_t is 64 bits
|
||||||
void CombineHashes(size_t* h1, size_t h2) {
|
void CombineHashes(size_t* h1, size_t h2) {
|
||||||
*h1 ^= (h2 << 7) + (h2 >> (64 - 7)) + 0x304975;
|
*h1 ^= (h2 << 7) + (h2 >> (sizeof(size_t) * 8 - 7)) + 0x304975;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
|
size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
|
||||||
|
@ -85,7 +85,7 @@ void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata user
|
|||||||
|
|
||||||
void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, nxt::CallbackUserdata userdata1, nxt::CallbackUserdata userdata2) {
|
void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, nxt::CallbackUserdata userdata1, nxt::CallbackUserdata userdata2) {
|
||||||
auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1));
|
auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1));
|
||||||
size_t index = userdata2;
|
size_t index = static_cast<size_t>(userdata2);
|
||||||
|
|
||||||
ASSERT_LT(index, self->expectations.size());
|
ASSERT_LT(index, self->expectations.size());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user