3

I am building an external project but want to change some files before calling configure on it. This is my current CMakeLists.txt:

ExternalProject_Add(
    foo
    URL ${PROJECT_SOURCE_DIR}/ext/foo.tar.gz
    BUILD_IN_SOURCE 1
    #Need copyFromOthers to run here, before configure but after untar
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
)

ExternalProject_Add_Step(){
    foo copyFromOthers
    ExternalProject_Get_Property(foo INSTALL_DIR)
    file (COPY <src>/foo_v1.c DESTINATION ${INSTALL_DIR}/foo_v1.c)
    file (COPY <src>/foo_v2.c DESTINATION ${INSTALL_DIR}/foo_v2.c)
##....Continues till foo_v10.c
}

Is there a way to call a custom step after URL command in ExternalProject_Add()?

I tried to add copyFromOthers as a DEPENDEES for ExternalProject_Add() but it kept giving me error about ExternalProject_Get_Property(foo INSTALL_DIR)

1 Answer 1

2

You may use STEP_TARGETS parameter like this

ExternalProject_Add(
    foo
    URL ${PROJECT_SOURCE_DIR}/ext/foo.tar.gz
    BUILD_IN_SOURCE 1
    #Need copyFromOthers to run here, before configure but after untar
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
    STEP_TARGETS download
)

Then you may use target "foo-download" in other ExternalProject_Add commands with DEPENDS parameter:

ExternalProject_Add (<some_target_name>
        <...>
        DEPENDS foo-download
        )

For example you could build external project which depends from other external projects. It is impossible to use dependencies like "foo-download" to build targets, defined with commands like add_executable or add_library, but you could use "ordinal" targets defined by ExternalProject_Add (for example, "foo") in such commands:

add_dependencies (some_target foo)

Also you could use ExternalProject_Add_Step commands to add steps to targets defined with ExternalProject_Add. See ExternalProject for more details

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.