diff options
author | Stuart Dootson <u404261@methods.local> | 2019-10-14 13:23:50 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2019-10-25 12:57:31 +0200 |
commit | 5586a71f42b047c2542425a6a296a557d7593e6b (patch) | |
tree | 4f34a052d204e19b11a985bc264780769489d817 | |
parent | 36f3c78d543495bd951e86e7b11e8462f303a227 (diff) | |
download | sigc++-5586a71f42b047c2542425a6a296a557d7593e6b.tar.gz |
Add default warning flags
-rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec2b4a..473d257 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,23 @@ project (sigc++) set( CMAKE_CXX_STANDARD 17 ) +# Turn on warnings for MSVC +if (MSVC) + # Remove the CMake default of /W3 because when you add /W4, MSVC will complain + # about two warning level flags + string(REGEX REPLACE "(^|[ \t])/W[0-9]($|[ \t])" "\\1\\2" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REGEX REPLACE "(^|[ \t])/W[0-9]($|[ \t])" "\\1\\2" CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS}") +elseif(CXX_COMPILER_ID) +endif() + +# Add compiler warning flags & turn warnings into errors +add_compile_options( + "$<$<OR:$<CXX_COMPILER_ID:MSVC>,$<C_COMPILER_ID:MSVC>>:/W4;/WX>" + "$<$<OR:$<CXX_COMPILER_ID:GNU>,$<C_COMPILER_ID:GNU>>:-pedantic;-Wall;-Wextra;-Wsuggest-override;-Wshadow;-Wzero-as-null-pointer-constant;-Wformat-security>" + "$<$<OR:$<CXX_COMPILER_ID:Clang>,$<C_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:AppleClang>>:-pedantic;-Wall;-Wextra;-Wshadow;-Wzero-as-null-pointer-constant;-Wformat-security>" +) + set (PROJECT_SOURCE_DIR "${sigc++_SOURCE_DIR}/sigc++") include_directories (${sigc++_SOURCE_DIR}) |