Add compilation options to CMakeLists.txt

This commit is contained in:
William Robinet 2023-09-11 11:20:40 +02:00
parent 6c1aa99da8
commit cec86cfc7d
No known key found for this signature in database
GPG key ID: 003FA3DF74C7A949

View file

@ -7,6 +7,22 @@ project(
LANGUAGES C
)
######## User defined options
option(DEBUG_BUILD "Build with debug facilities" OFF)
option(DISABLE_OPTIMIZATION "Build without compiler optimizations" OFF)
################
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
if(DEBUG_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb3 -DDEBUG")
endif()
if(DISABLE_OPTIMIZATION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
include(CheckSymbolExists)
include(GNUInstallDirs)