From 3796f6b04b5fce183e5480b57725545cda033f99 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 --- CMakeLists.txt | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ed52fd2..d225d29d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12.2...4.0.3.0) -cmake_policy(VERSION ${CMAKE_VERSION}) +cmake_minimum_required(VERSION 3.19) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") @@ -7,50 +6,67 @@ project(ouroboros C) include(GNUInstallDirs) +include(utils/DebugTargets) + include(version) include(package) include(compiler) -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - if (APPLE) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if(APPLE) set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING "Installation Prefix" FORCE) else() set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "Installation Prefix" FORCE) endif() -endif () +endif() -if (APPLE) +if(APPLE) set(CMAKE_MACOSX_RPATH 1) - include_directories("/usr/local/include/") + # Homebrew installs to /usr/local/include on Intel, /opt/homebrew/include on ARM + set(APPLE_INCLUDE_DIRS "/usr/local/include" "/opt/homebrew/include" + CACHE INTERNAL "Apple system include directories") endif() -if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") +if(CMAKE_INSTALL_PREFIX STREQUAL "/usr") set(RPATH_PREFIX "") -else () +else() set(RPATH_PREFIX ${CMAKE_INSTALL_PREFIX}) -endif () +endif() set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${RPATH_PREFIX}/lib" isSystemDir) -IF ("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${RPATH_PREFIX}/lib") -ENDIF ("${isSystemDir}" STREQUAL "-1") + "${RPATH_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir) +if(isSystemDir STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${RPATH_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +endif() include(dependencies) -include(include) -include(lib) -include(ipcp) -include(irmd) -include(tools) +# Configuration options (must be loaded before component modules) +include(config/global) +include(config/lib) +include(config/ssm) +include(config/irmd) +include(config/ipcp/common) +include(config/ipcp/unicast) +include(config/ipcp/broadcast) +include(config/ipcp/local) +include(config/ipcp/eth) +include(config/ipcp/udp) + include(tests) +include(include) +add_subdirectory(src/lib) +add_subdirectory(src/irmd) +add_subdirectory(src/ipcpd) +add_subdirectory(src/tools) +setup_coverage_target() include(doc) include(install) -- cgit v1.2.3