@@ -7,7 +7,7 @@ include(${LF_ROOT}/core/lf_utils.cmake)
77list (APPEND GENERAL_SOURCES tag.c clock.c port.c mixed_radix.c reactor_common.c lf_token.c environment .c)
88
99# Add tracing support if requested
10- if (DEFINED LF_TRACE)
10+ if (DEFINED LF_TRACE)
1111 message (STATUS "Including sources specific to tracing." )
1212 list (APPEND GENERAL_SOURCES tracepoint.c)
1313endif ()
@@ -16,7 +16,7 @@ endif()
1616list (APPEND REACTORC_SOURCES ${GENERAL_SOURCES} )
1717
1818# Add sources for either threaded or single-threaded runtime
19- if (DEFINED FEDERATED)
19+ if (DEFINED FEDERATED)
2020 include (federated/CMakeLists.txt)
2121 include (federated/network/CMakeLists.txt)
2222endif ()
@@ -35,14 +35,14 @@ endif()
3535
3636# Add sources for the local RTI if we are using scheduling enclaves
3737if (DEFINED LF_ENCLAVES)
38- include (federated/RTI/local_rti.cmake)
38+ include (federated/RTI/local_rti.cmake)
3939endif ()
4040
4141# Include sources from subdirectories
4242include (utils/CMakeLists.txt)
4343
44- if (DEFINED MODAL_REACTORS)
45- include (modal_models/CMakeLists.txt)
44+ if (DEFINED MODAL_REACTORS)
45+ include (modal_models/CMakeLists.txt)
4646endif ()
4747
4848# Print sources used for compilation
@@ -53,15 +53,28 @@ add_library(reactor-c)
5353target_sources (reactor-c PRIVATE ${REACTORC_SOURCES} )
5454lf_enable_compiler_warnings(reactor-c)
5555
56- if (DEFINED LF_TRACE)
56+ if (DEFINED LF_TRACE)
5757 include (${LF_ROOT} /trace/api/CMakeLists.txt)
58- if (NOT LF_TRACE_PLUGIN)
59- set (LF_TRACE_PLUGIN lf::trace-impl)
58+ target_link_libraries (reactor-c PUBLIC lf::trace-api)
59+ # If the user specified an external trace plugin. Find it and link with it
60+ if (LF_TRACE_PLUGIN)
61+ message (STATUS "Linking trace plugin library ${LF_TRACE_PLUGIN} " )
62+ find_library (TRACE_LIB NAMES ${LF_TRACE_PLUGIN} HINTS "${LF_ROOT} " )
63+ if (NOT TRACE_LIB)
64+ message (FATAL_ERROR "The trace plugin library ${LF_TRACE_PLUGIN} not found" )
65+ endif ()
66+ # We also link with libdl because it is needed for some platforms.
67+ # TODO: Figure out why this is the case and how to avoid it.
68+ target_link_libraries (reactor-c PRIVATE ${TRACE_LIB} dl)
69+ else ()
70+ # If not, use the default implementation
71+ message (STATUS "Linking with default trace implementation" )
6072 include (${LF_ROOT} /trace/impl/CMakeLists.txt)
73+ target_link_libraries (reactor-c PRIVATE lf::trace-impl)
6174 endif ()
62- message ( STATUS "linking trace plugin library ${LF_TRACE_PLUGIN} " )
63- target_link_libraries (reactor-c PUBLIC lf:: trace- api)
64- target_link_libraries (reactor-c PRIVATE " ${LF_TRACE_PLUGIN} " )
75+ else ( )
76+ include ( ${LF_ROOT} / trace/ api/types/CMakeLists.txt )
77+ target_link_libraries (reactor-c PUBLIC lf::trace-api-types )
6578endif ()
6679
6780include (${LF_ROOT} /version /api/CMakeLists.txt)
@@ -93,43 +106,46 @@ target_include_directories(reactor-c PUBLIC ../include/core/threaded)
93106target_include_directories (reactor-c PUBLIC ../include /core/utils)
94107target_include_directories (reactor-c PUBLIC federated/RTI/)
95108
96- if (APPLE )
97- SET (CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>" )
109+ if (APPLE )
110+ SET (CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>" )
98111 SET (CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>" )
99- SET (CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>" )
112+ SET (CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>" )
100113 SET (CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>" )
101114endif ()
102115
103116# Link with OpenSSL library
104117if (DEFINED FEDERATED_AUTHENTICATED)
105- if (APPLE )
118+ if (APPLE )
106119 set (OPENSSL_ROOT_DIR /usr/local/opt/openssl)
107120 endif ()
121+
108122 find_package (OpenSSL REQUIRED)
109123 target_link_libraries (reactor-c PUBLIC OpenSSL::SSL)
110124endif ()
111125
112- if (DEFINED _LF_CLOCK_SYNC_ON )
126+ if (DEFINED FEDERATED )
113127 find_library (MATH_LIBRARY m)
114128 if (MATH_LIBRARY)
115129 target_link_libraries (reactor-c PUBLIC ${MATH_LIBRARY} )
116130 endif ()
117131endif ()
118132
119133# Unless specified otherwise initial event queue and reaction queue to size 10
120- if (NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
134+ if (NOT DEFINED INITIAL_EVENT_QUEUE_SIZE)
121135 set (INITIAL_EVENT_QUEUE_SIZE 10)
122136endif ()
123- if (NOT DEFINED INITIAL_REACT_QUEUE_SIZE)
137+
138+ if (NOT DEFINED INITIAL_REACT_QUEUE_SIZE)
124139 set (INITIAL_REACT_QUEUE_SIZE 10)
125140endif ()
126141
127142target_compile_definitions (reactor-c PRIVATE INITIAL_EVENT_QUEUE_SIZE=${INITIAL_EVENT_QUEUE_SIZE} )
128143target_compile_definitions (reactor-c PRIVATE INITIAL_REACT_QUEUE_SIZE=${INITIAL_REACT_QUEUE_SIZE} )
129144target_compile_definitions (reactor-c PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME} )
130145
131- # Macro for translating a command-line argument into compile definition for
132- # reactor-c lib
146+ # If variable X is defined in cMake (set using SET()) or passed in as a command-line
147+ # argument using -DX=<value>, then make it a compiler flag for reactor-c so that X
148+ # is also defined in the C code for reactor-c.
133149macro (define X)
134150 if (DEFINED ${X} )
135151 message (STATUS ${X} =${${X} })
@@ -142,9 +158,9 @@ message(STATUS "Applying preprocessor definitions...")
142158define(_LF_CLOCK_SYNC_ATTENUATION)
143159define(_LF_CLOCK_SYNC_COLLECT_STATS)
144160define(_LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL)
145- define(_LF_CLOCK_SYNC_INITIAL)
146- define(_LF_CLOCK_SYNC_ON)
161+ define(LF_CLOCK_SYNC) # 1 for OFF, 2 for INIT and 3 for ON.
147162define(_LF_CLOCK_SYNC_PERIOD_NS)
163+ define(_LF_FEDERATE_NAMES_COMMA_SEPARATED)
148164define(ADVANCE_MESSAGE_INTERVAL)
149165define(EXECUTABLE_PREAMBLE)
150166define(FEDERATED_CENTRALIZED)
0 commit comments