aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-02-25 10:57:54 +0000
committergatecat <gatecat@ds0.me>2021-02-25 11:05:26 +0000
commit17183fff05e52471ff4c619fc24e104234489803 (patch)
tree24e274534a728441a1f6bb219379a2972ff8df4f
parentab8dfcfba4544c6733d074b24b0529d431b66d29 (diff)
downloadnextpnr-17183fff05e52471ff4c619fc24e104234489803.tar.gz
nextpnr-17183fff05e52471ff4c619fc24e104234489803.tar.bz2
nextpnr-17183fff05e52471ff4c619fc24e104234489803.zip
cmake: Enable -Wextra, and -Werror in some cases
-Werror is not enabled by default, except on CI and for a few specific common traps, to avoid the inevitable breakages when new compiler versions add new diagnostics. Signed-off-by: gatecat <gatecat@ds0.me>
-rw-r--r--.cirrus.yml2
-rw-r--r--CMakeLists.txt11
2 files changed, 9 insertions, 4 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index b7ff1891..e2d61df2 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -6,7 +6,7 @@ task:
dockerfile: .cirrus/Dockerfile.ubuntu20.04
submodule_script: git submodule sync --recursive && git submodule update --init --recursive
- build_script: mkdir build && cd build && cmake .. -DARCH=all+alpha -DOXIDE_INSTALL_PREFIX=$HOME/.cargo -DBUILD_TESTS=on -DBUILD_GUI=on && make -j3
+ build_script: mkdir build && cd build && cmake .. -DARCH=all+alpha -DOXIDE_INSTALL_PREFIX=$HOME/.cargo -DBUILD_TESTS=on -DBUILD_GUI=on -DWERROR=on && make -j3
test_generic_script: cd build && ./nextpnr-generic-test
flow_test_generic_script: export NPNR=$(pwd)/build/nextpnr-generic && cd tests/generic/flow && ./run.sh
test_ice40_script: cd build && ./nextpnr-ice40-test
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87f2e9b0..f2377975 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ option(USE_OPENMP "Use OpenMP to accelerate analytic placer" OFF)
option(COVERAGE "Add code coverage info" OFF)
option(STATIC_BUILD "Create static build" OFF)
option(EXTERNAL_CHIPDB "Create build with pre-built chipdb binaries" OFF)
+option(WERROR "pass -Werror to compiler (used for CI)" OFF)
if(WIN32 OR EXTERNAL_CHIPDB)
set(BBASM_MODE "binary")
@@ -105,11 +106,15 @@ if (MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /W4 /wd4100 /wd4244 /wd4125 /wd4800 /wd4456 /wd4458 /wd4305 /wd4459 /wd4121 /wd4996")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W4 /wd4100 /wd4244 /wd4125 /wd4800 /wd4456 /wd4458 /wd4305 /wd4459 /wd4121 /wd4996 /wd4127")
else()
- set(CMAKE_CXX_FLAGS_DEBUG "-Wall -fPIC -ggdb -pipe")
+ set(WARN_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=sign-compare -Werror=return-type")
+ if (WERROR)
+ set(WARN_FLAGS "${WARN_FLAGS} -Werror")
+ endif()
+ set(CMAKE_CXX_FLAGS_DEBUG "${WARN_FLAGS} -fPIC -ggdb -pipe")
if (USE_OPENMP)
- set(CMAKE_CXX_FLAGS_RELEASE "-Wall -fPIC -O3 -g -pipe -fopenmp")
+ set(CMAKE_CXX_FLAGS_RELEASE "${WARN_FLAGS} -fPIC -O3 -g -pipe -fopenmp")
else()
- set(CMAKE_CXX_FLAGS_RELEASE "-Wall -fPIC -O3 -g -pipe")
+ set(CMAKE_CXX_FLAGS_RELEASE "${WARN_FLAGS} -fPIC -O3 -g -pipe")
endif()
endif()