From: Kefu Chai Date: Mon, 8 Jul 2019 12:06:06 +0000 (+0800) Subject: cmake/modules/Distutils.cmake: avoid rebuilding cython ext X-Git-Tag: v15.1.0~2261^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f17861cdfafc463e512a847620808abc3addd4c1;p=ceph.git cmake/modules/Distutils.cmake: avoid rebuilding cython ext use the combination of add_custom_command() and add_custom_target() to build cython extensions to avoid rebuilding the cython extension everytime we run "make" Signed-off-by: Kefu Chai --- diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index 9a32f16ccaf1..f72b47b4fda7 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -72,7 +72,8 @@ function(distutils_add_cython_module target name src) message(FATAL_ERROR "Unable to tell python extension's suffix: ${error}") endif() set(output_dir "${CYTHON_MODULE_DIR}/lib.${PYTHON${PYTHON_VERSION}_VERSION_MAJOR}") - add_custom_target(${target} ALL + add_custom_command( + OUTPUT ${output_dir}/${name}${ext_suffix} COMMAND env CC="${PY_CC}" @@ -85,9 +86,10 @@ function(distutils_add_cython_module target name src) ${PYTHON${PYTHON_VERSION}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py build --verbose --build-base ${CYTHON_MODULE_DIR} --build-platlib ${output_dir} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - BUILD_BYPRODUCTS ${output_dir}/${ext_suffix} - DEPENDS ${src}) + DEPENDS ${src} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_custom_target(${target} ALL + DEPENDS ${output_dir}/${name}${ext_suffix}) endfunction(distutils_add_cython_module) function(distutils_install_cython_module name)