diff --git a/cmake/nccl.cmake b/cmake/nccl.cmake index cc1585b0fc..82cf3b4122 100644 --- a/cmake/nccl.cmake +++ b/cmake/nccl.cmake @@ -61,6 +61,10 @@ else() message(STATUS "Building NCCL from source") list(TRANSFORM CUDA_GENCODE PREPEND "NVCC_GENCODE=" OUTPUT_VARIABLE NCCL_BUILD_NVCC_GENCODE) + set(NCCL_BUILD_CMD make src.build "${NCCL_BUILD_NVCC_GENCODE}" "CUDA_HOME=${CUDA_TOOLKIT_ROOT_DIR}" "BUILDDIR=${CMAKE_BINARY_DIR}/deps/${NCCL_NAME}") + if(DEFINED ENV{MAKEFLAGS}) + set(NCCL_BUILD_CMD ${CMAKE_COMMAND} -E env MAKEFLAGS=$ENV{MAKEFLAGS} ${NCCL_BUILD_CMD}) + endif() ExternalProject_Add(${NCCL_NAME} SOURCE_DIR ${PROJECT_SOURCE_DIR}/deps/${NCCL_NAME} PREFIX ${CMAKE_BINARY_DIR}/deps/${NCCL_NAME} @@ -68,7 +72,7 @@ else() BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/deps/${NCCL_NAME}/lib/libnccl${LIBEXT} INSTALL_COMMAND "" CONFIGURE_COMMAND "" - BUILD_COMMAND make src.build "${NCCL_BUILD_NVCC_GENCODE}" "CUDA_HOME=${CUDA_TOOLKIT_ROOT_DIR}" "BUILDDIR=${CMAKE_BINARY_DIR}/deps/${NCCL_NAME}" + BUILD_COMMAND ${NCCL_BUILD_CMD} BUILD_IN_SOURCE 1 )