cmake

CMake: Add an external project but exclude from target "all"


Is it possible to add an external project in CMake but to exclude it from the all build target?

I've looked at the EXCLUDE_FROM_ALL option which is used with ADD_EXECUTABLE but I don't think this works with an external project.

Alternatively I'd be happy if I could change the default target for CMake, but I I think that's hard-coded to all.

For the project that I'm working on I am generating Unix Makefiles with CMake and right now I'm using CMake version 2.8.10.2.


Solution

  • Even if the option EXCLUDE_FROM_ALL is not used upon adding the target by the ExternalProject_add command, the option can be activated retroactively by setting the EXCLUDE_FROM_ALL property of the external project target, i.e.:

    ExternalProject_add(MyExternal
      URL ... )
    set_target_properties(MyExternal PROPERTIES EXCLUDE_FROM_ALL TRUE)