windows: Build liblily as a static library.
file(GLOB lily_SOURCES *.c *.h)
-# The goal is to have a lily executable that's standalone, and a shared liblily
-# library. The two use the same sources, put together in an object library.
+# The objects in this library are used to build several targets, but the library
+# itself is never installed.
add_library(liblily_obj OBJECT ${lily_SOURCES})
+
+if(WIN32)
+ # C extensions that use interpreter functions need to have their own copy of
+ # interpreter functions due to how DLLs work. This builds that.
+ add_library(liblily STATIC $<TARGET_OBJECTS:liblily_obj>)
+else()
add_library(liblily SHARED $<TARGET_OBJECTS:liblily_obj>)
-if(NOT MSVC)
if(LILY_NEED_DL)
target_link_libraries(liblily dl)
endif()
+
# -fPIC is needed for it to work properly as a shared library.
set_target_properties(liblily_obj PROPERTIES COMPILE_FLAGS "-fPIC")
+
# This prevents the shared library being named libliblily
set_target_properties(liblily PROPERTIES PREFIX "")
endif()
