Skip to content

Commit

Permalink
Enable -Wshadow for gcc and clang
Browse files Browse the repository at this point in the history
Use a single variable to set basic flags for both compilers.
  • Loading branch information
dsieger committed Dec 31, 2021
1 parent 7e02339 commit ef7cea9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Expand Up @@ -106,17 +106,19 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# set default compiler flags
# set default compiler flags for both gcc and clang
set(COMMON_CXX_FLAGS "-pedantic -Wall -Wextra -Wshadow")

if((UNIX OR APPLE) AND CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wno-deprecated-copy")
"${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS} -Wno-deprecated-copy")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-in-bool-context")
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS}")
endif()

if(WIN32)
Expand Down

0 comments on commit ef7cea9

Please sign in to comment.