FetchContent_Declare populate fails with option EXCLUDE_FROM_ALL
I am using FetchContent_Declare()
to add some third part libraries and some internal libraries to my project. I don't want them polluting my ALL target or installing all their files when I run install. with add_subdirectory()
I would use EXCLUDE_FROM_ALL
to accomplish this. ExternalProject_Add()
also supports this option, and I was under the impression that FetchContent_Declare()
supported all the same options.
The following pattern end with no file populated and a configure error:
FetchContent_Declare(lib
GIT_REPOSITORY https://github.com/username/lib.git
GIT_SHALLOW TRUE
GIT_TAG origin/optional-positional
EXCLUDE_FROM_ALL TRUE
)
FetchContent_MakeAvailable(lib)
The following works:
FetchContent_Declare(lib
GIT_REPOSITORY https://github.com/username/lib.git
GIT_SHALLOW TRUE
GIT_TAG origin/optional-positional
)
if(NOT lib_POPULATED)
FetchContent_Populate(lib)
add_subdirectory(${lib_SOURCE_DIR} ${lib_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()