Skip to content

Commit

Permalink
Add compiler specific build flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Werni2A committed Jun 29, 2024
1 parent 80ec28f commit 21353ef
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra")
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wall>)
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Werror>)
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wextra>)

# @todo enable /WX
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Wall>)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-g3>)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -flto")
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-O3>)
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-flto>)
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/O2>)
endif()

# Add fmt dependency
Expand Down

0 comments on commit 21353ef

Please sign in to comment.