diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-01 04:30:34 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-01 04:30:34 +0800 |
| commit | 81cf8b68eca2636574f3d0a9fa1cf0b428c163e9 (patch) | |
| tree | f3a83496e71358123cc5f838269dc134d02b63f6 /backend/CMakeLists.txt | |
| parent | 72af0dedf9e18911da65b9a5c4906689e868d9fc (diff) | |
| download | rcc-project-81cf8b68eca2636574f3d0a9fa1cf0b428c163e9.tar.gz rcc-project-81cf8b68eca2636574f3d0a9fa1cf0b428c163e9.tar.xz | |
[Backend] Establish standalone build infrastructure
Add the thin monorepo CMake entry point and an independently configurable backend project. Enforce the Clang/C++23 toolchain, expose Make/Ninja-neutral tests and developer checks, export an installable RCCBackend package, and introduce the first Support error abstraction.
Diffstat (limited to 'backend/CMakeLists.txt')
| -rw-r--r-- | backend/CMakeLists.txt | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt new file mode 100644 index 0000000..2d5cc82 --- /dev/null +++ b/backend/CMakeLists.txt @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +cmake_minimum_required(VERSION 3.25) + +set(RCC_BACKEND_VERSION 0.1.0) +set(RCC_BACKEND_IS_STANDALONE OFF) +set(RCC_BACKEND_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(RCC_BACKEND_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + project( + RCCBackend + VERSION ${RCC_BACKEND_VERSION} + DESCRIPTION "Independent RCC machine-code backend" + LANGUAGES CXX + ) + set(RCC_BACKEND_IS_STANDALONE ON) + include(CTest) +endif() + +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + message( + FATAL_ERROR + "RCC Backend must be compiled with Clang; found '${CMAKE_CXX_COMPILER_ID}'" + ) +endif() + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message( + FATAL_ERROR + "RCC Backend does not support in-source builds. Configure a separate build directory." + ) +endif() + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) +include(RCCBackendBuild) +include(RCCBackendDeveloperTools) + +option(RCC_BACKEND_BUILD_TESTS "Build RCC Backend tests" "${BUILD_TESTING}") +option(RCC_BACKEND_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) +option(RCC_BACKEND_ENABLE_CLANG_TIDY "Run clang-tidy during each compilation" OFF) + +rcc_backend_initialize_toolchain() + +add_subdirectory(lib) + +if(RCC_BACKEND_BUILD_TESTS) + enable_testing() + add_subdirectory(unittests) +endif() + +rcc_backend_add_developer_targets() + +install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/RCCBackendConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/RCCBackendConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/RCCBackend" +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/RCCBackendConfigVersion.cmake" + VERSION "${RCC_BACKEND_VERSION}" + COMPATIBILITY SameMajorVersion +) + +install( + EXPORT RCCBackendTargets + FILE RCCBackendTargets.cmake + NAMESPACE RCCBackend:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/RCCBackend" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/RCCBackendConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/RCCBackendConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/RCCBackend" +) |
