Skip to content

Commit

Permalink
Improve CMake compiler configuration
Browse files Browse the repository at this point in the history
* CMAKE_COMPILER_IS_GNUCC and CMAKE_COMPILER_IS_GNUCXX are deprecated.
  CMAKE_C_COMPILER_ID should be used instead.
* Remove -Werror
* Use generator expressions for compiler debug flags
  • Loading branch information
leonlynch committed Jun 30, 2022
1 parent b10461b commit 22a1feb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ else()
set(TR31_IS_TOP_LEVEL ${tr31_IS_TOP_LEVEL})
endif()

# Configure compiler
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wall -Werror)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall)
add_compile_options($<$<CONFIG:Debug>:-ggdb>)
add_compile_options($<$<CONFIG:RelWithDebInfo>:-ggdb>)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
Expand Down

0 comments on commit 22a1feb

Please sign in to comment.