Is there a way to tell the CMake system that I don't want further compilation until the dependencies (external projects) are built and installed correctly?
Say a project depends on other libraries, which may or may not be present in the system. In case they're not, I use the ExternalProject_Add
to download and install it. Yet, even though the configure part goes fine, building the external project doesn't happen until you type make
. Now it doesn't make sense to compile the code if building the dependencies failed. I found in CMake ExternalProject_Add() and FindPackage() that maybe adding some dependencies would help, but that answer defines the dependency at configuration time, so it's not relevant to my situation.
Any ideas?
ExternalProject_Add
will generate a custom target for building the dependency. If you don't want a target to be built in case building the dependency failed, add a dependency from that target to the external project's target.
ExternalProject_Add(my_external_lib [...])
add_executable(my_program [...])
add_dependencies(my_program my_external_lib)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.