allo
allo

Reputation: 4236

cmake does not run the StepTargets of an external project

I am using cmake with some projects added via ExternalProject_add and when i add a target with

ExternalProject_Add_StepTargets(SubProject doc)
ExternalProject_Add_Step(SubProject doc)

I get a new target SubProject-doc, but when I build it, the doc target of SubProject is not executed.

The external projects are added like this:

ExternalProject_add(subproject
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/subproject
    BINARY_DIR ${subproject_DIR}
    CMAKE_ARGS ${CMAKE_ARGS}
    INSTALL_DIR ${CMAKE_BINARY_DIR}/install
    DEPENDS subproject2
)

Upvotes: 0

Views: 1497

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66061

There is no implicit relation between steps of ExternalProject and targets of the subproject it represents. CMake only knows how to generate some predefined steps, like "download", "configure", "build". For create other steps you need to explicitely specify commands for them:

ExternalProject_Add_Step(Subproject doc
    # Equivalent to 'make doc' but in platform-independent manner
    COMMAND ${CMAKE_COMMAND} --build . --target doc
    # Use automatically-replaced token for refer to binary dir
    WORKING_DIRECTORY <BINARY_DIR>
    # When requested, step is always run.
    # (It is 'make doc' behavior who should care to not generate 
    # documentation if it has already been generated.)
    ALWAYS 1
    # This step is not a part of normal build of external project.
    EXCLUDE_FROM_MAIN 1
    # However, this step requires some other steps to be performed
    DEPENDEES configure
    )

After that you may create a target in the main project, which will perform given step:

ExternalProject_Add_StepTargets(SubProject doc)

See more in ExternalProject module's documentation.

Upvotes: 2

Related Questions