[CMake] CMake External Project always being rebuilt

Kim Topley kim.topley at streamingedge.com
Fri Jan 8 14:31:36 EST 2016


I am using an external project to download and build a third-party library
from GitHub. This works fine, except that every time, I run make, the
configure and build parts of the external project run, even though nothing
has changed. Here is the relevant CMake code:

=================================
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)

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


When I run this for the first time, the library code is pulled from Git and
built. The second time around, I see this:

[ 13%] Performing update step for 'Jemalloc'
Current branch master is up to date.
[ 18%] Performing configure step for 'Jemalloc'
Configuring jemalloc
autoconf
./configure --enable-autogen

I really don't want anything to be rebuilt if there are no changes in the
source repository. What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160108/f0b330e7/attachment.html>


More information about the CMake mailing list