generate and add clibs.c only for static builds

This commit is contained in:
Lukas Böger 2021-05-27 21:46:31 +01:00
parent 5402d86323
commit 9fab5cf4dd

View file

@ -142,10 +142,25 @@ foreach(e ${stubs})
endforeach() endforeach()
add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts}) add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts})
#
# Core library
#
add_library(libchibi-scheme
${chibi-scheme-srcs})
set_target_properties(libchibi-scheme
PROPERTIES
SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR}
VERSION ${CMAKE_PROJECT_VERSION})
add_dependencies(libchibi-scheme chibi-scheme-stubs)
# #
# Generate clib.c for SEXP_USE_STATIC_LIBS # Generate clib.c for SEXP_USE_STATIC_LIBS
# #
if (NOT BUILD_SHARED_LIBS)
string(REPLACE ";" "\n" genstatic-input "${slds}") string(REPLACE ";" "\n" genstatic-input "${slds}")
set(clibin ${CMAKE_CURRENT_BINARY_DIR}/clib-in.txt) set(clibin ${CMAKE_CURRENT_BINARY_DIR}/clib-in.txt)
set(clibout ${CMAKE_CURRENT_BINARY_DIR}/clib.c) set(clibout ${CMAKE_CURRENT_BINARY_DIR}/clib.c)
@ -153,6 +168,7 @@ set(genstatic-helper
${CMAKE_CURRENT_LIST_DIR}/contrib/chibi-genstatic-helper.cmake) ${CMAKE_CURRENT_LIST_DIR}/contrib/chibi-genstatic-helper.cmake)
file(WRITE ${clibin} "${genstatic-input}") file(WRITE ${clibin} "${genstatic-input}")
add_custom_command(OUTPUT ${clibout} add_custom_command(OUTPUT ${clibout}
COMMAND COMMAND
${CMAKE_COMMAND} ${CMAKE_COMMAND}
@ -168,25 +184,16 @@ add_custom_command(OUTPUT ${clibout}
${genstatic-helper} ${genstatic-helper}
${slds}) ${slds})
# target_compile_definitions(libchibi-scheme
# Core library PUBLIC
# SEXP_USE_STATIC_LIBS=1)
add_library(libchibi-scheme target_sources(libchibi-scheme
${chibi-scheme-srcs} PUBLIC
${clibout}) ${clibout})
elseif(WIN32)
set_target_properties(libchibi-scheme
PROPERTIES
SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR}
VERSION ${CMAKE_PROJECT_VERSION}
COMPILE_DEFINITIONS "SEXP_USE_STATIC_LIBS=1")
add_dependencies(libchibi-scheme chibi-scheme-stubs)
if(WIN32 AND ${BUILD_SHARED_LIBS})
target_link_libraries(libchibi-scheme ws2_32) target_link_libraries(libchibi-scheme ws2_32)
target_compile_definitions(libchibi-scheme PUBLIC -DBUILDING_DLL=1) target_compile_definitions(libchibi-scheme PUBLIC BUILDING_DLL=1)
endif() endif()
function(bless_chibi_scheme_executable tgt) function(bless_chibi_scheme_executable tgt)