Repository: mesos Updated Branches: refs/heads/master 1e30b3e35 -> 2246b8ab4
Made 3rdparty jemalloc only build when enabled. When declaring a library with `add_library()`, the library is added to the list of default targets, such that `make all` (and equivalents) will build it, even if nothing depends on it. This meant that on Windows, `cmake --build .` tried to run the `configure` script of jemalloc, which obviously fails. By wrapping the 3rdparty import with `ENABLE_JEMALLOC_ALLOCATOR` we fix this bug on Windows, and avoid unnecessary build steps on Linux. We do not use `EXCLUDE_FROM_ALL` so that we're consistent with the rest of the CMake build (e.g. `libevent` is also wrapped with its feature flag), and with Autotools (e.g. if the feature flag is not set, it is not added at all). Review: https://reviews.apache.org/r/66711 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2246b8ab Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2246b8ab Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2246b8ab Branch: refs/heads/master Commit: 2246b8ab436acf24b380bea3c3d8ebd568754640 Parents: 1e30b3e Author: Andrew Schwartzmeyer <[email protected]> Authored: Wed Apr 18 19:06:01 2018 -0700 Committer: Andrew Schwartzmeyer <[email protected]> Committed: Thu Apr 19 12:51:45 2018 -0700 ---------------------------------------------------------------------- 3rdparty/CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2246b8ab/3rdparty/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 70affa3..e6bb407 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -988,25 +988,27 @@ ExternalProject_Add( # Jemalloc: General-purpose malloc implementation. # http://jemalloc.net ################################################## -EXTERNAL(jemalloc ${JEMALLOC_VERSION} ${CMAKE_CURRENT_BINARY_DIR}) -add_library(jemalloc STATIC IMPORTED GLOBAL) -add_dependencies(jemalloc ${JEMALLOC_TARGET}) +if (ENABLE_JEMALLOC_ALLOCATOR) + EXTERNAL(jemalloc ${JEMALLOC_VERSION} ${CMAKE_CURRENT_BINARY_DIR}) + add_library(jemalloc STATIC IMPORTED GLOBAL) + add_dependencies(jemalloc ${JEMALLOC_TARGET}) -set_target_properties( - jemalloc PROPERTIES - IMPORTED_LOCATION ${JEMALLOC_ROOT}-build/lib/libjemalloc_pic${CMAKE_STATIC_LIBRARY_SUFFIX}) + set_target_properties( + jemalloc PROPERTIES + IMPORTED_LOCATION ${JEMALLOC_ROOT}-build/lib/libjemalloc_pic${CMAKE_STATIC_LIBRARY_SUFFIX}) -set( - JEMALLOC_CONFIGURE_COMMAND - ${JEMALLOC_ROOT}/configure --enable-stats --enable-prof --with-malloc-conf=prof:true,prof_active:false) + set( + JEMALLOC_CONFIGURE_COMMAND + ${JEMALLOC_ROOT}/configure --enable-stats --enable-prof --with-malloc-conf=prof:true,prof_active:false) -ExternalProject_Add( - ${JEMALLOC_TARGET} - PREFIX ${JEMALLOC_CMAKE_ROOT} - CONFIGURE_COMMAND ${JEMALLOC_CONFIGURE_COMMAND} - INSTALL_COMMAND ${CMAKE_NOOP} - URL ${JEMALLOC_URL} - URL_HASH ${JEMALLOC_HASH}) + ExternalProject_Add( + ${JEMALLOC_TARGET} + PREFIX ${JEMALLOC_CMAKE_ROOT} + CONFIGURE_COMMAND ${JEMALLOC_CONFIGURE_COMMAND} + INSTALL_COMMAND ${CMAKE_NOOP} + URL ${JEMALLOC_URL} + URL_HASH ${JEMALLOC_HASH}) +endif () # Apache ZooKeeper: C Client Library to ZooKeeper.
