HI!
I have the following problem: I’m fetching and building a few dependencies that should ship with my applications, primarily header-only and static libraries. I’m using FetchContent for that and it has been working great so far.
However, the new project has the following include in their CMake:
include(dependencies)
and it is used to include cmake/dependencies.cmake
.
Unfortunately, my project uses exactly the same structure, and for some reason, this resolves to a recursive inclusion of my file.
Is there a flag or option that I might have forgotten to set? I haven’t found anything in the documentation on include
function. At the moment, I resolved it by replacing the line in the dependency with
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
but it’s not a long-term solution. Ideally, I’d like to make sure that all CMake configuration in the dependency uses path relative to <build-dir>/_deps/<dependency>-src
.
My fetching script:
###
# AWS SDK - just the S3 part.
###
find_package(AWSSDK COMPONENTS s3 QUIET)
if(NOT AWSSDK_FOUND)
message(STATUS "Downloading and building AWS SDK dependency")
FetchContent_Declare(awsSDK
GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp
)
FetchContent_Populate(awsSDK)
set(BUILD_ONLY "s3" CACHE INTERNAL "")
set(ENABLE_TESTING OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(awsSDK)
add_subdirectory(${awssdk_SOURCE_DIR} ${awssdk_BINARY_DIR})
endif()