FetchContent: Add an optional CMAKE_SUBDIR argument to FetchContent_MakeAvailable
Some projects store the CMakeLists.txt
file in a sub-directory rather than in the root directory. For example, the popular Google's Protobuf library uses a cmake
sub-directory.
This makes it impossible to use FetchContent_MakeAvailable
. It would be very convenient, if we could pass FetchContent_MakeAvailable
an optional argument, let's call it CMAKE_SUBDIR
, that specifies the sub-directory which stores CMakeLists.txt
.
For example, for Protobuf
we would use:
FetchContent_Declare(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf
GIT_TAG v3.10.0
)
FetchContent_MakeAvailable(
protobuf
CMAKE_SUBDIR cmake
)
Edited by Brad King