Skip to content

Commit 2535fb0

Browse files
committed
Add static library build to CMake
1 parent 5b80176 commit 2535fb0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ add_library(libhl SHARED
136136
${std_srcs}
137137
)
138138

139+
add_library(libhl-static STATIC
140+
${pcre_srcs}
141+
src/gc.c
142+
${std_srcs}
143+
)
144+
139145
set(public_headers
140146
src/hl.h
141147
src/hlc.h
@@ -146,16 +152,29 @@ set_target_properties(libhl
146152
PUBLIC_HEADER "${public_headers}"
147153
)
148154

155+
set_target_properties(libhl-static
156+
PROPERTIES
157+
PUBLIC_HEADER "${public_headers}"
158+
)
159+
149160
if(WIN32)
150161
set_target_properties(libhl
151162
PROPERTIES
152163
OUTPUT_NAME libhl
153164
)
165+
set_target_properties(libhl-static
166+
PROPERTIES
167+
OUTPUT_NAME libhl-static
168+
)
154169
else()
155170
set_target_properties(libhl
156171
PROPERTIES
157172
OUTPUT_NAME hl
158173
)
174+
set_target_properties(libhl-static
175+
PROPERTIES
176+
OUTPUT_NAME hl
177+
)
159178
endif()
160179

161180
set_target_properties(libhl
@@ -165,6 +184,11 @@ set_target_properties(libhl
165184
COMPILE_DEFINITIONS "_USRDLL;LIBHL_EXPORTS;HAVE_CONFIG_H;PCRE2_CODE_UNIT_WIDTH=16"
166185
)
167186

187+
set_target_properties(libhl-static
188+
PROPERTIES
189+
COMPILE_DEFINITIONS "_USRDLL;LIBHL_EXPORTS;HAVE_CONFIG_H;PCRE2_CODE_UNIT_WIDTH=16"
190+
)
191+
168192
add_executable(hl
169193
src/code.c
170194
src/jit.c
@@ -355,6 +379,7 @@ install(
355379
TARGETS
356380
hl
357381
libhl
382+
libhl-static
358383
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
359384
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
360385
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

0 commit comments

Comments
 (0)