In CMake, is it possible to build a dependency imported from a build tree?

I am trying to use CMake feature to export / import targets from a build tree (see this viking page ). I have this library dependency

:

add_library(dependency SHARED dependency.cpp)
export(TARGETS dependency FILE dependency-targets.cmake)

      

And the executable uses this library in another project:

include(${DEPENDENCY_PATH}/dependency-targets.cmake)

add_executable(main-app main.cpp)
target_link_libraries(main-app dependency)

      

This works great. While I understand that this export / import mechanism "only" provides a convenient way to reference external binaries, I am wondering if it can be compiled dependency

when run make

in main-app

? Either use an import mechanism (which I doubt) or use a different one?

+3


source to share


1 answer


You can look into the "superbuild" template and the ExternalProject .



The bottom line is that you've created one "superstroy" project that will only use commands ExternalProject_Add()

; this will create your real project and all its dependencies.

+1


source







All Articles