mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-26 10:06:42 +08:00
cmake: compile SDL_uclibc separately for shared and static SDL3, ensuring fPIC for shared SDL3
(cherry picked from commit 6f19fecba3)
This commit is contained in:
+15
-12
@@ -1294,22 +1294,25 @@ sdl_glob_sources(
|
|||||||
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/*.h"
|
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/*.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build uclibc as a static library such that non-used symbols don't end up in the SDL3 shared library.
|
|
||||||
file(GLOB SDL_UCLIBC_SOURCES "${SDL3_SOURCE_DIR}/src/libm/*.c")
|
file(GLOB SDL_UCLIBC_SOURCES "${SDL3_SOURCE_DIR}/src/libm/*.c")
|
||||||
add_library(SDL_uclibc STATIC "${SDL_UCLIBC_SOURCES}")
|
|
||||||
target_compile_definitions(SDL_uclibc PRIVATE USING_GENERATED_CONFIG_H)
|
|
||||||
target_include_directories(SDL_uclibc PRIVATE "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config")
|
|
||||||
target_include_directories(SDL_uclibc PRIVATE "${SDL3_SOURCE_DIR}/src")
|
|
||||||
target_include_directories(SDL_uclibc PRIVATE "${SDL3_SOURCE_DIR}/include")
|
|
||||||
SDL_AddCommonCompilerFlags(SDL_uclibc)
|
|
||||||
target_compile_definitions(SDL_uclibc PRIVATE "$<$<CONFIG:Debug>:DEBUG>")
|
|
||||||
sdl_sources(STATIC "$<TARGET_OBJECTS:SDL_uclibc>")
|
|
||||||
set_property(TARGET SDL_uclibc PROPERTY UNITY_BUILD OFF)
|
|
||||||
if(TARGET SDL3-shared)
|
if(TARGET SDL3-shared)
|
||||||
|
# Build uclibc as a static library such that non-used symbols don't end up in the SDL3 shared library.
|
||||||
|
add_library(SDL_uclibc STATIC ${SDL_UCLIBC_SOURCES})
|
||||||
|
set_property(TARGET SDL_uclibc PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
target_compile_definitions(SDL_uclibc PRIVATE USING_GENERATED_CONFIG_H)
|
||||||
|
target_include_directories(SDL_uclibc PRIVATE "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/build_config")
|
||||||
|
target_include_directories(SDL_uclibc PRIVATE "${SDL3_SOURCE_DIR}/src")
|
||||||
|
target_include_directories(SDL_uclibc PRIVATE "${SDL3_SOURCE_DIR}/include")
|
||||||
|
SDL_AddCommonCompilerFlags(SDL_uclibc)
|
||||||
|
target_compile_definitions(SDL_uclibc PRIVATE "$<$<CONFIG:Debug>:DEBUG>")
|
||||||
|
set_property(TARGET SDL_uclibc PROPERTY UNITY_BUILD OFF)
|
||||||
target_link_libraries(SDL3-shared PRIVATE SDL_uclibc)
|
target_link_libraries(SDL3-shared PRIVATE SDL_uclibc)
|
||||||
|
if(HAVE_GCC_FVISIBILITY)
|
||||||
|
set_property(TARGET SDL_uclibc PROPERTY C_VISIBILITY_PRESET "hidden")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(HAVE_GCC_FVISIBILITY)
|
if(TARGET SDL3-static)
|
||||||
set_property(TARGET SDL_uclibc PROPERTY C_VISIBILITY_PRESET "hidden")
|
target_sources(SDL3-static PRIVATE ${SDL_UCLIBC_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable/disable various subsystems of the SDL library
|
# Enable/disable various subsystems of the SDL library
|
||||||
|
|||||||
Reference in New Issue
Block a user