prefer CMake's builtin BUILD_SHARED_LIBS option

This commit is contained in:
Lukas Böger 2021-05-25 13:30:47 +01:00
parent eb6c9db857
commit 76bce1ce1c

View file

@ -36,9 +36,9 @@ check_include_file(poll.h HAVE_POLL_H)
check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stdint.h HAVE_STDINT_H)
# option(CHIBI_SCHEME_USE_DL "Use dynamic loading" ON) # option(CHIBI_SCHEME_USE_DL "Use dynamic loading" ON)
set(CHIBI_SCHEME_USE_DL OFF) set(CHIBI_SCHEME_USE_DL OFF)
option(CHIBI_SCHEME_SHARED "Build chibi-scheme as a shared library" ON) option(BUILD_SHARED_LIBS "Build chibi-scheme as a shared library" ON)
if(NOT CHIBI_SCHEME_SHARED) if(NOT ${BUILD_SHARED_LIBS})
add_definitions(-DSEXP_STATIC_LIBRARY=1) add_definitions(-DSEXP_STATIC_LIBRARY=1)
endif() endif()
@ -172,13 +172,7 @@ add_custom_command(OUTPUT ${clibout}
# Core library # Core library
# #
if(CHIBI_SCHEME_SHARED) add_library(lib-chibi-scheme
set(libtype SHARED)
else()
set(libtype STATIC)
endif()
add_library(lib-chibi-scheme ${libtype}
${chibi-scheme-srcs} ${chibi-scheme-srcs}
${clibout}) ${clibout})
@ -188,14 +182,14 @@ set_target_properties(lib-chibi-scheme
add_dependencies(lib-chibi-scheme chibi-scheme-stubs) add_dependencies(lib-chibi-scheme chibi-scheme-stubs)
if(WIN32 AND CHIBI_SCHEME_SHARED) if(WIN32 AND ${BUILD_SHARED_LIBS})
target_link_libraries(lib-chibi-scheme ws2_32) target_link_libraries(lib-chibi-scheme ws2_32)
target_compile_definitions(lib-chibi-scheme PUBLIC -DBUILDING_DLL=1) target_compile_definitions(lib-chibi-scheme PUBLIC -DBUILDING_DLL=1)
endif() endif()
function(bless_chibi_scheme_executable tgt) function(bless_chibi_scheme_executable tgt)
target_link_libraries(${tgt} lib-chibi-scheme) target_link_libraries(${tgt} lib-chibi-scheme)
if(WIN32 AND NOT CHIBI_SCHEME_SHARED) if(WIN32 AND NOT ${BUILD_SHARED_LIBS})
target_link_libraries(${tgt} ws2_32) target_link_libraries(${tgt} ws2_32)
endif() endif()
endfunction() endfunction()