From a6c2c1edd7af6794424172465e3f71496477a707 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 09:13:21 +0100 Subject: [PATCH 1/6] Add infrastructure for C++26 compiler support (GCC16) --- .github/workflows/cmake.yml | 20 +++- CMakeLists.txt | 28 ++++++ cmake/xyz_add_test.cmake | 2 +- docker/Dockerfile | 27 ++++-- scripts/agentic-sandbox.py | 187 +++++++++++++++++++++--------------- scripts/cmake.py | 19 +++- scripts/docker-shell.sh | 10 ++ 7 files changed, 200 insertions(+), 93 deletions(-) create mode 100755 scripts/docker-shell.sh diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a35c7b7..5e6bdea 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -211,6 +211,18 @@ jobs: std: 20, }, } + - { + name: "Ubuntu GCC-16 (C++26 Reflection)", + os: ubuntu-24.04, + compiler: + { + type: GCC16, + version: 16, + cc: "gcc-16", + cxx: "g++-16", + std: 26, + }, + } steps: - uses: actions/checkout@v4 - uses: lukka/get-cmake@v4.4.2 @@ -231,9 +243,15 @@ jobs: with: version: ${{ matrix.settings.compiler.version }} platform: x64 + - name: Install GCC 16 from ubuntu-toolchain-r PPA + if: matrix.settings.compiler.type == 'GCC16' + run: | + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install -y --no-install-recommends g++-16 gcc-16 - name: Install uv uses: astral-sh/setup-uv@v5 - name: Set up Python run: uv sync - name: Run CMake - run: ./scripts/cmake.sh --${{ matrix.configuration == 'Debug' && 'debug' || 'release' }} + run: ./scripts/cmake.sh --${{ matrix.configuration == 'Debug' && 'debug' || 'release' }} ${{ matrix.settings.compiler.type == 'GCC16' && '--reflection' || '' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 459b0b1..d2e73b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,34 @@ option(ENABLE_UBSAN "Enable Undefined Behaviour Sanitizer" OFF) option(ENABLE_TSAN "Enable Thread Sanitizer" OFF) option(ENABLE_MSAN "Enable Memory Sanitizer" OFF) +option( + XYZ_PROTOCOL_BUILD_REFLECTION + "Also build and test tutorials/reflection.cc, which requires a compiler \ +with C++26 P2996 reflection support (GCC 16+ with -freflection)." + OFF) + +if(XYZ_PROTOCOL_BUILD_REFLECTION) + include(CheckCXXSourceCompiles) + set(CMAKE_REQUIRED_FLAGS "-std=c++26 -freflection") + check_cxx_source_compiles( + " + #include + constexpr std::meta::info reflection_of_int = ^^int; + int main() {} + " + XYZ_PROTOCOL_REFLECTION_SUPPORTED) + unset(CMAKE_REQUIRED_FLAGS) + if(NOT XYZ_PROTOCOL_REFLECTION_SUPPORTED) + message( + FATAL_ERROR + "XYZ_PROTOCOL_BUILD_REFLECTION is ON but the compiler " + "(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}) does not " + "accept '-std=c++26 -freflection'. C++26 reflection currently " + "requires GCC 16 or newer; configure with e.g. " + "CXX=g++-16 CC=gcc-16 and a separate build directory (-B).") + endif() +endif() + if(ENABLE_ASAN OR ENABLE_UBSAN OR ENABLE_TSAN OR ENABLE_MSAN) set(ENABLE_SANITIZERS ON) endif() diff --git a/cmake/xyz_add_test.cmake b/cmake/xyz_add_test.cmake index 00cf265..ff9f4a6 100644 --- a/cmake/xyz_add_test.cmake +++ b/cmake/xyz_add_test.cmake @@ -50,7 +50,7 @@ function(xyz_add_test) if(NOT XYZ_VERSION) set(XYZ_VERSION 20) else() - set(VALID_TARGET_VERSIONS 11 14 17 20 23) + set(VALID_TARGET_VERSIONS 11 14 17 20 23 26) list(FIND VALID_TARGET_VERSIONS ${XYZ_VERSION} index) if(index EQUAL -1) message(FATAL_ERROR "TYPE must be one of <${VALID_TARGET_VERSIONS}>") diff --git a/docker/Dockerfile b/docker/Dockerfile index 4966bbb..ed90b04 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ +# syntax=docker/dockerfile:1 FROM ubuntu:24.04 # Install base tools and C++ development tools. RUN apt-get update && apt-get install -y --no-install-recommends \ - cmake \ curl \ g++ \ gdb \ @@ -18,13 +18,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ssh \ unzip \ wget \ -&& rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* # Install newer CMake from kitware. RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \ -&& apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ noble main' \ -&& apt-get update && apt-get install -y --no-install-recommends cmake \ -&& rm -rf /var/lib/apt/lists/* + && apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ noble main' \ + && apt-get update && apt-get install -y --no-install-recommends cmake \ + && rm -rf /var/lib/apt/lists/* + +# Install GCC 16 (experimental C++26 reflection support via -std=c++26 +# -freflection, see https://gcc.gnu.org/gcc-16/changes.html) from the Ubuntu +# Toolchain Test PPA, since Ubuntu 24.04's own repos only go up to GCC 14. +RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test \ + && apt-get update && apt-get install -y --no-install-recommends g++-16 gcc-16 \ + && rm -rf /var/lib/apt/lists/* # Install bazelisk. RUN ARCH=$(dpkg --print-architecture) && \ @@ -36,11 +43,11 @@ RUN ARCH=$(dpkg --print-architecture) && \ # https://github.com/cli/cli/blob/trunk/docs/install_linux.md (not reliably # available via Ubuntu 24.04's default repos). RUN mkdir -p -m 755 /etc/apt/keyrings \ -&& wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \ -&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ -&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list >/dev/null \ -&& apt-get update && apt-get install -y --no-install-recommends gh \ -&& rm -rf /var/lib/apt/lists/* + && wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \ + && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list >/dev/null \ + && apt-get update && apt-get install -y --no-install-recommends gh \ + && rm -rf /var/lib/apt/lists/* # Install jj (Jujutsu VCS) from its GitHub release binary. The jujutsu apt # package isn't built for Ubuntu 24.04 (noble) or Debian stable; it only diff --git a/scripts/agentic-sandbox.py b/scripts/agentic-sandbox.py index 3a41bdf..5692bed 100644 --- a/scripts/agentic-sandbox.py +++ b/scripts/agentic-sandbox.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Script to run an AI agent in a Docker sandbox. +Script to run an AI agent, or a plain shell, in a Docker sandbox. Supported agents: Gemini CLI, Claude Code, Antigravity CLI. """ @@ -9,14 +9,30 @@ import os import subprocess import sys +from typing import TypedDict +IMAGE_NAME = "cc-protocol-sandbox" + + +class AgentCli(TypedDict): + """npm package and launch command for an agent CLI.""" + + npm_package: str | None + cmd: str -def _seed_config_file(path: str, content: bytes) -> None: - """ - Create path with content and mode 0o600. - Skips silently if it already exists. - """ +AGENT_CLIS: dict[str, AgentCli] = { + "gemini": {"npm_package": "@google/gemini-cli", "cmd": "gemini"}, + "claude": { + "npm_package": "@anthropic-ai/claude-code", + "cmd": "claude --dangerously-skip-permissions", + }, + "antigravity": {"npm_package": None, "cmd": "agy"}, +} + + +def _seed_config_file(path: str, content: bytes) -> None: + """Create path with content and mode 0o600, skipping silently if it exists.""" try: fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600) except FileExistsError: @@ -27,21 +43,78 @@ def _seed_config_file(path: str, content: bytes) -> None: os.close(fd) +def _update_command(agent: str, agent_cmd: str, npm_package: str | None) -> str: + """Build the shell command that updates an agent CLI before running it.""" + if agent == "antigravity": + return ( + "curl -fsSL https://antigravity.google/cli/install.sh | bash && " + f"{agent_cmd}" + ) + return ( + "export NPM_CONFIG_PREFIX=~/.npm-global && " + "export PATH=~/.npm-global/bin:$PATH && " + f"npm install -g {npm_package}@latest && {agent_cmd}" + ) + + +def _agent_mount_args(agent: str | None) -> list[str]: + """Seed and mount host config so an agent CLI keeps its auth state.""" + # Use os.open with restrictive permissions in _seed_config_file to avoid + # exposing credentials to other local users on multi-user systems. + if agent in ("gemini", "antigravity"): + gemini_config_dir = os.path.expanduser("~/.gemini") + os.makedirs(gemini_config_dir, mode=0o700, exist_ok=True) + _seed_config_file( + os.path.join(gemini_config_dir, "trustedFolders.json"), + b'{"/workspace": "TRUST_FOLDER"}', + ) + _seed_config_file( + os.path.join(gemini_config_dir, "settings.json"), + b'{"selectedAuthType": "oauth-personal"}', + ) + return ["-v", f"{gemini_config_dir}:/home/vscode/.gemini"] + + if agent == "claude": + host_claude_dir = os.path.expanduser("~/.claude") + host_claude_json = os.path.expanduser("~/.claude.json") + os.makedirs(host_claude_dir, mode=0o700, exist_ok=True) + # Ensure the file exists on the host so Docker doesn't create it as a + # directory. + if os.path.exists(host_claude_json): + if not os.path.isfile(host_claude_json): + sys.exit( + f"Expected {host_claude_json} to be a regular file, but found " + "a different filesystem object. Remove or rename it and rerun." + ) + else: + _seed_config_file(host_claude_json, b"") + return [ + "-v", + f"{host_claude_dir}:/home/vscode/.claude", + "-v", + f"{host_claude_json}:/home/vscode/.claude.json", + ] + + return [] + + def main() -> None: """Provide the main entry point for the agentic sandbox script.""" parser = argparse.ArgumentParser( - description="Run an AI agent (gemini, claude, or antigravity)" - " in a Docker sandbox." + description="Run an AI agent (gemini, claude, or antigravity) in a Docker " + "sandbox, or a plain shell if no agent is given." ) parser.add_argument( "agent", - choices=["gemini", "claude", "antigravity"], - help="AI agent to run inside the sandbox.", + nargs="?", + choices=list(AGENT_CLIS), + help="AI agent to run inside the sandbox. Omit for a plain shell.", ) parser.add_argument( "--update", action="store_true", - help="Update the agent CLI inside the container before running.", + help="Update the agent CLI inside the container before running. " + "Requires an agent.", ) parser.add_argument( "--rebuild-docker", action="store_true", help="Rebuild the Docker image." @@ -49,11 +122,12 @@ def main() -> None: parser.add_argument( "-v", "--verbose", action="store_true", help="Enable verbose logging." ) - args = parser.parse_args() + if args.update and args.agent is None: + parser.error("--update requires an agent") + def log(msg: str) -> None: - """Log a message if verbose mode is enabled.""" if args.verbose: print(msg) @@ -61,57 +135,41 @@ def log(msg: str) -> None: ["git", "rev-parse", "--show-toplevel"], text=True ).strip() - image_name = "cc-protocol-sandbox" - image_exists = ( subprocess.run( - ["docker", "image", "inspect", image_name], - capture_output=True, + ["docker", "image", "inspect", IMAGE_NAME], capture_output=True ).returncode == 0 ) - if args.rebuild_docker or not image_exists: - log(f"--- Building Docker Sandbox: {image_name} ---") + log(f"--- Building Docker Sandbox: {IMAGE_NAME} ---") subprocess.check_call( [ "docker", "build", "-t", - image_name, + IMAGE_NAME, "-f", os.path.join(project_root, "docker/Dockerfile"), project_root, ] ) - log(f"--- Starting Sandboxed {args.agent.capitalize()} Session ---") + session_name = args.agent.capitalize() if args.agent else "Shell" + log(f"--- Starting Sandboxed {session_name} Session ---") log(f"Note: Your current directory {project_root} is mounted to /workspace") - if args.agent == "gemini": - npm_package = "@google/gemini-cli" - agent_cmd = "gemini" - elif args.agent == "antigravity": - npm_package = None - agent_cmd = "agy" - else: - npm_package = "@anthropic-ai/claude-code" - agent_cmd = "claude --dangerously-skip-permissions" - - if args.update: - if args.agent == "antigravity": - container_cmd = ( - "curl -fsSL https://antigravity.google/cli/install.sh | bash && " - f"{agent_cmd}" - ) - else: - container_cmd = ( - f"export NPM_CONFIG_PREFIX=~/.npm-global && " - f"export PATH=~/.npm-global/bin:$PATH && " - f"npm install -g {npm_package}@latest && {agent_cmd}" - ) + if args.agent is None: + print("To build and test with the C++26 reflection backend (GCC 16):") + print(" ./scripts/cmake.sh --release --reflection -B build-reflection") + container_cmd = None else: - container_cmd = agent_cmd + cli = AGENT_CLIS[args.agent] + container_cmd = ( + _update_command(args.agent, cli["cmd"], cli["npm_package"]) + if args.update + else cli["cmd"] + ) run_args = [ "docker", @@ -120,48 +178,17 @@ def log(msg: str) -> None: "--rm", "-v", f"{project_root}:/workspace", + *_agent_mount_args(args.agent), ] - - if args.agent in ("gemini", "antigravity"): - gemini_config_dir = os.path.expanduser("~/.gemini") - os.makedirs(gemini_config_dir, mode=0o700, exist_ok=True) - # Seed default config files if missing so they are accessible inside the - # container. - # Use os.open with restrictive permissions to avoid exposing credentials to - # other local users on multi-user systems. - _seed_config_file( - os.path.join(gemini_config_dir, "trustedFolders.json"), - b'{"/workspace": "TRUST_FOLDER"}', - ) - _seed_config_file( - os.path.join(gemini_config_dir, "settings.json"), - b'{"selectedAuthType": "oauth-personal"}', - ) - run_args.extend(["-v", f"{gemini_config_dir}:/home/vscode/.gemini"]) - else: - host_claude_dir = os.path.expanduser("~/.claude") - host_claude_json = os.path.expanduser("~/.claude.json") - os.makedirs(host_claude_dir, mode=0o700, exist_ok=True) - # Ensure the file exists on the host so Docker doesn't create it as a directory. - # Use os.open with restrictive permissions to avoid exposing credentials to - # other local users on multi-user systems. - if os.path.exists(host_claude_json): - if not os.path.isfile(host_claude_json): - sys.exit( - f"Expected {host_claude_json} to be a regular file, but found a " - "different filesystem object. Remove or rename it and rerun." - ) - else: - _seed_config_file(host_claude_json, b"") - run_args.extend(["-v", f"{host_claude_dir}:/home/vscode/.claude"]) - run_args.extend(["-v", f"{host_claude_json}:/home/vscode/.claude.json"]) - if "TERM" in os.environ: run_args.extend(["-e", f"TERM={os.environ['TERM']}"]) if "COLORTERM" in os.environ: run_args.extend(["-e", f"COLORTERM={os.environ['COLORTERM']}"]) - run_args.extend([image_name, "bash", "-c", container_cmd]) + if container_cmd is None: + run_args.extend([IMAGE_NAME, "bash"]) + else: + run_args.extend([IMAGE_NAME, "bash", "-c", container_cmd]) try: subprocess.run(run_args, check=True) diff --git a/scripts/cmake.py b/scripts/cmake.py index ecfca13..1d35436 100644 --- a/scripts/cmake.py +++ b/scripts/cmake.py @@ -2,6 +2,7 @@ """CMake helper script for building and testing the project.""" import argparse +import os import subprocess from typing import Any @@ -37,6 +38,12 @@ def main() -> None: ) parser.add_argument("--tsan", action="store_true", help="Enable Thread Sanitizer") parser.add_argument("--msan", action="store_true", help="Enable Memory Sanitizer") + parser.add_argument( + "--reflection", + action="store_true", + help="Build and test tutorials/reflection.cc (requires a P2996 " + "reflection compiler, e.g. CXX=g++-16 CC=gcc-16)", + ) parser.add_argument("-B", "--build-dir", help="Build directory") parser.add_argument( "--clean", action="store_true", help="Fresh configuration and clean-first build" @@ -74,6 +81,7 @@ def log(msg: Any) -> None: f"-DENABLE_UBSAN={'ON' if args.ubsan else 'OFF'}", f"-DENABLE_TSAN={'ON' if args.tsan else 'OFF'}", f"-DENABLE_MSAN={'ON' if args.msan else 'OFF'}", + "-DXYZ_PROTOCOL_BUILD_REFLECTION=" + ("ON" if args.reflection else "OFF"), ] if args.build_dir: configure_args.extend(["-B", args.build_dir]) @@ -82,8 +90,17 @@ def log(msg: Any) -> None: configure_args.extend(extra) + # A P2996 reflection compiler is required to configure with + # XYZ_PROTOCOL_BUILD_REFLECTION=ON. CMake only reads CXX/CC + # from the environment, not from -D cache variables, so set them here + # rather than as configure_args. + configure_env = os.environ.copy() + if args.reflection: + configure_env["CXX"] = "g++-16" + configure_env["CC"] = "gcc-16" + log(f"Running: {' '.join(configure_args)}") - subprocess.check_call(configure_args) + subprocess.check_call(configure_args, env=configure_env) # Build step (required for build, test, benchmark) build_args = ["cmake", "--build"] diff --git a/scripts/docker-shell.sh b/scripts/docker-shell.sh new file mode 100755 index 0000000..451ec5d --- /dev/null +++ b/scripts/docker-shell.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eu -o pipefail + +# Get the workspace root +WORKSPACE_ROOT=$(git rev-parse --show-toplevel) + +# Change directory to the workspace root and run the python script +cd "$WORKSPACE_ROOT" +uv run scripts/agentic-sandbox.py "$@" From 0b62f348db8b078612f8ba0d0f8713d83b763017 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 22:24:01 +0100 Subject: [PATCH 2/6] Clean up CMake C++26 support and checks --- CMakeLists.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2e73b6..10bd2d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,13 +36,16 @@ with C++26 P2996 reflection support (GCC 16+ with -freflection)." OFF) if(XYZ_PROTOCOL_BUILD_REFLECTION) +set(CMAKE_CXX_STANDARD 26) +set(CMAKE_REQUIRED_FLAGS "-std=c++26 -freflection") + set(CMAKE_REQUIRED_FLAGS "$<$:-freflection>") include(CheckCXXSourceCompiles) - set(CMAKE_REQUIRED_FLAGS "-std=c++26 -freflection") check_cxx_source_compiles( - " - #include - constexpr std::meta::info reflection_of_int = ^^int; - int main() {} + "#include + + #ifndef __cpp_impl_reflection + #error No reflection support + #endif " XYZ_PROTOCOL_REFLECTION_SUPPORTED) unset(CMAKE_REQUIRED_FLAGS) @@ -51,9 +54,7 @@ if(XYZ_PROTOCOL_BUILD_REFLECTION) FATAL_ERROR "XYZ_PROTOCOL_BUILD_REFLECTION is ON but the compiler " "(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}) does not " - "accept '-std=c++26 -freflection'. C++26 reflection currently " - "requires GCC 16 or newer; configure with e.g. " - "CXX=g++-16 CC=gcc-16 and a separate build directory (-B).") + "support C++26 reflection.") endif() endif() From 1dec90c45d0c66fb651126ea07cda944e9c04671 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 22:27:49 +0100 Subject: [PATCH 3/6] Update minimum CMake version for C++26 support --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10bd2d2..83d45e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22.4 FATAL_ERROR) +cmake_minimum_required(VERSION 3.25 FATAL_ERROR) cmake_policy(SET CMP0127 NEW) cmake_policy(SET CMP0135 NEW) cmake_policy(SET CMP0140 NEW) From 2cbbd6120a029b3819ac95d8297872d90d3398e6 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 22:31:48 +0100 Subject: [PATCH 4/6] Fix setting of CMakeLists flags --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83d45e2..6487671 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,13 +32,14 @@ option(ENABLE_MSAN "Enable Memory Sanitizer" OFF) option( XYZ_PROTOCOL_BUILD_REFLECTION "Also build and test tutorials/reflection.cc, which requires a compiler \ -with C++26 P2996 reflection support (GCC 16+ with -freflection)." +with C++26 P2996 reflection support (eg. GCC 16+ with -freflection)." OFF) if(XYZ_PROTOCOL_BUILD_REFLECTION) set(CMAKE_CXX_STANDARD 26) -set(CMAKE_REQUIRED_FLAGS "-std=c++26 -freflection") - set(CMAKE_REQUIRED_FLAGS "$<$:-freflection>") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_REQUIRED_FLAGS "-freflection") + endif() include(CheckCXXSourceCompiles) check_cxx_source_compiles( "#include From 6e554da6841906ddcdea4539220234c65ca10048 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 22:32:21 +0100 Subject: [PATCH 5/6] Fix setting of CMakeLists flags --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6487671..952af3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ with C++26 P2996 reflection support (eg. GCC 16+ with -freflection)." OFF) if(XYZ_PROTOCOL_BUILD_REFLECTION) -set(CMAKE_CXX_STANDARD 26) + set(CMAKE_CXX_STANDARD 26) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_REQUIRED_FLAGS "-freflection") endif() From 80697627fa5280f7d037263c98d7668a90d1f663 Mon Sep 17 00:00:00 2001 From: "Jonathan B. Coe" Date: Tue, 18 Aug 2026 22:37:13 +0100 Subject: [PATCH 6/6] Amend rfecltion check code --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 952af3c..ac8f1c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,11 +42,10 @@ if(XYZ_PROTOCOL_BUILD_REFLECTION) endif() include(CheckCXXSourceCompiles) check_cxx_source_compiles( - "#include - - #ifndef __cpp_impl_reflection - #error No reflection support - #endif + " + #include + constexpr std::meta::info reflection_of_int = ^^int; + int main() {} " XYZ_PROTOCOL_REFLECTION_SUPPORTED) unset(CMAKE_REQUIRED_FLAGS)