Enable warnings on Windows

This commit is contained in:
Corentin Wallez 2017-07-10 20:09:59 -04:00 committed by Corentin Wallez
parent 83e779d8f2
commit 0f833f30ed
6 changed files with 33 additions and 10 deletions

View File

@ -13,7 +13,7 @@ install:
build_script:
- mkdir build
- cd build
- cmake ..
- cmake -DNXT_USE_WERROR=1 ..
- cmake --build .
# TODO(cwallez@chromium.org) test on more than Debug.

View File

@ -29,6 +29,7 @@ set(NXT_FLAGS "")
set(NXT_DEFS "")
set(NXT_INTERNAL_FLAGS "")
set(NXT_INTERNAL_DEFS "")
set(NXT_GENERATED_FLAGS "")
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
list(APPEND NXT_DEFS "NXT_ENABLE_ASSERTS")
@ -43,13 +44,24 @@ endif()
if (MSVC)
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()
# 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 "-fPIC")
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)
list(APPEND NXT_INTERNAL_FLAGS "-Werror")
endif()

View File

@ -22,8 +22,23 @@ NXTInternalTarget("examples" sample_utils)
function(add_nxt_sample target sources)
add_executable(${target} ${sources})
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})
# 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()
add_nxt_sample(CHelloTriangle CHelloTriangle.cpp)

View File

@ -62,10 +62,7 @@ function(Generate)
)
NXTInternalTarget("${G_FOLDER}" ${G_LIB_NAME})
if (NOT MSVC)
target_compile_options(${G_LIB_NAME} PRIVATE "-Wno-unused-variable")
target_compile_options(${G_LIB_NAME} PRIVATE "-Wno-unused-function")
endif()
target_compile_options(${G_LIB_NAME} PRIVATE ${NXT_GENERATED_FLAGS})
endfunction()
set(GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)

View File

@ -35,11 +35,10 @@ namespace backend {
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
// this currently assumes that size_t is 64 bits
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) {

View File

@ -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) {
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());