DirectStorage icon indicating copy to clipboard operation
DirectStorage copied to clipboard

Adding optional configuration for building as a shared library vs static?

Open weedleeedle opened this issue 6 months ago • 0 comments

I needed to build a shared library version of GDeflate to satisfy a dependency, but currently the CMake configuration only builds a static version. I was able to fix this by replacing

add_library(GDeflate STATIC ${SOURCES} ${HEADERS} ${PUBLIC_HEADERS})

with

if(BUILD_SHARED_LIBS)
    add_library(GDeflate SHARED ${SOURCES} ${HEADERS} ${PUBLIC_HEADERS})
else()
    add_library(GDeflate STATIC ${SOURCES} ${HEADERS} ${PUBLIC_HEADERS})
endif()

I also had to change this in 3rdparty/libdeflate.cmake, ending up with two shared libraries. It's a small change but I wanted to propose a PR for it in case it would be useful for anyone else? Let me know what you think.

weedleeedle avatar Aug 20 '25 00:08 weedleeedle