mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
Add support for tcc to cmake (#14464)
This PR adds support to the cmake build scripts so to allow building SDL with the Tiny C Compiler (tcc). TinyCC supports the subset of C99 used by SDL and will complete the build once the --version-script linker flag is removed. The changes have been tested with various build configurations, including X11 and Wayland, and using tcc version 0.9.28rc 2025-10-27 mob@f4e01bfc on x86_64 Linux.
This commit is contained in:
@@ -169,12 +169,12 @@ else()
|
||||
endif()
|
||||
|
||||
set(SDL_ASSEMBLY_DEFAULT OFF)
|
||||
if(USE_CLANG OR USE_GCC OR USE_INTELCC OR MSVC_VERSION GREATER 1400)
|
||||
if(USE_CLANG OR USE_GCC OR USE_INTELCC OR USE_TCC OR MSVC_VERSION GREATER 1400)
|
||||
set(SDL_ASSEMBLY_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
set(SDL_GCC_ATOMICS_DEFAULT OFF)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC OR TCC)
|
||||
set(SDL_GCC_ATOMICS_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
@@ -463,7 +463,10 @@ if(SDL_SHARED)
|
||||
if ("c_std_99" IN_LIST CMAKE_C_COMPILE_FEATURES)
|
||||
target_compile_features(SDL3-shared PRIVATE c_std_99)
|
||||
else()
|
||||
message(WARNING "target_compile_features does not know c_std_99 for C compiler")
|
||||
# tcc does support the subset of C99 used by SDL
|
||||
if (NOT USE_TCC)
|
||||
message(WARNING "target_compile_features does not know c_std_99 for C compiler")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -476,7 +479,9 @@ if(SDL_STATIC)
|
||||
if ("c_std_99" IN_LIST CMAKE_C_COMPILE_FEATURES)
|
||||
target_compile_features(SDL3-static PRIVATE c_std_99)
|
||||
else()
|
||||
message(WARNING "target_compile_features does not know c_std_99 for C compiler")
|
||||
if (NOT USE_TCC)
|
||||
message(WARNING "target_compile_features does not know c_std_99 for C compiler")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -510,7 +515,10 @@ check_linker_supports_version_file(HAVE_WL_VERSION_SCRIPT)
|
||||
if(HAVE_WL_VERSION_SCRIPT)
|
||||
sdl_shared_link_options("-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/dynapi/SDL_dynapi.sym")
|
||||
else()
|
||||
if((LINUX AND LIBC_IS_GLIBC) OR ANDROID)
|
||||
# When building with tcc on Linux+glibc or Android, avoid emitting an error
|
||||
# for lack of support of the version-script linker flag: the option will be
|
||||
# silently ignored by the compiler and the build will still succeed.
|
||||
if(((LINUX AND LIBC_IS_GLIBC) OR ANDROID) AND (NOT USE_TCC))
|
||||
message(FATAL_ERROR "Linker does not support '-Wl,--version-script=xxx.sym'. This is required on the current host platform (${SDL_CMAKE_PLATFORM}).")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user