Skip to content

Commit 5586a71

Browse files
Stuart Dootsonmurraycu
authored andcommitted
Add default warning flags
1 parent 36f3c78 commit 5586a71

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ project (sigc++)
3030

3131
set( CMAKE_CXX_STANDARD 17 )
3232

33+
# Turn on warnings for MSVC
34+
if (MSVC)
35+
# Remove the CMake default of /W3 because when you add /W4, MSVC will complain
36+
# about two warning level flags
37+
string(REGEX REPLACE "(^|[ \t])/W[0-9]($|[ \t])" "\\1\\2" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
38+
string(REGEX REPLACE "(^|[ \t])/W[0-9]($|[ \t])" "\\1\\2" CMAKE_CXX_FLAGS
39+
"${CMAKE_CXX_FLAGS}")
40+
elseif(CXX_COMPILER_ID)
41+
endif()
42+
43+
# Add compiler warning flags & turn warnings into errors
44+
add_compile_options(
45+
"$<$<OR:$<CXX_COMPILER_ID:MSVC>,$<C_COMPILER_ID:MSVC>>:/W4;/WX>"
46+
"$<$<OR:$<CXX_COMPILER_ID:GNU>,$<C_COMPILER_ID:GNU>>:-pedantic;-Wall;-Wextra;-Wsuggest-override;-Wshadow;-Wzero-as-null-pointer-constant;-Wformat-security>"
47+
"$<$<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>"
48+
)
49+
3350
set (PROJECT_SOURCE_DIR "${sigc++_SOURCE_DIR}/sigc++")
3451

3552
include_directories (${sigc++_SOURCE_DIR})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy