From 82e2337ecc9c1746cfffbf95dd6add9da16ad2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 4 Oct 2025 21:35:39 +0200 Subject: [PATCH] Substitube build_type --- CMakeLists.txt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd1977e..f770602 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(libucore C) execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR} describe --abbrev=5 --dirty --always OUTPUT_VARIABLE version_revision WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND hostname OUTPUT_VARIABLE build_host OUTPUT_STRIP_TRAILING_WHITESPACE) - +cmake_host_system_information(RESULT build_host QUERY HOSTNAME) set(libucore_VERSION_MAJOR 1) set(libucore_VERSION_MINOR 0) set(libucore_VERSION_PATCH 0) @@ -11,28 +10,32 @@ set(libucore_VERSION ${libucore_VERSION_MAJOR}.${libucore_VERSION_MINOR}.${libuc set(CMAKE_VERBOSE_MAKEFILE ON) -set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD 11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wundef -Wcast-qual -Wshadow -Wcast-align -pipe -Wno-unused-parameter -Werror=implicit-function-declaration -Winit-self") add_definitions(-D_FILE_OFFSET_BITS=64) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O2") set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) option(CODE_COVERAGE "build with code coverage intrumentation" OFF) -if (CODE_COVERAGE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") - add_definitions(-DCOVERAGE) -endif() - -option(BUILD_SANITIZE "build with address sanitizer" OFF) -if (BUILD_SANITIZE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") -endif() if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) # Set the property for multi-config generators as well, if applicable set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel) endif() +set(build_type ${CMAKE_BUILD_TYPE}) +if (CODE_COVERAGE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") + add_definitions(-DCOVERAGE) + set(build_type "${build_type}-coverage") +endif() + +option(BUILD_SANITIZE "build with address sanitizer" OFF) +if (BUILD_SANITIZE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(build_type "${build_type}-sanitize") +endif() + include_directories(include)