aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-02-14 14:50:04 -0800
committerGarrett D'Amore <garrett@damore.org>2018-02-14 18:28:36 -0800
commit45bc175ef9278c175d2fc3a0678b49b18e74c449 (patch)
treeb1838778ee898112f28b35178364068c6f48c9b4 /CMakeLists.txt
parent8f93750ed2a6aaa1749eb689ddf119280f9aac7a (diff)
downloadnng-45bc175ef9278c175d2fc3a0678b49b18e74c449.tar.gz
nng-45bc175ef9278c175d2fc3a0678b49b18e74c449.tar.bz2
nng-45bc175ef9278c175d2fc3a0678b49b18e74c449.zip
fixes #234 Investigate enabling more verbose compiler warnings
We enabled verbose compiler warnings, and found a lot of issues. Some of these were even real bugs. As a bonus, we actually save some initialization steps in the compat layer, and avoid passing some variables we don't need.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 15 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70d7b29f..3a6ea442 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -240,24 +240,32 @@ endif()
# Platform checks.
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(NNG_WARN_FLAGS "-Wall -Wextra")
+elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(NNG_WARN_FLAGS "-Wall -Wextra")
+elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(NNG_WARN_FLAGS "-Wall -Wextra")
+endif()
+
if (NNG_ENABLE_COVERAGE)
# NB: This only works for GCC and Clang 3.0 and newer. If your stuff
# is older than that, you will need to find something newer. For
# correct reporting, we always turn off all optimizations.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set(CMAKE_C_FLAGS "-g -O0 --coverage")
- set(CMAKE_CXX_FLAGS "-g -O0 --coverage")
+ set(NNG_COVERAGE_FLAGS "-g -O0 --coverage")
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
- elseif (CMAKE_COMPILER_ID STREQUAL "AppleClang")
- set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
- set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+ set(NNG_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(NNG_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
else()
message(FATAL_ERROR "Unable to enable coverage for your compiler.")
endif()
endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NNG_WARN_FLAGS} ${NNG_COVERAGE_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NNG_WARN_FLAGS} ${NNG_COVERAGE_FLAGS}")
+
find_package (Threads REQUIRED)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")