(#1118) Treat warning as errors only on CI

Because during development it's super annoying
master
rexim 2019-11-04 01:01:02 +07:00
parent c6d0abddeb
commit 47746965ec
3 changed files with 11 additions and 5 deletions

View File

@ -13,5 +13,5 @@ compiler:
script:
- mkdir build/
- cd build/
- cmake ..
- cmake -DNOTHING_CI=ON ..
- make -k

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.13)
project(nothing)
set(NOTHING_CI OFF CACHE BOOL "Indicates whether the build is running on CI or not")
if(WIN32)
if(MINGW)
add_compile_definitions(SDL_MAIN_HANDLED) # https://stackoverflow.com/a/25089610
@ -170,7 +172,6 @@ if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQU
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
-Wall \
-Werror \
-Wextra \
-Wconversion \
-Wunused \
@ -198,12 +199,14 @@ if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQU
-std=c11 \
-ggdb \
-O3")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
target_link_libraries(nothing m)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
/Wall \
/WX \
/wd4127 \
/wd4201 \
/wd4204 \
@ -217,6 +220,9 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
/wd5045 \
/wd4200 \
/D \"_CRT_SECURE_NO_WARNINGS\"")
if (${NOTHING_CI})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif()
endif()
if(MINGW)
target_link_libraries(nothing hid setupapi Imm32 Version winmm)

View File

@ -32,9 +32,9 @@ build_script:
- cd build
- ps: |
if ($isWindows -and $env:BUILD_TYPE -eq 'mingw') {
C:\msys64\usr\bin\bash.exe -lc "cmake .. -G 'MSYS Makefiles'"
C:\msys64\usr\bin\bash.exe -lc "cmake .. -G 'MSYS Makefiles' -DNOTHING_CI=ON"
C:\msys64\usr\bin\bash.exe -lc "cmake --build ."
} else {
cmake ..
cmake .. -DNOTHING_CI=ON
cmake --build .
}