diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-02-02 22:50:17 +0100 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-02-04 08:17:24 +0100 |
| commit | 4c64d7daef8819d644ab78a911067b16943f023d (patch) | |
| tree | 7545488b224d510017f08a99006d9949367a9d77 /cmake/lib/common.cmake | |
| parent | b1687570df3e080c961cdcc0d59b708cfbdf955e (diff) | |
| download | ouroboros-4c64d7daef8819d644ab78a911067b16943f023d.tar.gz ouroboros-4c64d7daef8819d644ab78a911067b16943f023d.zip | |
build: Refactor CMake back to in-tree CMakeListsbe
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 <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake/lib/common.cmake')
| -rw-r--r-- | cmake/lib/common.cmake | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/cmake/lib/common.cmake b/cmake/lib/common.cmake deleted file mode 100644 index b0898950..00000000 --- a/cmake/lib/common.cmake +++ /dev/null @@ -1,124 +0,0 @@ -# Common library configuration - -set(LIB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/lib") -set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/src/lib") - -# Protobuf files -set_source_files_properties( - "${LIB_SOURCE_DIR}/pb/model.proto" - "${LIB_SOURCE_DIR}/pb/ipcp_config.proto" - "${LIB_SOURCE_DIR}/pb/enroll.proto" - "${LIB_SOURCE_DIR}/pb/cep.proto" - "${LIB_SOURCE_DIR}/pb/irm.proto" - "${LIB_SOURCE_DIR}/pb/ipcp.proto" - PROPERTIES - COMPILE_FLAGS "-I${LIB_SOURCE_DIR}/pb" -) - -protobuf_generate_c(MODEL_PROTO_SRCS MODEL_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/model.proto") -protobuf_generate_c(IPCP_CONFIG_PROTO_SRCS IPCP_CONFIG_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/ipcp_config.proto") -protobuf_generate_c(ENROLL_PROTO_SRCS ENROLL_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/enroll.proto") -protobuf_generate_c(CEP_PROTO_SRCS CEP_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/cep.proto") -protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/irm.proto") -protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS - "${LIB_SOURCE_DIR}/pb/ipcp.proto") - -# Common library source files -set(SOURCE_FILES_COMMON - bitmap.c - btree.c - crc32.c - crypt.c - hash.c - list.c - lockfile.c - logs.c - md5.c - notifier.c - protobuf.c - qoscube.c - random.c - rib.c - serdes-irm.c - serdes-oep.c - sha3.c - ssm/flow_set.c - ssm/rbuff.c - ssm/pool.c - sockets.c - tpm.c - utils.c -) - -# Convert relative paths to absolute -set(SOURCE_FILES_COMMON_ABS) -foreach(src ${SOURCE_FILES_COMMON}) - list(APPEND SOURCE_FILES_COMMON_ABS "${LIB_SOURCE_DIR}/${src}") -endforeach() - -if (HAVE_OPENSSL) - set(OPENSSL_SOURCES "${LIB_SOURCE_DIR}/crypt/openssl.c") -else() - set(OPENSSL_SOURCES "") -endif() - -add_library(ouroboros-common SHARED - ${SOURCE_FILES_COMMON_ABS} - ${IRM_PROTO_SRCS} - ${IPCP_PROTO_SRCS} - ${IPCP_CONFIG_PROTO_SRCS} - ${MODEL_PROTO_SRCS} - ${ENROLL_PROTO_SRCS} - ${OPENSSL_SOURCES}) - -set_target_properties(ouroboros-common PROPERTIES - VERSION ${PACKAGE_VERSION} - SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}) - -include(utils/AddCompileFlags) -if (CMAKE_BUILD_TYPE MATCHES "Debug*") - add_compile_flags(ouroboros-common -DCONFIG_OUROBOROS_DEBUG) -endif () - -target_include_directories(ouroboros-common PUBLIC - ${LIB_SOURCE_DIR} - ${LIB_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include - ${CMAKE_BINARY_DIR} - ${PROTOBUF_C_INCLUDE_DIRS} - ${SYS_RND_HDR}) - -if (LIBGCRYPT_INCLUDE_DIR) - target_include_directories(ouroboros-common PUBLIC ${LIBGCRYPT_INCLUDE_DIR}) -endif () - -if (OPENSSL_INCLUDE_DIR) - target_include_directories(ouroboros-common PUBLIC ${OPENSSL_INCLUDE_DIR}) -endif () - - -target_link_libraries(ouroboros-common - ${LIBRT_LIBRARIES} - ${LIBPTHREAD_LIBRARIES} - ${PROTOBUF_C_LIBRARY}) - -if (OPENSSL_CRYPTO_LIBRARY) - target_link_libraries(ouroboros-common ${OPENSSL_CRYPTO_LIBRARY}) -endif () - -if (LIBGCRYPT_LIBRARIES) - target_link_libraries(ouroboros-common ${LIBGCRYPT_LIBRARIES}) -endif () - -if (FUSE_LIBRARIES) - target_link_libraries(ouroboros-common ${FUSE_LIBRARIES}) -endif () - -install(TARGETS ouroboros-common LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - |
