From 18c3c3bd517e6bb6e9a52b086a34055d5329b195 Mon Sep 17 00:00:00 2001 From: Andy Vandijck Date: Sat, 3 May 2025 23:51:32 +0000 Subject: [PATCH] build: fix link error on MSVC for SFML port Change two `constexpr` declarations to `inline` to fix a link error on MSVC. Also remove the C++14 override that was used for testing on MSVC, the project being defined as C++17 in CMake. Signed-off-by: Rafael Kitover --- cmake/Toolchain-msvc.cmake | 2 -- third_party/sfml/include/SFML/System/Angle.inl | 4 ++++ third_party/sfml/include/SFML/System/Time.inl | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/Toolchain-msvc.cmake b/cmake/Toolchain-msvc.cmake index 340ad9fd..c2f39ab1 100644 --- a/cmake/Toolchain-msvc.cmake +++ b/cmake/Toolchain-msvc.cmake @@ -68,8 +68,6 @@ if(CMAKE_VERSION VERSION_LESS "3.25") endif() endif() -add_compile_options($<$:/std:c++14>) - set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE) # We need to explicitly set all of these to override the CMake defaults. diff --git a/third_party/sfml/include/SFML/System/Angle.inl b/third_party/sfml/include/SFML/System/Angle.inl index 517108d2..a3cf6794 100644 --- a/third_party/sfml/include/SFML/System/Angle.inl +++ b/third_party/sfml/include/SFML/System/Angle.inl @@ -266,6 +266,10 @@ constexpr Angle operator""_rad(unsigned long long angle) // Note: the 'inline' keyword here is technically not required, but VS2019 fails // to compile with a bogus "multiple definition" error if not explicitly used. +#ifdef _MSC_VER +inline constexpr Angle Angle::Zero; +#else constexpr Angle Angle::Zero; +#endif } // namespace sf diff --git a/third_party/sfml/include/SFML/System/Time.inl b/third_party/sfml/include/SFML/System/Time.inl index 1180ad08..9f75783b 100644 --- a/third_party/sfml/include/SFML/System/Time.inl +++ b/third_party/sfml/include/SFML/System/Time.inl @@ -279,6 +279,10 @@ constexpr Time& operator%=(Time& left, Time right) // Note: the 'inline' keyword here is technically not required, but VS2019 fails // to compile with a bogus "multiple definition" error if not explicitly used. +#ifdef _MSC_VER +inline constexpr Time Time::Zero; +#else constexpr Time Time::Zero; +#endif } // namespace sf