build: check CMake variable ENABLE_SHARED

Check for the commonly used CMake variable `ENABLE_SHARED` and set
`VBAM_STATIC` accordingly if it is set.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover
2025-10-04 09:44:48 +00:00
parent 479a7d9097
commit 6e20fdc2e3

View File

@@ -22,8 +22,18 @@ elseif(MINGW OR MSYS)
# Default to static builds on MinGW and all MSYS2 envs.
set(VBAM_STATIC_DEFAULT ON)
endif()
option(VBAM_STATIC "Try to link all libraries statically" ${VBAM_STATIC_DEFAULT})
# This is a commonly used CMake option.
if(DEFINED ENABLE_SHARED)
if(NOT ENABLE_SHARED)
set(VBAM_STATIC ON)
else()
set(VBAM_STATIC OFF)
endif()
endif()
if(VBAM_STATIC)
set(SDL2_STATIC ON)
set(SDL3_STATIC ON)