@@ -41,6 +41,26 @@ add_custom_command(
4141 COMMENT "Generating version.c"
4242)
4343
44+ # -----------------------------------------------------------------------------
45+ # Shared source list
46+ # -----------------------------------------------------------------------------
47+
48+ set (CLOX_SOURCES
49+ src/asserts.c
50+ src/chunk.c
51+ src/compiler.c
52+ src/debug.c
53+ src/hashtable.c
54+ src/memory.c
55+ src/native.c
56+ src/object.c
57+ src/scanner.c
58+ src/token.c
59+ src/value.c
60+ src/vm.c
61+ ${VERSION_C}
62+ )
63+
4464# -----------------------------------------------------------------------------
4565# Shared configuration helpers
4666# -----------------------------------------------------------------------------
@@ -89,46 +109,37 @@ function(enable_coverage TARGET_NAME)
89109endfunction ()
90110
91111# -----------------------------------------------------------------------------
92- # Main runtime library
112+ # Main runtime library (static)
93113# -----------------------------------------------------------------------------
94114
95115add_library (clox_core STATIC
96- src/asserts.c
97- src/chunk.c
98- src/compiler.c
99- src/debug.c
100- src/hashtable.c
101- src/memory.c
102- src/native.c
103- src/object.c
104- src/scanner.c
105- src/token.c
106- src/value.c
107- src/vm.c
108- ${VERSION_C}
116+ ${CLOX_SOURCES}
109117)
110118
111119configure_clox_target (clox_core )
112120enable_coverage (clox_core )
113121
122+ # -----------------------------------------------------------------------------
123+ # Shared runtime library
124+ # -----------------------------------------------------------------------------
125+
126+ add_library (cloxlib SHARED
127+ ${CLOX_SOURCES}
128+ )
129+
130+ set_target_properties (cloxlib PROPERTIES
131+ OUTPUT_NAME clox
132+ )
133+
134+ configure_clox_target (cloxlib )
135+ enable_coverage (cloxlib )
136+
114137# -----------------------------------------------------------------------------
115138# Debug runtime library
116139# -----------------------------------------------------------------------------
117140
118141add_library (clox_core_debug STATIC
119- src/asserts.c
120- src/chunk.c
121- src/compiler.c
122- src/debug.c
123- src/hashtable.c
124- src/memory.c
125- src/native.c
126- src/object.c
127- src/scanner.c
128- src/token.c
129- src/value.c
130- src/vm.c
131- ${VERSION_C}
142+ ${CLOX_SOURCES}
132143)
133144
134145target_compile_definitions (clox_core_debug
@@ -235,4 +246,4 @@ if(BUILD_TESTS)
235246 COMMAND clox-value-unit-test
236247 )
237248
238- endif ()
249+ endif ()
0 commit comments