From 661fe08f080d90ffc24830960d50df4bee4efe3a Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Tue, 3 Sep 2024 23:20:56 +0200 Subject: [PATCH] GLMHelpers: Fix build with C++20 on GCC. When enabling C++20 the lerp function seems to be redefined on GCC (not on MSVC), don't redefine it using a CMake definition. --- libraries/shared/src/GLMHelpers.h | 2 ++ plugins/openxr/CMakeLists.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h index cfb4bb6398..c74820e4a0 100644 --- a/libraries/shared/src/GLMHelpers.h +++ b/libraries/shared/src/GLMHelpers.h @@ -212,9 +212,11 @@ T toNormalizedDeviceScale(const T& value, const T& size) { #define ROLL(euler) euler.z // float - linear interpolate +#if !defined(DONT_REDEFINE_LERP) inline float lerp(float x, float y, float a) { return x * (1.0f - a) + (y * a); } +#endif // vec2 lerp - linear interpolate template diff --git a/plugins/openxr/CMakeLists.txt b/plugins/openxr/CMakeLists.txt index 9316a77f63..c54d5efcc2 100644 --- a/plugins/openxr/CMakeLists.txt +++ b/plugins/openxr/CMakeLists.txt @@ -22,6 +22,9 @@ include_hifi_library_headers(script-engine) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") # Silence GCC warnings target_compile_options(openxr PRIVATE -Wno-missing-field-initializers) + + # Fix build issue where lerp is already defined on C++20 / GCC + target_compile_definitions(openxr PRIVATE -DDONT_REDEFINE_LERP) endif() set_property(TARGET openxr PROPERTY CXX_STANDARD 20) \ No newline at end of file