From 2535fb026053bc3779e475b0cf18bcb69001075a Mon Sep 17 00:00:00 2001 From: Matt Molyneaux Date: Sat, 9 Sep 2023 17:23:29 +0100 Subject: [PATCH] Add static library build to CMake --- CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 886c754af..16227dc4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -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 @@ -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}