@@ -9,11 +9,8 @@ if (DEFINED LF_TRACE)
99 list (APPEND GENERAL_SOURCES trace.c)
1010endif ()
1111
12- # Store all sources used to build the reactor-c lib in INFO_SOURCES
13- list (APPEND INFO_SOURCES ${GENERAL_SOURCES} )
14-
15- # Create the core library
16- add_library (core ${GENERAL_SOURCES} )
12+ # Add the general sources to the list of REACTORC_SOURCES
13+ list (APPEND REACTORC_SOURCES ${GENERAL_SOURCES} )
1714
1815# Add sources for either threaded or single-threaded runtime
1916if (DEFINED FEDERATED)
@@ -25,8 +22,7 @@ endif()
2522if (DEFINED LF_SINGLE_THREADED)
2623 message (STATUS "Including sources for single-threaded runtime." )
2724 list (APPEND SINGLE_THREADED_SOURCES reactor.c)
28- target_sources (core PRIVATE ${SINGLE_THREADED_SOURCES} )
29- list (APPEND INFO_SOURCES ${SINGLE_THREADED_SOURCES} )
25+ list (APPEND REACTORC_SOURCES ${SINGLE_THREADED_SOURCES} )
3026else ()
3127 message (STATUS "Including sources for threaded runtime with \
3228${NUMBER_OF_WORKERS} worker(s) with scheduler=${SCHEDULER} and \
@@ -44,20 +40,33 @@ include(utils/CMakeLists.txt)
4440include (modal_models/CMakeLists.txt)
4541include (platform/CMakeLists.txt)
4642
47-
4843# Print sources used for compilation
49- list (JOIN INFO_SOURCES ", " PRINTABLE_SOURCE_LIST)
44+ list (JOIN REACTORC_SOURCES ", " PRINTABLE_SOURCE_LIST)
5045message (STATUS "Including the following sources: " ${PRINTABLE_SOURCE_LIST} )
5146
52- target_include_directories (core PUBLIC ../include )
53- target_include_directories (core PUBLIC ../include /core)
54- target_include_directories (core PUBLIC ../include /core/federated)
55- target_include_directories (core PUBLIC ../include /core/federated/network)
56- target_include_directories (core PUBLIC ../include /core/platform)
57- target_include_directories (core PUBLIC ../include /core/modal_models)
58- target_include_directories (core PUBLIC ../include /core/threaded)
59- target_include_directories (core PUBLIC ../include /core/utils)
60- target_include_directories (core PUBLIC federated/RTI/)
47+ # Create the reactor-c library. If we are targeting Zephyr we have to use the
48+ # Zephyr Cmake extension to create the library and add the sources.
49+ if (PLATFORM_ZEPHYR)
50+ message ("--- Building Zephyr library" )
51+ zephyr_library_named(reactor-c)
52+ zephyr_library_sources(${REACTORC_SOURCES} )
53+ zephyr_library_link_libraries(kernel)
54+ else ()
55+ add_library (reactor-c ${REACTORC_SOURCES} )
56+ endif ()
57+
58+ # Apply compile definitions to the reactor-c library.
59+ target_compile_definitions (reactor-c PUBLIC ${REACTORC_COMPILE_DEFS} )
60+
61+ target_include_directories (reactor-c PUBLIC ../include )
62+ target_include_directories (reactor-c PUBLIC ../include /core)
63+ target_include_directories (reactor-c PUBLIC ../include /core/federated)
64+ target_include_directories (reactor-c PUBLIC ../include /core/federated/network)
65+ target_include_directories (reactor-c PUBLIC ../include /core/platform)
66+ target_include_directories (reactor-c PUBLIC ../include /core/modal_models)
67+ target_include_directories (reactor-c PUBLIC ../include /core/threaded)
68+ target_include_directories (reactor-c PUBLIC ../include /core/utils)
69+ target_include_directories (reactor-c PUBLIC federated/RTI/)
6170
6271if (APPLE )
6372 SET (CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>" )
@@ -72,38 +81,38 @@ if(DEFINED FEDERATED_AUTHENTICATED)
7281 set (OPENSSL_ROOT_DIR /usr/local/opt/openssl)
7382 endif ()
7483 find_package (OpenSSL REQUIRED)
75- target_link_libraries (core PUBLIC OpenSSL::SSL)
84+ target_link_libraries (reactor-c PUBLIC OpenSSL::SSL)
7685endif ()
7786
7887if (DEFINED _LF_CLOCK_SYNC_ON)
7988 find_library (MATH_LIBRARY m)
8089 if (MATH_LIBRARY)
81- target_link_libraries (core PUBLIC ${MATH_LIBRARY} )
90+ target_link_libraries (reactor-c PUBLIC ${MATH_LIBRARY} )
8291 endif ()
8392endif ()
8493
85- # Link with thread library, unless if we are targeting the Zephyr RTOS
94+ # Link with thread library, unless we are on the Zephyr platform.
8695if (NOT DEFINED LF_SINGLE_THREADED OR DEFINED LF_TRACE)
87- if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Zephyr" )
96+ if (NOT PLATFORM_ZEPHYR )
8897 find_package (Threads REQUIRED)
89- target_link_libraries (core PUBLIC Threads::Threads)
98+ target_link_libraries (reactor-c PUBLIC Threads::Threads)
9099 endif ()
91100endif ()
92101
93102# Macro for translating a command-line argument into compile definition for
94- # core lib
103+ # reactor-c lib
95104macro (define X)
96105 if (DEFINED ${X} )
97106 message (STATUS ${X} =${${X} })
98- target_compile_definitions (core PUBLIC ${X} =${${X} })
107+ target_compile_definitions (reactor-c PUBLIC ${X} =${${X} })
99108 endif (DEFINED ${X} )
100109endmacro ()
101110
102111# FIXME: May want these to be application dependent, hence passed as
103112# parameters to Cmake.
104- target_compile_definitions (core PRIVATE INITIAL_EVENT_QUEUE_SIZE=10)
105- target_compile_definitions (core PRIVATE INITIAL_REACT_QUEUE_SIZE=10)
106- target_compile_definitions (core PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME} )
113+ target_compile_definitions (reactor-c PRIVATE INITIAL_EVENT_QUEUE_SIZE=10)
114+ target_compile_definitions (reactor-c PRIVATE INITIAL_REACT_QUEUE_SIZE=10)
115+ target_compile_definitions (reactor-c PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME} )
107116
108117# Search and apply all possible compile definitions
109118message (STATUS "Applying preprocessor definitions..." )
0 commit comments