## Summary Improve CMake build system: cleaner separation, compiler caching, and release packaging. ### Toolchain & Build - Clean up `toolchain.cmake` to only contain clang/lld-specific setup (compiler paths, linker selection, llvm tools), allowing other toolchains like GCC to work without it - Add ccache (Linux/macOS) and sccache (Windows) support via toolchain auto-detection - Move project-universal flags (`-ffunction-sections`, `--gc-sections`, `-static-libstdc++`, etc.) to `CMakeLists.txt` so they apply regardless of toolchain - Add `-fno-exceptions` to project compile options; fix `/EHs-c-` for proper MSVC exception disabling - Use MSVC/clang-cl frontend detection instead of `WIN32` for MSVC-specific linker flags - Declare missing options: `CLICE_USE_LIBCXX`, `CLICE_OFFLINE_BUILD`, `CLICE_ENABLE_BENCHMARK`, `CLICE_RELEASE` ### Release Packaging (`cmake/release.cmake`) - Strip debug symbols and produce separate symbol archives (`.debug` / `.dSYM` / `.pdb`) - Windows: copy PDB via `$<TARGET_PDB_FILE:clice>`; macOS: use `copy_directory` for dSYM bundle - Package clice binary + clang resource dir + config into distributable tarball/zip - `cmake/archive.cmake` helper for cross-platform archive creation - Activated via `-DCLICE_RELEASE=ON` (auto-enables LTO) ### Code Cleanup - Replace manual 40+ line source file list with `GLOB_RECURSE` for clice-core - Fix duplicate `include_resolver.cpp` entry - Use build-time `add_custom_target` for clang resource dir copy (instead of configure-time `file(COPY)`) - Gate `scan_benchmark` behind `CLICE_ENABLE_BENCHMARK` option ### CI - Add compiler cache with env var control (`CCACHE_DIR`/`SCCACHE_DIR`) and `actions/cache` for persistence - Proper cache lifecycle: zero-stats before build, show-stats + stop-server after - Stop sccache server before pixi cleanup to fix Windows EBUSY error - Pass `CLICE_ENABLE_BENCHMARK=ON` in benchmark workflow - Platform-specific ccache/sccache dependencies in pixi.toml ## Test plan - [x] Local build (RelWithDebInfo) passes - [x] Local release build (LTO + strip + pack) produces correct archives - [ ] CI: Linux Debug/RelWithDebInfo - [ ] CI: macOS Debug/RelWithDebInfo - [ ] CI: Windows Debug/RelWithDebInfo - [ ] CI: Benchmark (all platforms) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.7 KiB
CMake
50 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.30)
|
|
|
|
set(CMAKE_C_COMPILER clang CACHE STRING "")
|
|
set(CMAKE_CXX_COMPILER clang++ CACHE STRING "")
|
|
|
|
find_program(LLVM_AR_PATH "llvm-ar")
|
|
if(LLVM_AR_PATH)
|
|
set(CMAKE_AR "${LLVM_AR_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_C_COMPILER_AR "${LLVM_AR_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_CXX_COMPILER_AR "${LLVM_AR_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
|
|
find_program(LLVM_RANLIB_PATH "llvm-ranlib")
|
|
if(LLVM_RANLIB_PATH)
|
|
set(CMAKE_RANLIB "${LLVM_RANLIB_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_C_COMPILER_RANLIB "${LLVM_RANLIB_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_CXX_COMPILER_RANLIB "${LLVM_RANLIB_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
|
|
find_program(LLVM_NM_PATH "llvm-nm")
|
|
if(LLVM_NM_PATH)
|
|
set(CMAKE_NM "${LLVM_NM_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
|
|
find_program(LLVM_RC_PATH "llvm-rc")
|
|
if(LLVM_RC_PATH)
|
|
set(CMAKE_RC_COMPILER "${LLVM_RC_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
|
|
if(WIN32)
|
|
find_program(SCCACHE_PATH "sccache")
|
|
if(SCCACHE_PATH)
|
|
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "")
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld-link")
|
|
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld-link")
|
|
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld-link")
|
|
else()
|
|
find_program(CCACHE_PATH "ccache")
|
|
if(CCACHE_PATH)
|
|
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PATH}" CACHE FILEPATH "")
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PATH}" CACHE FILEPATH "")
|
|
endif()
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
endif()
|