cmake: don't use uninitialized SDL_VERSION and use REVISION.txt

Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
This commit is contained in:
Kai Pastor
2024-11-09 18:03:25 +01:00
committed by GitHub
parent 332fd824f0
commit 559223ff9d
+9 -7
View File
@@ -3063,15 +3063,17 @@ endforeach()
# If REVISION.txt exists, then we are building from a SDL release. # If REVISION.txt exists, then we are building from a SDL release.
# SDL_revision.h(.cmake) in source releases have SDL_REVISION baked into them. # SDL_revision.h(.cmake) in source releases have SDL_REVISION baked into them.
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt")
set(SDL_REVISION "" CACHE STRING "Custom SDL revision") file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt" revisions)
if(SDL_REVISION) list(GET revisions 0 revisions_0)
set(SDL_REVISION_CENTER "${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_MICRO}-${SDL_REVISION}") string(STRIP "${revisions_0}" SDL_REVISION)
else() else()
# If SDL_REVISION is not overrided, use git to describe set(SDL_REVISION "" CACHE STRING "Custom SDL revision (only used when REVISION.txt does not exist)")
git_describe(SDL_REVISION_CENTER)
endif() endif()
set(SDL_REVISION "SDL3-${SDL_REVISION_CENTER}") if(NOT SDL_REVISION)
# If SDL_REVISION is not overrided, use git to describe
git_describe(SDL_REVISION_GIT)
set(SDL_REVISION "SDL3-${SDL3_VERSION}-${SDL_REVISION_GIT}")
endif() endif()
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include-revision/SDL3") execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include-revision/SDL3")