From 72bee0bd2826d7c623b3d8df4c818e0a067c81d1 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 14 Apr 2024 08:02:17 +0200 Subject: [PATCH] add build with debug symboles --- CMakeLists.txt | 17 ++++++++++++----- readme.md | 7 +++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e512ec..3f5204a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,18 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.25.1) -SET(CMAKE_C_COMPILER gcc CACHE STRING "compiler") -IF (NOT RUN_TESTS) - SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "release" FORCE) +SET(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "release") + +IF(CMAKE_BUILD_TYPE STREQUAL "RELEASE") SET(CMAKE_C_FLAGS "-Wall -Werror" CACHE STRING "compiler flags" FORCE) -ELSE() - SET(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "release" FORCE) +ENDIF() + +IF(CMAKE_BUILD_TYPE STREQUAL "DEBUG") + SET(CMAKE_C_FLAGS "-Wall -g" CACHE STRING "debug compiler flags" FORCE) +ENDIF() + +SET(CMAKE_C_COMPILER gcc CACHE STRING "compiler") +IF (RUN_TESTS) + SET(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "debug" FORCE) SET(CMAKE_C_FLAGS "-fPIC \ -fprofile-arcs \ -ftest-coverage \ diff --git a/readme.md b/readme.md index d2d57c7..7a3c16f 100644 --- a/readme.md +++ b/readme.md @@ -66,4 +66,11 @@ build with tests and run it ```bash cmake -DRUN_TESTS=on .. make +``` + +build with debug symboles + +```bash +cmake -DCMAKE_BUILD_TYPE=DEBUG .. +make ``` \ No newline at end of file -- 2.39.5