mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Reapply "Convert build scripts to CMake (#13427)"
This reverts commit 374bb15db6.
This commit is contained in:
42
cmake/tools/SetupCcache.cmake
Normal file
42
cmake/tools/SetupCcache.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
include(Macros)
|
||||
|
||||
optionx(ENABLE_CCACHE BOOL "If ccache should be enabled" DEFAULT ON)
|
||||
|
||||
if(NOT ENABLE_CCACHE OR CACHE_STRATEGY STREQUAL "none")
|
||||
setenv(CCACHE_DISABLE 1)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CCACHE_PROGRAM
|
||||
COMMAND
|
||||
ccache
|
||||
REQUIRED
|
||||
ON
|
||||
)
|
||||
|
||||
set(CCACHE_ARGS CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
|
||||
foreach(arg ${CCACHE_ARGS})
|
||||
setx(${arg} ${CCACHE_PROGRAM})
|
||||
list(APPEND CMAKE_ARGS -D${arg}=${${arg}})
|
||||
endforeach()
|
||||
|
||||
setenv(CCACHE_DIR ${CACHE_PATH}/ccache)
|
||||
setenv(CCACHE_BASEDIR ${CWD})
|
||||
setenv(CCACHE_NOHASHDIR 1)
|
||||
|
||||
if(CACHE_STRATEGY STREQUAL "read-only")
|
||||
setenv(CCACHE_READONLY 1)
|
||||
elseif(CACHE_STRATEGY STREQUAL "write-only")
|
||||
setenv(CCACHE_RECACHE 1)
|
||||
endif()
|
||||
|
||||
setenv(CCACHE_FILECLONE 1)
|
||||
setenv(CCACHE_STATSLOG ${BUILD_PATH}/ccache.log)
|
||||
|
||||
if(CI)
|
||||
setenv(CCACHE_SLOPPINESS "pch_defines,time_macros,locale,clang_index_store,gcno_cwd,include_file_ctime,include_file_mtime")
|
||||
else()
|
||||
setenv(CCACHE_SLOPPINESS "pch_defines,time_macros,locale,random_seed,clang_index_store,gcno_cwd")
|
||||
endif()
|
||||
Reference in New Issue
Block a user