|
| 1 | +From ac77fbe9b43c7d5656b521735cc9ab3d3ccc8325 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rudi Heitbaum <rudi@heitbaum.com> |
| 3 | +Date: Thu, 11 Jun 2026 20:48:08 +1000 |
| 4 | +Subject: [PATCH] CMakeLists: rename version to VERSION to avoid shadowing |
| 5 | + C++20 <version> |
| 6 | + |
| 7 | +Problem |
| 8 | +------- |
| 9 | +The file named `version` in the repository root contains the plain-text |
| 10 | +project version string ("1.1.0") and is read by CMakeLists.txt at |
| 11 | +configure time: |
| 12 | + |
| 13 | + file(READ version PROJECT_VERSION) |
| 14 | + |
| 15 | +When rpi_ws281x is used as a CMake subdirectory of a C++20 project, the |
| 16 | +subdirectory's source path is typically added to the compiler include |
| 17 | +search path so that the library headers (ws2811.h, rpihw.h, etc.) can be |
| 18 | +found with angle-bracket includes. On any compiler that implements C++20, |
| 19 | +the `<version>` feature-test header is part of the standard library. When |
| 20 | +a translation unit (directly, or through a transitively included header) |
| 21 | +does: |
| 22 | + |
| 23 | + #include <version> |
| 24 | + |
| 25 | +the preprocessor searches the include path in order. If the rpi_ws281x |
| 26 | +source directory appears on that path before the toolchain's system include |
| 27 | +directory, the compiler opens the plain-text `version` file instead of the |
| 28 | +C++20 standard library header. Attempting to parse "1.1.0" as C++ source |
| 29 | +is a hard error: |
| 30 | + |
| 31 | + error: stray '.' in program |
| 32 | + |
| 33 | +Fix |
| 34 | +--- |
| 35 | +Rename `version` to `VERSION`. On Linux (and all other case-sensitive |
| 36 | +filesystems) `VERSION` and `version` are distinct names; the compiler |
| 37 | +looking for `<version>` will no longer find the version data file. |
| 38 | + |
| 39 | +Update the single `file(READ ...)` call in CMakeLists.txt accordingly. |
| 40 | +No other file in this repository references the plain name `version` as a |
| 41 | +path: `version.h.in` and `version.py` are separate files with different |
| 42 | +names and are unaffected. |
| 43 | + |
| 44 | +Impact |
| 45 | +------ |
| 46 | +Behaviour is identical for all existing build methods (CMake, SCons). The |
| 47 | +only observable change is the filename on disk; the content and the |
| 48 | +PROJECT_VERSION variable it populates are unchanged. |
| 49 | +--- |
| 50 | + CMakeLists.txt | 4 ++-- |
| 51 | + version => VERSION | 0 |
| 52 | + 2 files changed, 2 insertions(+), 2 deletions(-) |
| 53 | + rename version => VERSION (100%) |
| 54 | + |
| 55 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 56 | +index ba5dd90..19bb717 100644 |
| 57 | +--- a/CMakeLists.txt |
| 58 | ++++ b/CMakeLists.txt |
| 59 | +@@ -1,7 +1,7 @@ |
| 60 | + cmake_minimum_required(VERSION 3.0.0) |
| 61 | + |
| 62 | +-# read and parse version file |
| 63 | +-file(READ version PROJECT_VERSION) |
| 64 | ++# read and parse VERSION file |
| 65 | ++file(READ VERSION PROJECT_VERSION) |
| 66 | + string(STRIP ${PROJECT_VERSION} PROJECT_VERSION) |
| 67 | + string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VERSION_MAJOR ${PROJECT_VERSION}) |
| 68 | + string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" VERSION_MINOR ${PROJECT_VERSION}) |
| 69 | +diff --git a/VERSION b/VERSION |
| 70 | +new file mode 100644 |
| 71 | +index 0000000..9084fa2 |
| 72 | +--- /dev/null |
| 73 | ++++ b/VERSION |
| 74 | +@@ -0,0 +1 @@ |
| 75 | ++1.1.0 |
| 76 | +diff --git a/version b/version |
| 77 | +deleted file mode 100644 |
| 78 | +index 9084fa2..0000000 |
| 79 | +--- a/version |
| 80 | ++++ /dev/null |
| 81 | +@@ -1 +0,0 @@ |
| 82 | +-1.1.0 |
| 83 | +-- |
| 84 | +2.53.0 |
| 85 | + |
0 commit comments