I am working on a CMake project that depends on a couple other projects I
have previously written. I would like to include those other projects using
"ExternalProject_Add", but I am having some issues.

The basic layout of the project is this:

cmake_minimum_required(VERSION 3.14.0)

project(ProjectWithDependencies)

include(ExternalProject)
ExternalProject_Add(Dependency1
    GIT_REPOSITORY <URL to git repo>
)
ExternalProject_Add(Dependency2
    GIT_REPOSITORY <URL to git repo>
)

find_package(Dependency1 Required)
find_package(Dependency2 Required)

# Use targets

I was under the assumption that "ExternalProject_Add" would automatically
build and install the dependencies before getting to the "find_package"
calls (they are CMake projects so the default build and install commands
should be fine) but this doesn't seem to be how it works.

When I get to "find_package" it fails because the dependency hasn't been
installed yet.

How can I ensure that the dependencies are fully compiled and installed
before attempting to find them? (Note: FetchContent doesn't work here
because the two projects "Dependency1" and "Dependency2" have targets with
the same name which causes FetchContent to fail.)

Any help is appreciated.

Thanks,
Tim
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to