summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2025-12-23 11:59:45 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-01-07 10:00:06 +0100
commit48c294105f5123dc876fbad199ec1e0166d82a18 (patch)
treec49ce8ac75a7d63c10ea1ff960eeff750c680a8e /src/irmd
parent145be13e8c18fcb39476d8f65fed23d82320f22f (diff)
downloadouroboros-48c294105f5123dc876fbad199ec1e0166d82a18.tar.gz
ouroboros-48c294105f5123dc876fbad199ec1e0166d82a18.zip
build: Refactor CMake modules
This moves the CMake build logic out of the source tree and splits it up into a more modular form. The tests now have a CMakeLists.txt file in their respective source directory. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/CMakeLists.txt119
-rw-r--r--src/irmd/reg/CMakeLists.txt9
-rw-r--r--src/irmd/reg/tests/CMakeLists.txt10
-rw-r--r--src/irmd/tests/CMakeLists.txt5
-rw-r--r--src/irmd/tests/oap_test.c2
5 files changed, 12 insertions, 133 deletions
diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt
deleted file mode 100644
index a9584b85..00000000
--- a/src/irmd/CMakeLists.txt
+++ /dev/null
@@ -1,119 +0,0 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-set(OUROBOROS_CONFIG_DIR /etc/ouroboros CACHE STRING
- "Configuration directory (should be absolute)")
-
-find_library(LIBTOML_LIBRARIES toml QUIET)
-if (LIBTOML_LIBRARIES)
- set(DISABLE_CONFIGFILE FALSE CACHE BOOL
- "Disable configuration file support")
- if (NOT DISABLE_CONFIGFILE)
- set(OUROBOROS_CONFIG_FILE irmd.conf CACHE STRING
- "Name of the IRMd configuration file")
- set(HAVE_TOML TRUE)
- message(STATUS "Found TOML C99 library: " ${LIBTOML_LIBRARIES})
- message(STATUS "Configuration file support enabled")
- message(STATUS "Configuration directory: ${OUROBOROS_CONFIG_DIR}")
- set(INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
- configure_file("${CMAKE_SOURCE_DIR}/irmd.conf.in"
- "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example" @ONLY)
- install(FILES "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example"
- DESTINATION "${OUROBOROS_CONFIG_DIR}")
- install(CODE "
- if (NOT EXISTS \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\")
- file(WRITE \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\" \"\")
- endif()
- ")
- unset(INSTALL_DIR)
- find_path(LIBTOML_INCLUDE toml.h)
- mark_as_advanced(LIBTOML_LIBRARIES LIBTOML_INCLUDE)
- else ()
- message(STATUS "Configuration file support disabled by user")
- unset(OUROBOROS_CONFIG_FILE CACHE)
- set(HAVE_TOML FALSE)
- endif ()
-else ()
- message(STATUS "Install tomlc99 for config file support")
- message(STATUS " https://github.com/cktan/tomlc99")
- set(LIBTOML_LIBRARIES "")
- unset(DISABLE_CONFIGFILE CACHE)
- unset(HAVE_TOML)
-endif ()
-
-set(OUROBOROS_SECURITY_DIR "${OUROBOROS_CONFIG_DIR}/security" CACHE STRING
- "Security directory holding authentication information")
-set(OUROBOROS_CA_CRT_DIR "${OUROBOROS_SECURITY_DIR}/cacert" CACHE STRING
- "Directory holding trusted CA certificates")
-set(OUROBOROS_SRV_CRT_DIR "${OUROBOROS_SECURITY_DIR}/server" CACHE STRING
- "Directory holding trusted CA certificates")
-set(OUROBOROS_CLI_CRT_DIR "${OUROBOROS_SECURITY_DIR}/client" CACHE STRING
- "Directory holding trusted CA certificates")
-set(OUROBOROS_UNTRUSTED_DIR "${OUROBOROS_SECURITY_DIR}/untrusted" CACHE STRING
- "Directory holding untrusted intermediate certificates")
-
-set(IRMD_REQ_ARR_TIMEOUT 1000 CACHE STRING
- "Timeout for an application to respond to a new flow (ms)")
-set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
- "Timeout for an IPCP to bootstrap (ms)")
-set(ENROLL_TIMEOUT 20000 CACHE STRING
- "Timeout for an IPCP to enroll (ms)")
-set(REG_TIMEOUT 20000 CACHE STRING
- "Timeout for registering a name (ms)")
-set(QUERY_TIMEOUT 200 CACHE STRING
- "Timeout to query a name with an IPCP (ms)")
-set(CONNECT_TIMEOUT 20000 CACHE STRING
- "Timeout to connect an IPCP to another IPCP (ms)")
-set(FLOW_ALLOC_TIMEOUT 20000 CACHE STRING
- "Timeout for a flow allocation response (ms)")
-set(IRMD_MIN_THREADS 8 CACHE STRING
- "Minimum number of worker threads in the IRMd")
-set(IRMD_ADD_THREADS 8 CACHE STRING
- "Number of extra threads to start when the IRMD faces thread starvation")
-set(IRMD_PKILL_TIMEOUT 30 CACHE STRING
- "Number of seconds to wait before sending SIGKILL to subprocesses on exit")
-set(IRMD_KILL_ALL_PROCESSES TRUE CACHE BOOL
- "Kill all processes on exit")
-set(DEBUG_PROTO_OAP FALSE CACHE BOOL
- "Add Flow allocation protocol message output to IRMd debug logging")
-
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
- "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
-
-set(SOURCE_FILES
- # Add source files here
- ipcp.c
- configfile.c
- main.c
- oap.c
- reg/flow.c
- reg/ipcp.c
- reg/proc.c
- reg/prog.c
- reg/name.c
- reg/reg.c
- )
-
-add_executable (irmd ${SOURCE_FILES})
-
-target_link_libraries (irmd LINK_PUBLIC ouroboros-common
- ${LIBTOML_LIBRARIES})
-
-if (HAVE_TOML)
- target_include_directories(irmd PUBLIC ${LIBTOML_INCLUDE})
-endif ()
-
-include(AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-install(TARGETS irmd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
-
-add_subdirectory(reg)
-if(BUILD_TESTS)
- add_subdirectory(tests)
-endif ()
diff --git a/src/irmd/reg/CMakeLists.txt b/src/irmd/reg/CMakeLists.txt
deleted file mode 100644
index d3844908..00000000
--- a/src/irmd/reg/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-if(BUILD_TESTS)
- add_subdirectory(tests)
-endif ()
diff --git a/src/irmd/reg/tests/CMakeLists.txt b/src/irmd/reg/tests/CMakeLists.txt
index d2907a93..eb7a1765 100644
--- a/src/irmd/reg/tests/CMakeLists.txt
+++ b/src/irmd/reg/tests/CMakeLists.txt
@@ -1,6 +1,14 @@
get_filename_component(tmp ".." ABSOLUTE)
get_filename_component(src_folder "${tmp}" NAME)
+# Set include directories for tests
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${CMAKE_BINARY_DIR}/include)
+include_directories(${CMAKE_SOURCE_DIR}/src/irmd)
+include_directories(${CMAKE_BINARY_DIR}/src/irmd)
+
create_test_sourcelist(${src_folder}_tests test_suite.c
# Add new tests here
flow_test.c
@@ -29,5 +37,5 @@ endif()
foreach(test ${tests_to_run})
get_filename_component(test_name ${test} NAME_WE)
- add_test(irmd/reg/${test_name} ${C_TEST_PATH}/${src_folder}_test ${test_name})
+ add_test(irmd/reg/${test_name} ${CMAKE_CURRENT_BINARY_DIR}/${src_folder}_test ${test_name})
endforeach(test)
diff --git a/src/irmd/tests/CMakeLists.txt b/src/irmd/tests/CMakeLists.txt
index 5bef0064..a255ca00 100644
--- a/src/irmd/tests/CMakeLists.txt
+++ b/src/irmd/tests/CMakeLists.txt
@@ -8,7 +8,8 @@ create_test_sourcelist(${src_folder}_tests test_suite.c
)
add_executable(${src_folder}_test ${${src_folder}_tests})
-target_link_libraries(${src_folder}_test ouroboros-common)
+target_link_libraries(${src_folder}_test ouroboros-irm)
+target_include_directories(${src_folder}_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
add_dependencies(build_tests ${src_folder}_test)
@@ -21,7 +22,7 @@ endif()
foreach(test ${tests_to_run})
get_filename_component(test_name ${test} NAME_WE)
- add_test(irmd/${test_name} ${C_TEST_PATH}/${src_folder}_test ${test_name})
+ add_test(irmd/${test_name} ${CMAKE_CURRENT_BINARY_DIR}/${src_folder}_test ${test_name})
endforeach(test)
set_property(TEST irmd/oap_test PROPERTY SKIP_RETURN_CODE 1)
diff --git a/src/irmd/tests/oap_test.c b/src/irmd/tests/oap_test.c
index 4e7fb2d1..a5f9c706 100644
--- a/src/irmd/tests/oap_test.c
+++ b/src/irmd/tests/oap_test.c
@@ -19,8 +19,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include "config.h"
-
#include "oap.c"
#include <ouroboros/random.h>