1

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?

Community
  • 1
  • 1
aaragon
  • 2,314
  • 4
  • 26
  • 60
  • 1
    Usually you need to run superbuild to install dependencies, so simply if superbuild failed - you're not building your project. Can you explain how exactly you're using `ExternalProject_Add`? may be with little example. –  Aug 07 '14 at 20:22

1 Answers1

3

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)
ComicSansMS
  • 51,484
  • 14
  • 155
  • 166