summaryrefslogtreecommitdiff
path: root/src/irmd/CMakeLists.txt
blob: fb1e6ca238729e3163b8d7c9814f5762ec2ff100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)

find_library(TOML_LIBRARIES toml QUIET)
if (TOML_LIBRARIES)
  set(DISABLE_CONFIGFILE FALSE CACHE BOOL
    "Disable configuration file support")
  if (NOT DISABLE_CONFIGFILE)
    set(OUROBOROS_CONFIG_DIR /etc/ouroboros/ CACHE STRING
      "Configuration directory")
    set(OUROBOROS_CONFIG_FILE irmd.conf CACHE STRING
      "Name of the IRMd configuration file")
    set(HAVE_TOML TRUE)
    message(STATUS "Found TOML C99 library: " ${TOML_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}/irmd.conf.example" @ONLY)
    install(FILES "${CMAKE_BINARY_DIR}/irmd.conf.example"
      DESTINATION "${OUROBOROS_CONFIG_DIR}")
    unset(INSTALL_DIR)
    mark_as_advanced(TOML_LIBRARIES)
  else ()
    message(STATUS "Configuration file support disabled by user")
    unset(OUROBOROS_CONFIG_FILE CACHE)
    unset(OUROBOROS_CONFIG_DIR CACHE)
    set(HAVE_TOML FALSE)
  endif ()
else ()
  message(STATUS "Install tomlc99 for config file support")
  message(STATUS "     https://github.com/cktan/tomlc99")
  unset(DISABLE_CONFIGFILE CACHE)
  unset(HAVE_TOML)
endif ()

set(IRMD_REQ_ARR_TIMEOUT 500 CACHE STRING
  "Timeout for an application to respond to a new flow (ms)")
set(IRMD_FLOW_TIMEOUT 5000 CACHE STRING
  "Timeout for a flow allocation response (ms)")
set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
  "Timeout for an IPCP to bootstrap (ms)")
set(ENROLL_TIMEOUT 60000 CACHE STRING
  "Timeout for an IPCP to enroll (ms)")
set(REG_TIMEOUT 10000 CACHE STRING
  "Timeout for registering a name (ms)")
set(QUERY_TIMEOUT 3000 CACHE STRING
  "Timeout to query a name with an IPCP (ms)")
set(CONNECT_TIMEOUT 60000 CACHE STRING
  "Timeout to connect an IPCP to another IPCP (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")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
  "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)

set(SOURCE_FILES
  # Add source files here
  proc_table.c
  prog_table.c
  ipcp.c
  configfile.c
  irm_flow.c
  main.c
  registry.c
  utils.c
  )

add_executable (irmd ${SOURCE_FILES})

target_link_libraries (irmd LINK_PUBLIC ouroboros-common
  ${TOML_LIBRARIES} ${CONFINI_LIBRARIES})

include(AddCompileFlags)
if (CMAKE_BUILD_TYPE MATCHES "Debug*")
  add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG)
endif ()

install(TARGETS irmd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})

# Enable once irmd has tests
# add_subdirectory(tests)