summaryrefslogtreecommitdiff
path: root/llvm/CMakeLists.txt
diff options
context:
space:
mode:
authorTobias Hieta <tobias@hieta.se>2023-02-13 08:56:56 +0100
committerTobias Hieta <tobias@hieta.se>2023-02-13 08:57:19 +0100
commitfff762d674c34c56d82f71250df2ac3652992049 (patch)
tree4e4bc90dd82e0293f40f5c570ec8a459dbfba6df /llvm/CMakeLists.txt
parent240c6f2643991b1fe69c03ddcc8be0104e699327 (diff)
downloadllvm-fff762d674c34c56d82f71250df2ac3652992049.tar.gz
Revert "[CMake] Remove custom ccache CMake logic"
This reverts commit 0fad18c44a14b909a1aa47165021273d4c10a665. We need bots to be updated first.
Diffstat (limited to 'llvm/CMakeLists.txt')
-rw-r--r--llvm/CMakeLists.txt38
1 files changed, 34 insertions, 4 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 5aedf28b0435..8e6b738efd7e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -233,8 +233,38 @@ if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
endif()
unset(SHOULD_ENABLE_PROJECT)
-if(DEFINED LLVM_CCACHE_BUILD)
- message(FATAL_ERROR "-DLLVM_CACHE_BUILD=ON is deprecated! Use to the following options instead:\n-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
+# Build llvm with ccache if the package is present
+set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
+if(LLVM_CCACHE_BUILD)
+ find_program(CCACHE_PROGRAM ccache)
+ if(CCACHE_PROGRAM)
+ set(LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache")
+ set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data")
+ set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
+ CACHE STRING "Parameters to pass through to ccache")
+
+ if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
+ if (LLVM_CCACHE_MAXSIZE)
+ set(CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}")
+ endif()
+ if (LLVM_CCACHE_DIR)
+ set(CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}")
+ endif()
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
+ else()
+ if(LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR
+ NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes")
+ message(FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables.")
+ endif()
+ # RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
+ # with cmd.exe and some MSVC tools other than cl.exe
+ set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+ set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
+ endif()
+ else()
+ message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF")
+ endif()
endif()
set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING
@@ -250,8 +280,8 @@ if(LLVM_DEPENDENCY_DEBUGGING)
if(NOT CMAKE_HOST_APPLE)
message(FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts.")
endif()
- if(DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
- message(FATAL_ERROR "Cannot enable dependency debugging while using a compiler launcher like ccache.")
+ if(LLVM_CCACHE_BUILD)
+ message(FATAL_ERROR "Cannot enable dependency debugging while using ccache.")
endif()
endif()