## 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>
79 lines
3.1 KiB
CMake
79 lines
3.1 KiB
CMake
include_guard()
|
|
|
|
set(CLICE_PACK_DIR "${PROJECT_BINARY_DIR}/pack")
|
|
set(CLICE_SYMBOL_DIR "${PROJECT_BINARY_DIR}/pack-symbol")
|
|
|
|
if(WIN32)
|
|
set(CLICE_ARCHIVE_EXT ".zip")
|
|
set(CLICE_SYMBOL_NAME "clice.pdb")
|
|
else()
|
|
set(CLICE_ARCHIVE_EXT ".tar.gz")
|
|
if(APPLE)
|
|
set(CLICE_SYMBOL_NAME "clice.dSYM")
|
|
else()
|
|
set(CLICE_SYMBOL_NAME "clice.debug")
|
|
endif()
|
|
endif()
|
|
|
|
if(WIN32)
|
|
add_custom_target(clice-strip ALL
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CLICE_SYMBOL_DIR}"
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
"$<TARGET_PDB_FILE:clice>"
|
|
"${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}"
|
|
DEPENDS clice
|
|
COMMENT "Collecting PDB for clice"
|
|
)
|
|
elseif(APPLE)
|
|
add_custom_target(clice-strip ALL
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CLICE_SYMBOL_DIR}"
|
|
COMMAND dsymutil "$<TARGET_FILE:clice>" -o "${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}"
|
|
COMMAND strip -x "$<TARGET_FILE:clice>"
|
|
DEPENDS clice
|
|
COMMENT "Extracting dSYM and stripping clice"
|
|
)
|
|
else()
|
|
add_custom_target(clice-strip ALL
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CLICE_SYMBOL_DIR}"
|
|
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug "$<TARGET_FILE:clice>" "${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}"
|
|
COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded "$<TARGET_FILE:clice>"
|
|
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink="${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}" "$<TARGET_FILE:clice>"
|
|
DEPENDS clice
|
|
COMMENT "Extracting debug symbols and stripping clice"
|
|
)
|
|
endif()
|
|
|
|
add_custom_target(clice-pack ALL
|
|
DEPENDS clice-strip copy_clang_resource
|
|
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CLICE_PACK_DIR}"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CLICE_PACK_DIR}/clice/bin"
|
|
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:clice>" "${CLICE_PACK_DIR}/clice/bin/"
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory "${LLVM_INSTALL_PATH}/lib/clang" "${CLICE_PACK_DIR}/clice/lib/clang"
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/docs/clice.toml" "${CLICE_PACK_DIR}/clice/"
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-DOUTPUT="${PROJECT_BINARY_DIR}/clice${CLICE_ARCHIVE_EXT}"
|
|
-DWORK_DIR="${CLICE_PACK_DIR}"
|
|
-P "${PROJECT_SOURCE_DIR}/cmake/archive.cmake"
|
|
COMMENT "Packaging clice distribution"
|
|
)
|
|
|
|
if(APPLE)
|
|
set(CLICE_COPY_SYMBOL_CMD ${CMAKE_COMMAND} -E copy_directory
|
|
"${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}" "${CLICE_SYMBOL_DIR}/pack/${CLICE_SYMBOL_NAME}")
|
|
else()
|
|
set(CLICE_COPY_SYMBOL_CMD ${CMAKE_COMMAND} -E copy
|
|
"${CLICE_SYMBOL_DIR}/${CLICE_SYMBOL_NAME}" "${CLICE_SYMBOL_DIR}/pack/")
|
|
endif()
|
|
|
|
add_custom_target(clice-pack-symbol ALL
|
|
DEPENDS clice-strip
|
|
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CLICE_SYMBOL_DIR}/pack"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${CLICE_SYMBOL_DIR}/pack"
|
|
COMMAND ${CLICE_COPY_SYMBOL_CMD}
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-DOUTPUT="${PROJECT_BINARY_DIR}/clice-symbol${CLICE_ARCHIVE_EXT}"
|
|
-DWORK_DIR="${CLICE_SYMBOL_DIR}/pack"
|
|
-P "${PROJECT_SOURCE_DIR}/cmake/archive.cmake"
|
|
COMMENT "Packaging clice debug symbols"
|
|
)
|