Skip to content

Commit

Permalink
Fixed opts.cmake compile flags based on compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
FuexFollets authored Jan 27, 2024
1 parent e243793 commit e0106fc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmake/opts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 20)

if(CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "GCC detected, adding compile flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -g")
endif()
set(base_flags "-Wall -Wextra -Wpedantic -g")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# Remove -Wextra for MSVC
string(REPLACE "-Wextra" "" flags "${base_flags}")
else()
# Use base flags for other compilers
set(flags "${base_flags}")
endif()

# Apply the final flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags}")

0 comments on commit e0106fc

Please sign in to comment.