MantisBT - CMake
View Issue Details
0015914CMakeCMakepublic2016-01-12 16:292016-06-10 14:31
Kim Topley 
Kitware Robot 
normalmajoralways
closedmoved 
MacOS X11.2
CMake 3.4 
 
0015914: Update and subsequent steps of ExternalProject_Add are executed even when there is no change in the downloaded source
I have several CMake files that download and build source from a Git repo or a file on SourceForge, using ExternalProject_Add. Everything works, except that the software is rebuilt every time I run make, even if nothing new was pulled from Git or the downloaded source file did not change. This means that builds that should take a couple of seconds take many minutes.
I use a file that imports the following snippet:

include(ExternalProject)

set(JEMALLOC_PREFIX_DIR ${CMAKE_BINARY_DIR}/Jemalloc)
set(JEMALLOC_SRC_DIR ${JEMALLOC_PREFIX_DIR}/src/Jemalloc)
set(JEMALLOC_INSTALL_DIR ${JEMALLOC_PREFIX_DIR}/install)

ExternalProject_Add(Jemalloc
        GIT_REPOSITORY https://github.com/jemalloc/jemalloc.git [^]
        GIT_TAG master
        PREFIX ${JEMALLOC_PREFIX_DIR}
        CONFIGURE_COMMAND echo Configuring jemalloc
                            && cd ${JEMALLOC_SRC_DIR}
                            && ./autogen.sh && ./configure
--prefix=${JEMALLOC_INSTALL_DIR} --with-jemalloc-prefix=je_ --enable-prof
        BUILD_COMMAND echo Building jemalloc && cd ${JEMALLOC_SRC_DIR}
                            && make install_lib_static install_include
        INSTALL_COMMAND ""
)

# Create libjemalloc and libjemalloc-pic targets to be used as
# dependencies
add_library(libjemalloc STATIC IMPORTED GLOBAL)
add_library(libjemalloc-pic STATIC IMPORTED GLOBAL)

set_target_properties(libjemalloc PROPERTIES
        "IMPORTED_LOCATION" "${JEMALLOC_INSTALL_DIR}/lib/libjemalloc.a")
set_target_properties(libjemalloc-pic PROPERTIES
        "IMPORTED_LOCATION" "${JEMALLOC_INSTALL_DIR}/lib/libjemalloc-pic.a")

# Make the targets depend on the external project download.
add_dependencies(libjemalloc Jemalloc)
add_dependencies(libjemalloc-pic Jemalloc)

# Export the include directory path.
set(JEMALLOC_INCLUDE_DIR ${JEMALLOC_INSTALL_DIR}/include)
The issue seems to be that the -update target in the generated Makefile is always seen to be out of date. It looks like that's because it doesn't do a touch at the end, unlike all of the other similar targets. I added a touch to the generated file and it stopped rebuilding the source:

Jemalloc/src/Jemalloc-stamp/Jemalloc-update: Jemalloc/src/Jemalloc-stamp/Jemalloc-download
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/Users/kim/clionprojects/Hacking2/XYZZY/CMakeFiles --progress-num=$(CMAKE_PROGRESS_5) "Performing update step for 'Jemalloc'"
    cd /Users/kim/clionprojects/Hacking2/XYZZY/Jemalloc/src/Jemalloc && /Applications/CMake.app/Contents/bin/cmake -P /Users/kim/clionprojects/Hacking2/XYZZY/Jemalloc/tmp/Jemalloc-gitupdate.cmake
    echo I ADDED THE NEXT LINE.....
    cd /Users/kim/clionprojects/Hacking2/XYZZY/Jemalloc/src && /Applications/CMake.app/Contents/bin/cmake -E touch /Users/kim/clionprojects/Hacking2/XYZZY/Jemalloc/src/Jemalloc-stamp/Jemalloc-update
No tags attached.
Issue History
2016-01-12 16:29Kim TopleyNew Issue
2016-06-10 14:29Kitware RobotNote Added: 0042911
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042911)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.