How do I build specific target with ExternalProject ?
scenario 1: my external project has few targets and I would like to build only on of them
scenario 2: the targets in my external project has EXCLUDE_FROM_ALL so I must specify the required target other wise it will not be built.
By using commands ExternalProject_Add_Step
and ExternalProject_Add_StepTargets
(see Explicit Step Management), you can launch easily any target from your external project.
Thank you,
I have read this documentation but I was not able to use it successfully, probably I’m missing something:
lets say I have ExternalProject named foo and it has a target named bar created with EXCLUDE_FROM_ALL.
can you please provide the instructions for building the bar target ?
Assuming, you have an external project based on CMake
, here is a minimal example (for a more realistic declaration, DEPENDERS
and DEPENDEES
should be considered):
ExternalProject_Add_Step(foo bar
COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target bar
WORKING_DIRECTORY <BINARY_DIR>)
ExternalProject_Add_StepTargets(foo bar)
With these declarations, you can now use target foo-bar
in your own project. Or even build directly this target by using the command cmake --build <my-binary-dir> --target foo-bar