diff --git a/CMakeLists.txt b/CMakeLists.txt index 2612854ffdce..a510c843181f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ option(ENABLE_TESTCOVERAGE "Enable compilation with test coverage metric output" option(USE_INT64_TENSOR_SIZE "Use int64_t to represent the total number of elements in a tensor" OFF) option(BUILD_CYTHON_MODULES "Build cython modules." OFF) cmake_dependent_option(USE_SPLIT_ARCH_DLL "Build a separate DLL for each Cuda arch (Windows only)." ON "MSVC" OFF) +cmake_dependent_option(USE_CCACHE "Attempt using CCache to wrap the compilation" ON "UNIX" OFF) message(STATUS "CMAKE_CROSSCOMPILING ${CMAKE_CROSSCOMPILING}") @@ -100,6 +101,17 @@ if(UNIX) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +if(USE_CCACHE) + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + else() + message(STATUS "Could not find CCache. Consider installing CCache to speed up compilation.") + endif() +endif() + if(MSVC) set(SYSTEM_ARCHITECTURE x86_64) enable_language(ASM_MASM) diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 7fd24575a462..60ab617c88ae 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -279,8 +279,6 @@ build_armv6() { build_ccache_wrappers cmake \ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_OPENCV=OFF \ -DUSE_OPENMP=OFF \ @@ -311,8 +309,6 @@ build_armv7() { cmake \ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ -DCMAKE_CROSSCOMPILING=ON \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_OPENCV=OFF \ -DUSE_OPENMP=ON \ @@ -332,8 +328,6 @@ build_armv7() { build_armv8() { build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF\ -DSUPPORT_F16C=OFF\ -DUSE_OPENCV=OFF\ @@ -358,8 +352,6 @@ build_android_armv7() { build_ccache_wrappers cmake \ -DANDROID=ON\ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF\ -DUSE_SSE=OFF\ -DSUPPORT_F16C=OFF\ @@ -412,8 +404,6 @@ build_amzn_linux_cpu() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF\ -DUSE_OPENCV=ON\ -DUSE_OPENMP=ON\ @@ -505,8 +495,6 @@ build_ubuntu_cpu_cmake_debug() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_TVM_OP=ON \ -DPython3_EXECUTABLE=/usr/bin/python3 \ @@ -528,8 +516,6 @@ build_ubuntu_cpu_cmake_no_tvm_op() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_TVM_OP=OFF \ -DPython3_EXECUTABLE=/usr/bin/python3 \ @@ -554,8 +540,6 @@ build_ubuntu_cpu_cmake_asan() { export CC=gcc-8 build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLDNN=OFF \ @@ -618,8 +602,6 @@ build_ubuntu_cpu_clang_tidy() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDA=OFF \ -DUSE_MKLDNN=OFF \ -DUSE_MKL_IF_AVAILABLE=OFF \ @@ -714,8 +696,6 @@ build_ubuntu_gpu_tensorrt() { mkdir -p build cd build cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_FLAGS=-I/usr/include/python${PYVER}\ -DBUILD_SHARED_LIBS=ON ..\ -G Ninja @@ -730,10 +710,7 @@ build_ubuntu_gpu_tensorrt() { cd 3rdparty/onnx-tensorrt/ mkdir -p build cd build - cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - .. + cmake .. make -j$(nproc) export LIBRARY_PATH=`pwd`:$LIBRARY_PATH popd @@ -745,8 +722,6 @@ build_ubuntu_gpu_tensorrt() { cd /work/build cmake -DUSE_CUDA=1 \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DUSE_CUDNN=1 \ -DUSE_OPENCV=1 \ -DUSE_TENSORRT=1 \ @@ -861,9 +836,6 @@ build_ubuntu_gpu_cmake_mkldnn() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ -DUSE_SIGNAL_HANDLER=ON \ -DUSE_CUDA=1 \ -DUSE_CUDNN=1 \ @@ -883,9 +855,6 @@ build_ubuntu_gpu_cmake() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ -DUSE_SIGNAL_HANDLER=ON \ -DUSE_CUDA=ON \ -DUSE_CUDNN=ON \ @@ -909,9 +878,6 @@ build_ubuntu_gpu_cmake_no_tvm_op() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ -DUSE_SIGNAL_HANDLER=ON \ -DUSE_CUDA=ON \ -DUSE_CUDNN=ON \ @@ -935,9 +901,6 @@ build_ubuntu_cpu_large_tensor() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ -DUSE_SIGNAL_HANDLER=ON \ -DUSE_CUDA=OFF \ -DUSE_CUDNN=OFF \ @@ -955,9 +918,6 @@ build_ubuntu_gpu_large_tensor() { cd /work/build build_ccache_wrappers cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ -DUSE_SIGNAL_HANDLER=ON \ -DUSE_CUDA=ON \ -DUSE_CUDNN=ON \ diff --git a/docs/static_site/src/pages/get_started/ubuntu_setup.md b/docs/static_site/src/pages/get_started/ubuntu_setup.md index 89601d2a517d..91e00504f3e6 100644 --- a/docs/static_site/src/pages/get_started/ubuntu_setup.md +++ b/docs/static_site/src/pages/get_started/ubuntu_setup.md @@ -120,9 +120,6 @@ mkdir -p build && cd build cmake -GNinja \ -DUSE_CUDA=OFF \ -DUSE_MKL_IF_AVAILABLE=OFF \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=Release \ .. ninja @@ -140,9 +137,6 @@ mkdir -p build && cd build cmake -GNinja \ -DUSE_CUDA=OFF \ -DUSE_MKL_IF_AVAILABLE=ON \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=Release \ .. ninja @@ -157,9 +151,6 @@ mkdir -p build && cd build cmake -GNinja \ -DUSE_CUDA=ON \ -DUSE_MKL_IF_AVAILABLE=OFF \ - -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=Release \ .. ninja