Skip to content

Commit

Permalink
Add static library build to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
moggers87 committed Jun 4, 2024
1 parent 5b80176 commit 2535fb0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ add_library(libhl SHARED
${std_srcs}
)

add_library(libhl-static STATIC
${pcre_srcs}
src/gc.c
${std_srcs}
)

set(public_headers
src/hl.h
src/hlc.h
Expand All @@ -146,16 +152,29 @@ set_target_properties(libhl
PUBLIC_HEADER "${public_headers}"
)

set_target_properties(libhl-static
PROPERTIES
PUBLIC_HEADER "${public_headers}"
)

if(WIN32)
set_target_properties(libhl
PROPERTIES
OUTPUT_NAME libhl
)
set_target_properties(libhl-static
PROPERTIES
OUTPUT_NAME libhl-static
)
else()
set_target_properties(libhl
PROPERTIES
OUTPUT_NAME hl
)
set_target_properties(libhl-static
PROPERTIES
OUTPUT_NAME hl
)
endif()

set_target_properties(libhl
Expand All @@ -165,6 +184,11 @@ set_target_properties(libhl
COMPILE_DEFINITIONS "_USRDLL;LIBHL_EXPORTS;HAVE_CONFIG_H;PCRE2_CODE_UNIT_WIDTH=16"
)

set_target_properties(libhl-static
PROPERTIES
COMPILE_DEFINITIONS "_USRDLL;LIBHL_EXPORTS;HAVE_CONFIG_H;PCRE2_CODE_UNIT_WIDTH=16"
)

add_executable(hl
src/code.c
src/jit.c
Expand Down Expand Up @@ -355,6 +379,7 @@ install(
TARGETS
hl
libhl
libhl-static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down

0 comments on commit 2535fb0

Please sign in to comment.