]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake/modules/Distutils.cmake: avoid rebuilding cython ext
authorKefu Chai <kchai@redhat.com>
Mon, 8 Jul 2019 12:06:06 +0000 (20:06 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 8 Jul 2019 12:30:14 +0000 (20:30 +0800)
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 <kchai@redhat.com>
cmake/modules/Distutils.cmake

index 9a32f16ccaf164034132cc1b0e342385da0e5fcc..f72b47b4fda7da779af22de6b70a37e658bf2b17 100644 (file)
@@ -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)