CMakeLists: rename version to VERSION to avoid shadowing C++20 <version> - #570
Open
heitbaum wants to merge 1 commit into
Open
CMakeLists: rename version to VERSION to avoid shadowing C++20 <version>#570heitbaum wants to merge 1 commit into
heitbaum wants to merge 1 commit into
Conversation
Problem
-------
The file named `version` in the repository root contains the plain-text
project version string ("1.1.0") and is read by CMakeLists.txt at
configure time:
file(READ version PROJECT_VERSION)
When rpi_ws281x is used as a CMake subdirectory of a C++20 project, the
subdirectory's source path is typically added to the compiler include
search path so that the library headers (ws2811.h, rpihw.h, etc.) can be
found with angle-bracket includes. On any compiler that implements C++20,
the `<version>` feature-test header is part of the standard library. When
a translation unit (directly, or through a transitively included header)
does:
#include <version>
the preprocessor searches the include path in order. If the rpi_ws281x
source directory appears on that path before the toolchain's system include
directory, the compiler opens the plain-text `version` file instead of the
C++20 standard library header. Attempting to parse "1.1.0" as C++ source
is a hard error:
error: stray '.' in program
Fix
---
Rename `version` to `VERSION`. On Linux (and all other case-sensitive
filesystems) `VERSION` and `version` are distinct names; the compiler
looking for `<version>` will no longer find the version data file.
Update the single `file(READ ...)` call in CMakeLists.txt accordingly.
No other file in this repository references the plain name `version` as a
path: `version.h.in` and `version.py` are separate files with different
names and are unaffected.
Impact
------
Behaviour is identical for all existing build methods (CMake, SCons). The
only observable change is the filename on disk; the content and the
PROJECT_VERSION variable it populates are unchanged.
heitbaum
added a commit
to heitbaum/LibreELEC.tv
that referenced
this pull request
Jun 11, 2026
The source tree ships a plain-text version file in its root directory. When the directory is on a compiler include path, #include <version> (used by Qt5's qstdlibdetection.h) finds this file instead of the C++ standard library header and fails to compile with "error: stray '.' in program". Carry a patch to rename version to VERSION (safe on case-sensitive Linux) and update the file(READ) call in CMakeLists.txt. hyperhdr processes rpi_ws281x via add_subdirectory so cmake still reads the version data; hyperion compiles the sources directly and is unaffected either way. Patch submitted upstream: jgarff/rpi_ws281x#570 Drop this patch when the upstream PR is merged and PKG_VERSION is bumped.
Merged
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The file named
versionin the repository root contains the plain-text project version string ("1.1.0") and is read by CMakeLists.txt at configure time:When rpi_ws281x is used as a CMake subdirectory of a C++20 project, the subdirectory's source path is typically added to the compiler include search path so that the library headers (ws2811.h, rpihw.h, etc.) can be found with angle-bracket includes. On any compiler that implements C++20, the
<version>feature-test header is part of the standard library. When a translation unit (directly, or through a transitively included header) does:the preprocessor searches the include path in order. If the rpi_ws281x source directory appears on that path before the toolchain's system include directory, the compiler opens the plain-text
versionfile instead of the C++20 standard library header. Attempting to parse "1.1.0" as C++ source is a hard error:Fix
Rename
versiontoVERSION. On Linux (and all other case-sensitive filesystems)VERSIONandversionare distinct names; the compiler looking for<version>will no longer find the version data file.Update the single
file(READ ...)call in CMakeLists.txt accordingly. No other file in this repository references the plain nameversionas a path:version.h.inandversion.pyare separate files with different names and are unaffected.Impact
Behaviour is identical for all existing build methods (CMake, SCons). The only observable change is the filename on disk; the content and the PROJECT_VERSION variable it populates are unchanged.