CMake build for Linux next to MSBuild, warnings as errors, pinned downloads #2

Closed
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:47 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

Linux needs a build system, and Windows keeps MSBuild for the solution. Every later issue builds on both, so both have to exist and agree before any engine code changes. Warnings as errors from the first day keep the code clean on three compilers without a later cleanup pass.

Decided

  • CMake (3.28 or newer, for modules) with presets: linux-debug, linux-release (clang) and linux-gcc-debug, linux-gcc-release; Ninja. Output goes to x64/<Config>/ like MSBuild.
  • C++23: cxx_std_23 in CMake; stdcpp23 and toolset v145 in every .vcxproj (not stdcpplatest).
  • Warnings: -Wall -Wextra -Wpedantic with -Werror (PRIMAL_WARNINGS_AS_ERRORS, default ON); MSVC /W4 /WX /permissive- (PrimalWarningsAsErrors, default on).
  • Third-party code is downloaded, never committed: cmake/PrimalDependencies.cmake (FetchContent with URL + SHA-256) and an MSBuild .targets file with the same version and hash. vcpkg is not used.
  • The engine compiles on Linux first with a stub platform layer; S1 adds the real one.
  • PRIMAL_ENABLE_SANITIZERS=ON turns on ASan and UBSan.

Read first

  • LinuxVulkanPort, "Phase 1 – CMake build alongside the .vcxproj files" and "Phase 2".
  • LinuxVulkanPortSteps (the commit-by-commit rebuild of the port's first phases).
  • Engine/Engine.vcxproj and EngineTest/EngineTest.vcxproj on master.

Steps

  • 1. Write CMakeLists.txt and CMakePresets.json for Engine (static for now; S1 makes it shared) and EngineTest.
  • 2. Make Engine compile on Linux: platform detection stubs, #if around Win32-only files. Keep every change small enough to review.
  • 3. Turn on the warning flags and fix what clang and GCC report.
  • 4. Retarget the .vcxproj files to v145 and stdcpp23, with /W4 /WX /permissive-, and build the four configurations on Windows.
  • 5. Add cmake/PrimalDependencies.cmake and the matching MSBuild .targets file, with DirectXMath as the first download.
  • 6. Write down the build commands in CLAUDE.md.

Done when

  • cmake --build --preset linux-debug and linux-gcc-debug build Engine and EngineTest with 0 warnings.
  • The four Windows configurations build with 0 warnings.
  • The entity-components EngineTest runs on Linux.

Claude can help with

  • Reading compiler errors from the GCC and clang builds and pointing at the cause.
  • Running the Windows builds in the VM once S0-08 exists, or reviewing the .vcxproj diff.
  • Writing the FetchContent boilerplate once you've picked the URL.

Learn

  • How CMake presets, generators and multi-config builds relate.
  • Why MSVC's /permissive- matters for code that has to build on clang and GCC.
## Why Linux needs a build system, and Windows keeps MSBuild for the solution. Every later issue builds on both, so both have to exist and agree before any engine code changes. Warnings as errors from the first day keep the code clean on three compilers without a later cleanup pass. ## Decided - CMake (3.28 or newer, for modules) with presets: `linux-debug`, `linux-release` (clang) and `linux-gcc-debug`, `linux-gcc-release`; Ninja. Output goes to `x64/<Config>/` like MSBuild. - C++23: `cxx_std_23` in CMake; `stdcpp23` and toolset v145 in every `.vcxproj` (not `stdcpplatest`). - Warnings: `-Wall -Wextra -Wpedantic` with `-Werror` (`PRIMAL_WARNINGS_AS_ERRORS`, default ON); MSVC `/W4 /WX /permissive-` (`PrimalWarningsAsErrors`, default on). - Third-party code is downloaded, never committed: `cmake/PrimalDependencies.cmake` (FetchContent with URL + SHA-256) and an MSBuild `.targets` file with the same version and hash. vcpkg is not used. - The engine compiles on Linux first with a stub platform layer; S1 adds the real one. - `PRIMAL_ENABLE_SANITIZERS=ON` turns on ASan and UBSan. ## Read first - [LinuxVulkanPort](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/LinuxVulkanPort), "Phase 1 – CMake build alongside the `.vcxproj` files" and "Phase 2". - [LinuxVulkanPortSteps](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/LinuxVulkanPortSteps) (the commit-by-commit rebuild of the port's first phases). - `Engine/Engine.vcxproj` and `EngineTest/EngineTest.vcxproj` on `master`. ## Steps - [x] 1. Write `CMakeLists.txt` and `CMakePresets.json` for `Engine` (static for now; S1 makes it shared) and `EngineTest`. - [x] 2. Make `Engine` compile on Linux: platform detection stubs, `#if` around Win32-only files. Keep every change small enough to review. - [x] 3. Turn on the warning flags and fix what clang and GCC report. - [x] 4. Retarget the `.vcxproj` files to v145 and `stdcpp23`, with `/W4 /WX /permissive-`, and build the four configurations on Windows. - [x] 5. Add `cmake/PrimalDependencies.cmake` and the matching MSBuild `.targets` file, with DirectXMath as the first download. - [x] 6. Write down the build commands in `CLAUDE.md`. ## Done when - [x] `cmake --build --preset linux-debug` and `linux-gcc-debug` build `Engine` and `EngineTest` with 0 warnings. - [x] The four Windows configurations build with 0 warnings. - [x] The entity-components EngineTest runs on Linux. ## Claude can help with - Reading compiler errors from the GCC and clang builds and pointing at the cause. - Running the Windows builds in the VM once S0-08 exists, or reviewing the `.vcxproj` diff. - Writing the FetchContent boilerplate once you've picked the URL. ## Learn - How CMake presets, generators and multi-config builds relate. - Why MSVC's `/permissive-` matters for code that has to build on clang and GCC.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks
#4 Self-contained headers and no include cycles
UnflavoredMeson/Primal_Plus_Plus
#5 Unit tests with doctest
UnflavoredMeson/Primal_Plus_Plus
#9 Freeze the WPF editor
UnflavoredMeson/Primal_Plus_Plus
#8 Windows VM for build and test checks
UnflavoredMeson/Primal_Plus_Plus
#11 The engine as one shared library
UnflavoredMeson/Primal_Plus_Plus
#24 ShaderCompilerTool at build time
UnflavoredMeson/Primal_Plus_Plus
Depends on
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#2
No description provided.