~~`FetchContent_MakeAvailable` broken when `FetchContent_Declare` uses `SOURCE_SUBDIR` (regresion)~~
As of 592085b9 (@craig.scott), FetchContent_MakeAvailable
no longer works if FetchContent_Declare
used a SOURCE_SUBDIR
argument.
Example:
include(FetchContent)
FetchContent_Declare(osg
URL https://github.com/openscenegraph/OpenSceneGraph/archive/ddbed23537ce74c6a3223d59bfb8cf349acfd677.zip
URL_HASH MD5=010db32ce7f0013007e6f904bb888018
SOURCE_DIR fetched/osg
SOURCE_SUBDIR openscenegraph-ddbed23537ce74c6a3223d59bfb8cf349acfd677
)
FetchContent_MakeAvailable(osg)
In CMake 3.16, this works as expected.
In CMake 3.19, add_subdirectory
is not called.
Adding some logging reveals that it's check whether CMakeFile.txt
exist in the wrong path:
build/fetched/osg/openscenegraph-ddbed23537ce74c6a3223d59bfb8cf349acfd677/
Instead of the correct path:
build/fetched/osg/
A copy-pasteable set of commands to reproduce the issue (must be using a recent CMake, e.g. 3.19):
mkdir -p /tmp/cmake-repro-21721
cd /tmp/cmake-repro-21721
cat <<CMAKE > CMakeLists.txt
include(FetchContent)
FetchContent_Declare(osg
URL https://github.com/openscenegraph/OpenSceneGraph/archive/ddbed23537ce74c6a3223d59bfb8cf349acfd677.zip
URL_HASH MD5=010db32ce7f0013007e6f904bb888018
SOURCE_DIR fetched/osg
SOURCE_SUBDIR openscenegraph-ddbed23537ce74c6a3223d59bfb8cf349acfd677
)
FetchContent_MakeAvailable(osg)
CMAKE
cmake -S. -Bbuild
cmake --build build --target osg
Edited by Gleb Mazovetskiy