From 4c64d7daef8819d644ab78a911067b16943f023d Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 2 Feb 2026 22:50:17 +0100 Subject: build: Refactor CMake back to in-tree CMakeLists This moves the build definitions back to src/ subdirectories (CMakeLists.txt per component). Configuration and dependencies are kept out of tree. Configuration options are bundled into cmake/config/ modules. Dependencies are grouped by component (system/, crypt/, eth/, coverage/, etc.). It now consistently uses target-based commands (target_include_directories, target_link_libraries) instead of global include_directories(). Proper PRIVATE/PUBLIC visibility for executable link libraries. CONFIG_OUROBOROS_DEBUG now properly set based on being a valid debug config (not just checking the string name). It also adds OuroborosTargets export for find_package() support and CMake package config files (OuroborosConfig.cmake) for easier integration with CMake projects. The build logic now follows more idiomatic CMake practices with configuration separated from target definitions. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- cmake/compiler.cmake | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'cmake/compiler.cmake') diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 6258cca0..5d452e02 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -31,42 +31,34 @@ test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement) test_and_set_c_compiler_flag_global(-Winfinite-recursion) test_and_set_c_compiler_flag_global(-fmax-errors=5) -set(DISABLE_COVERAGE ON CACHE BOOL "Disable code coverage analysis") - -if (NOT DISABLE_COVERAGE) - test_and_set_c_compiler_flag_global(-g) - test_and_set_c_compiler_flag_global(--coverage) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") - set(ENABLE_COVERAGE ON) -else() - set(ENABLE_COVERAGE OFF) -endif() - -if (NOT CMAKE_BUILD_TYPE) +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE) endif() -if (CMAKE_BUILD_TYPE STREQUAL "Release") +if(CMAKE_BUILD_TYPE STREQUAL "Release") test_and_set_c_compiler_flag_global(-O3) -elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") +elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") test_and_set_c_compiler_flag_global(-g) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugASan") +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugASan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=address) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan") + add_link_options(-fsanitize=address) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugTSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=thread) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan") + add_link_options(-fsanitize=thread) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugLSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=leak) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugUSan") + add_link_options(-fsanitize=leak) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugUSan") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fsanitize=undefined) -elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer") + add_link_options(-fsanitize=undefined) +elseif(CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer") test_and_set_c_compiler_flag_global(-g) test_and_set_c_compiler_flag_global(-fanalyzer) -else () - message(FATAL_ERROR "Unkown build type ${CMAKE_BUILD_TYPE}") -endif () +else() + message(FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}") +endif() -- cgit v1.2.3