(#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: script:
- mkdir build/ - mkdir build/
- cd build/ - cd build/
- cmake .. - cmake -DNOTHING_CI=ON ..
- make -k - make -k

View File

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

View File

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