The following issue has been SUBMITTED. 
====================================================================== 
https://cmake.org/Bug/view.php?id=15914 
====================================================================== 
Reported By:                Kim Topley
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15914
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2016-01-12 16:29 EST
Last Modified:              2016-01-12 16:29 EST
====================================================================== 
Summary:                    Update and subsequent steps of ExternalProject_Add
are executed even when there is no change in the downloaded source
Description: 
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.

Steps to Reproduce: 
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)


Additional Information: 
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

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-01-12 16:29 Kim Topley     New Issue                                    
======================================================================

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to