[CMake] Automatic rebuild of external projects

Evgeny Startsev exbluesbreaker at gmail.com
Mon Jul 2 23:53:30 EDT 2012


I am using test project for understanding external project features. There
are main project with main.cpp source file in <main_dir>:

cmake_minimum_required (VERSION 2.8)

set (PROJECT_NAME main)
project(${PROJECT_NAME})

include(ExternalProject)

ExternalProject_Add(libhello
        URL ${CMAKE_CURRENT_LIST_DIR}/
hello
        PREFIX  ${CMAKE_CURRENT_LIST_DIR}/prefix/hello
        CMAKE_ARGS ${CMARGS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
        )

ExternalProject_Add_Step(libhello forceconfigure
            COMMAND ${CMAKE_COMMAND} -E echo "Force configure of libhello"

            DEPENDEES update
            DEPENDERS configure
            ALWAYS 1)
include_directories(${CMAKE_CURRENT_LIST_DIR}/prefix/hello/include)
if(BUILD_ANDROID)

link_directories(${CMAKE_CURRENT_LIST_DIR}/prefix/hello/libs/${ANDROID_NDK_ABI_NAME})
else()
    link_directories(${CMAKE_CURRENT_LIST_DIR}/prefix/hello/lib)
endif()

add_executable(${PROJECT_NAME} main.cpp)
add_dependencies(${PROJECT_NAME} libhello)

target_link_libraries(${PROJECT_NAME} hello)

in <main_dir>/hello test external lib sources - hello.cpp, another.cpp and
hello.h header:

cmake_minimum_required (VERSION 2.8)

set (PROJECT_NAME hello)
project(${PROJECT_NAME})

set(SOURCES hello.cpp
        another.cpp)

add_library(${PROJECT_NAME} SHARED ${SOURCES})

if(BUILD_ANDROID)
        install(TARGETS ${PROJECT_NAME} DESTINATION
libs/${ANDROID_NDK_ABI_NAME})
else(BUILD_ANDROID)
        install(TARGETS ${PROJECT_NAME} DESTINATION lib)
endif(BUILD_ANDROID)

install(FILES hello.h DESTINATION include)

I run cmake .. in <main_dir>/build and make after that. All builds
correctly. But if i change, for example, <main_dir>/hello/hello.cpp , there
is no rebuild after make.

Cmake version - 2.8.3.
There are some cross-compile Android things, but as i can understand they
has no effect on external project module.

Sorry for poor english.


On Mon, Jul 2, 2012 at 8:54 PM, David Cole <david.cole at kitware.com> wrote:

> That should work already.
>
> If you change the URL of an ExternalProject, it should re-execute the
> download and all subsequent steps.
>
> If you're having problems with that, please post a piece of sample
> CMake code that we can use to try to reproduce your problem.
>
>
> Thanks,
> David
>
>
> On Mon, Jul 2, 2012 at 10:30 AM, Evgeny Startsev
> <exbluesbreaker at gmail.com> wrote:
> > Thank you, for answers! Sorry, i not accurately describe the problem. I
> > interested in support rebuild, then source in External_project URL
> changed.
> > As i understand it correctly this solution for changes in downloaded
> local
> > sources?
> >
> > I found only solution with rsync based download command and force rsync
> step
> > before install for rebuild, if sources from URL changed.
> >
> > On Mon, Jul 2, 2012 at 6:13 PM, David Cole <david.cole at kitware.com>
> wrote:
> >>
> >> It's possible without modifying ExternalProject as well. One technique
> >> we've adopted on several projects looks something like this:
> >>
> >>   # After the ExternalProject_Add call for "myProject"
> >>   ExternalProject_Add_Step(myProject forceconfigure
> >>     COMMAND ${CMAKE_COMMAND} -E echo "Force configure of myProject"
> >>     DEPENDEES update
> >>     DEPENDERS configure
> >>     ALWAYS 1)
> >>
> >> Or, you can use "DEPENDEES configure DEPENDERS build" as a "forcebuild"
> >> step.
> >>
> >> This is such a common request, that we will probably add
> >> ALWAYS_CONFIGURE and ALWAYS_BUILD options to ExternalProject_Add in a
> >> future version.
> >>
> >>
> >> HTH,
> >> David
> >>
> >>
> >> On Mon, Jul 2, 2012 at 7:55 AM, Yuri Timenkov <yuri at timenkov.ru> wrote:
> >> > Hi,
> >> >
> >> > It's possible with some modifications to ExternalProject.cmake:
> >> > http://public.kitware.com/Bug/view.php?id=12322
> >> >
> >> > However it is not encouraged by CMake developers.
> >> >
> >> > On Mon, Jul 2, 2012 at 2:25 PM, Evgeny Startsev
> >> > <exbluesbreaker at gmail.com> wrote:
> >> >> I am using external project module for cmake. Is there any way to
> >> >> rebuild
> >> >> local external project (from local directory), then its sources was
> >> >> changed?
> >> >> I have tried special DOWNLOAD_COMMAND or UPDATE_COMMAND, but this
> >> >> commands
> >> >> called only first time.
> >> >>
> >> >> --
> >> >>
> >> >> Powered by www.kitware.com
> >> >>
> >> >> Visit other Kitware open-source projects at
> >> >> http://www.kitware.com/opensource/opensource.html
> >> >>
> >> >> Please keep messages on-topic and check the CMake FAQ at:
> >> >> http://www.cmake.org/Wiki/CMake_FAQ
> >> >>
> >> >> Follow this link to subscribe/unsubscribe:
> >> >> http://www.cmake.org/mailman/listinfo/cmake
> >> > --
> >> >
> >> > Powered by www.kitware.com
> >> >
> >> > Visit other Kitware open-source projects at
> >> > http://www.kitware.com/opensource/opensource.html
> >> >
> >> > Please keep messages on-topic and check the CMake FAQ at:
> >> > http://www.cmake.org/Wiki/CMake_FAQ
> >> >
> >> > Follow this link to subscribe/unsubscribe:
> >> > http://www.cmake.org/mailman/listinfo/cmake
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120703/645e2ddc/attachment-0001.htm>


More information about the CMake mailing list