Open Eric-Arz opened 4 days ago
Can you please provide a series of shell commands that reproduces this issue? e.g. the following series works for me on Linux
projectdir=/tmp/new_sdl_project
rm -rf $projectdir
mkdir -p $projectdir
cd $projectdir
cat >CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.20)
project(project C)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
file(WRITE src/main.c
[==[
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
int main(int argc, char *argv[]) {
SDL_Init(0);
SDL_Quit();
return 0;
}
]==]
)
add_subdirectory(lib/sdl EXCLUDE_FROM_ALL)
add_executable(project src/main.c)
target_link_libraries(project PRIVATE SDL3::SDL3)
EOF
git init
git clone https://github.com/libsdl-org/SDL lib/sdl --depth=1
cmake -S . -B build
@madebr your script works because you used git clone to checkout the repo.
SDL seems to search for a .git directory
I downloaded the source code as .zip from https://github.com/libsdl-org/SDL/releases/tag/preview-3.1.3. That doesn't come as a git repo, it's just the source code. When SDL doesn't have it's own .git folder it keeps searching until it finds the one of the outer project and then fails if there is no packed pack-refs
That's why you need to download the SDL3-3.1.3.zip
or SDL3-3.1.3.tar.xz
source archive.
When REVISION.txt
(VERSION.txt
in 3.1.3) is not present, the cmake script assumes it is a git repo.
For current SDL git, you need to define SDL_REVISION
yourself if you don't want to hit git.
Either ways, this causes no build error.
The SDL_REVISION
macro will be defined to "SDL-3.1.3-no-vcs"
, which is kinda correct.
Creating a new blank github repo and trying to vendor SDL3 from a subdirectory doesn't work.
CMake configure fails:
CMake Error: File xxx/.git/packed-refs does not exist. [cmake] CMake Error at build/lib/sdl/CMakeFiles/git-data/grabRef.cmake:29 (configure_file): [cmake] configure_file Problem configuring file [cmake] Call Stack (most recent call first): [cmake] lib/sdl/cmake/GetGitRevisionDescription.cmake:165 (include) [cmake] lib/sdl/cmake/GetGitRevisionDescription.cmake:179 (get_git_head_revision) [cmake] lib/sdl/CMakeLists.txt:3056 (git_describe)
SDL seems to search for a .git directory to fetch some revision stuff. When that .git directory is present but does not contain a packed-refs file (which is the case when creating a blank new repo with no commits) CMake configure fails.
Moving the source code into a subdirectory of a git repo without a packed-refs should probably not make the configuring fail.
git pack-refs --all
Fixed the issue for me.