I am receiving this error after changing SOURCE_DIR
in FetchContent_Declare
:
error: pathspec did not match any file(s) known to git
a minimal example:
cmake_minimum_required( VERSION 3.16 )
project(MyProj VERSION 0 LANGUAGES NONE)
include(FetchContent)
FetchContent_Declare(myscript
GIT_REPOSITORY git@gist.github.com:76c2097a0b6a74c870f6b50c2cf1f470.git
SOURCE_DIR foo)
# FetchContent_GetProperties(myscript)
# if( NOT cmakebuild_POPULATED )
# FetchContent_Populate(myscript)
# endif()
FetchContent_MakeAvailable(myscript)
to trigger the error the project must be build once, then change SOURCE_DIR
and and build again.
I used a random git repository only for demonstration. The problem shows both for MakeAvailable
and Populate
. My CMake version is 3.19.
To get around this error i deleted <build_dir>/_deps/xxx-subbuild/xxx-populate-prefix
directory. Is there a better way?