[CMake] Properly remove raudio.c and rmodels.c if they're disabled modules (#5878)

* only build raudio.c in cmake if it's still enabled

* only compile rmodels if it's supported
This commit is contained in:
Colin James Wood
2026-05-29 17:16:17 +01:00
committed by GitHub
parent e7edb181dc
commit 186d3ce9fb

View File

@@ -30,14 +30,22 @@ set(raylib_public_headers
# Sources to be compiled
set(raylib_sources
raudio.c
rcore.c
rmodels.c
rshapes.c
rtext.c
rtextures.c
)
# Only build raudio if it's enabled
if (NOT DEFINED SUPPORT_MODULE_RAUDIO OR SUPPORT_MODULE_RAUDIO)
list(APPEND raylib_sources raudio.c)
endif()
# Only build rmodels if it's enabled
if (NOT DEFINED SUPPORT_MODULE_RMODELS OR SUPPORT_MODULE_RMODELS)
list(APPEND raylib_sources rmodels.c)
endif()
# <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw
if (NOT ${PLATFORM} MATCHES "Web")
include(GlfwImport)
@@ -48,10 +56,10 @@ endif ()
# Produces a variable LIBS_PRIVATE that will be used later
include(LibraryConfigurations)
if (SUPPORT_MODULE_RAUDIO)
MESSAGE(STATUS "Audio Backend: miniaudio")
else ()
if (DEFINED SUPPORT_MODULE_RAUDIO AND NOT SUPPORT_MODULE_RAUDIO)
MESSAGE(STATUS "Audio Backend: None (-DCUSTOMIZE_BUILD=ON -DSUPPORT_MODULE_RAUDIO=OFF)")
else ()
MESSAGE(STATUS "Audio Backend: miniaudio")
endif ()
add_library(raylib ${raylib_sources} ${raylib_public_headers})