fix: build failures on CMake 4.x and OpenCL headers >= 3.0.16#1209
Open
rginon314 wants to merge 2 commits intoOpenKinect:masterfrom
Open
fix: build failures on CMake 4.x and OpenCL headers >= 3.0.16#1209rginon314 wants to merge 2 commits intoOpenKinect:masterfrom
rginon314 wants to merge 2 commits intoOpenKinect:masterfrom
Conversation
CMake 4.0 removed compatibility with versions < 3.5, causing a hard error when configuring the build. Update all three CMakeLists.txt files from VERSION 2.8.12.1 to VERSION 3.5. Fixes build on CMake >= 4.0 (e.g. CMake 4.2.x).
OpenCL headers >= 3.0.16 (cl_ext.h) define CL_ICDL_VERSION as a preprocessor macro with value 2. This conflicts with the local variable declaration 'const int CL_ICDL_VERSION = 2;' in both OpenCL processor files, causing a compile error: error: expected unqualified-id before numeric constant Add a conditional #undef before the local declaration to resolve the macro collision on modern OpenCL header versions. Affected files: - src/opencl_depth_packet_processor.cpp - src/opencl_kde_depth_packet_processor.cpp
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.
Build Failures on Modern Toolchains (CMake ≥ 4.0 + OpenCL ≥ 3.0.16)
Summary
Building libfreenect2 from source fails with two independent errors when using
CMake 4.x and a recent OpenCL ICD loader (opencl-icd-loader ≥ 3.0.16 / Khronos
vendor headers that include
cl_ext.h≥ 3.0.16).Environment
opencl-headers(cl_ext.h definingCL_ICDL_VERSION)fd64c5d(current HEAD of master)Error 1 —
cmake_minimum_requiredversion too old (CMake ≥ 4.0)Symptom
Root cause
Three
CMakeLists.txtfiles declarecmake_minimum_required(VERSION 2.8.12.1),which CMake 4.0+ explicitly rejects.
Affected files:
CMakeLists.txtexamples/CMakeLists.txttools/streamer_recorder/CMakeLists.txtFix
Error 2 —
CL_ICDL_VERSIONmacro collision (OpenCL headers ≥ 3.0.16)Symptom
(Same error in
src/opencl_kde_depth_packet_processor.cpp.)Root cause
cl_ext.h(Khronos OpenCL headers ≥ 3.0.16) now defines:This macro expands the variable name in the local declaration
const int CL_ICDL_VERSION = 2;, turning it intoconst int 2 = 2;, whichis a hard compile error.
Affected files:
src/opencl_depth_packet_processor.cpp(line ~254)src/opencl_kde_depth_packet_processor.cpp(line ~262)Fix
Undefine the macro immediately before the local variable declaration:
Steps to reproduce
Patch
See the accompanying pull request for a minimal two-commit fix.