diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bad8fa98..abcf71b43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,8 +137,6 @@ if(SFML_USE_SYSTEM_DEPS) endforeach() list(REMOVE_DUPLICATES CMAKE_IGNORE_PATH) -elseif(SFML_COMPILER_GCC AND GCC_COMPILER_VERSION MATCHES "ucrt") - message(FATAL_ERROR "The pre-compiled SFML dependencies for MinGW are not compatible with the UCRT. Either switch to the MSVCRT or build the dependencies yourself.") endif() if(SFML_COMPILER_MSVC) @@ -387,13 +385,15 @@ if(SFML_OS_WINDOWS) if(NOT SFML_USE_SYSTEM_DEPS) # install the binaries of SFML dependencies - if(ARCH_32BITS) + if(ARCH_ARM64) + install(DIRECTORY extlibs/libs-msvc-universal/ARM64/ DESTINATION ${CMAKE_INSTALL_LIBDIR}) + elseif(ARCH_X86) if(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW)) install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() - elseif(ARCH_64BITS) + elseif(ARCH_X64) if(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW)) install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 07c956c1b..35dc26ede 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -6,10 +6,14 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(OPENGL_ES 0) # detect the architecture - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(ARCH_32BITS 1) + if(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64") + set(ARCH_ARM64 1) + elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "ARM64") + set(ARCH_ARM64 1) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(ARCH_X86 1) elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ARCH_64BITS 1) + set(ARCH_X64 1) else() message(FATAL_ERROR "Unsupported architecture") return() @@ -87,11 +91,21 @@ if(MSVC) endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(SFML_COMPILER_CLANG 1) + + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" OUTPUT_VARIABLE CLANG_COMPILER_VERSION ERROR_VARIABLE CLANG_COMPILER_VERSION) + + if("${CLANG_COMPILER_VERSION}" MATCHES "ucrt") + set(SFML_RUNTIME_UCRT 1) + endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(SFML_COMPILER_GCC 1) - execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION) + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" OUTPUT_VARIABLE GCC_COMPILER_VERSION ERROR_VARIABLE GCC_COMPILER_VERSION) string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}") + + if("${GCC_COMPILER_VERSION}" MATCHES "ucrt") + set(SFML_RUNTIME_UCRT 1) + endif() else() message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}. Use at your own risk.") endif() diff --git a/cmake/Mesa3D.cmake b/cmake/Mesa3D.cmake index 60539ed6b..485db274d 100644 --- a/cmake/Mesa3D.cmake +++ b/cmake/Mesa3D.cmake @@ -4,10 +4,12 @@ set(MESA3D_SHA256 "FEF8A643689414A70347AE8027D24674DEFD85E8D6428C8A9D4145BB3F44A get_filename_component(MESA3D_ARCHIVE "${MESA3D_URL}" NAME) get_filename_component(MESA3D_ARCHIVE_DIRECTORY "${MESA3D_URL}" NAME_WLE) -if(${ARCH_64BITS}) +if(${ARCH_X64}) set(MESA3D_ARCH "x64") -else() +elseif(${ARCH_X86}) set(MESA3D_ARCH "x86") +else() + message(FATAL_ERROR "Mesa 3D does currently not support the target architecture.") endif() set(MESA3D_ARCHIVE_PATH "${PROJECT_BINARY_DIR}/${MESA3D_ARCHIVE_DIRECTORY}/${MESA3D_ARCHIVE}") diff --git a/extlibs/libs-mingw-ucrt/x64/libFLAC.a b/extlibs/libs-mingw-ucrt/x64/libFLAC.a new file mode 100644 index 000000000..523c71963 Binary files /dev/null and b/extlibs/libs-mingw-ucrt/x64/libFLAC.a differ diff --git a/extlibs/libs-mingw-ucrt/x64/libfreetype.a b/extlibs/libs-mingw-ucrt/x64/libfreetype.a new file mode 100644 index 000000000..a1e5ed574 Binary files /dev/null and b/extlibs/libs-mingw-ucrt/x64/libfreetype.a differ diff --git a/extlibs/libs-mingw-ucrt/x86/libFLAC.a b/extlibs/libs-mingw-ucrt/x86/libFLAC.a new file mode 100644 index 000000000..bea890ae1 Binary files /dev/null and b/extlibs/libs-mingw-ucrt/x86/libFLAC.a differ diff --git a/extlibs/libs-mingw-ucrt/x86/libfreetype.a b/extlibs/libs-mingw-ucrt/x86/libfreetype.a new file mode 100644 index 000000000..71eac0d41 Binary files /dev/null and b/extlibs/libs-mingw-ucrt/x86/libfreetype.a differ diff --git a/extlibs/libs-msvc-universal/ARM64/flac.lib b/extlibs/libs-msvc-universal/ARM64/flac.lib new file mode 100644 index 000000000..e8e4c4ded Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/flac.lib differ diff --git a/extlibs/libs-msvc-universal/ARM64/freetype.lib b/extlibs/libs-msvc-universal/ARM64/freetype.lib new file mode 100644 index 000000000..a56097437 Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/freetype.lib differ diff --git a/extlibs/libs-msvc-universal/ARM64/ogg.lib b/extlibs/libs-msvc-universal/ARM64/ogg.lib new file mode 100644 index 000000000..6bfefb350 Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/ogg.lib differ diff --git a/extlibs/libs-msvc-universal/ARM64/vorbis.lib b/extlibs/libs-msvc-universal/ARM64/vorbis.lib new file mode 100644 index 000000000..d59f33b9a Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/vorbis.lib differ diff --git a/extlibs/libs-msvc-universal/ARM64/vorbisenc.lib b/extlibs/libs-msvc-universal/ARM64/vorbisenc.lib new file mode 100644 index 000000000..a700b1de6 Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/vorbisenc.lib differ diff --git a/extlibs/libs-msvc-universal/ARM64/vorbisfile.lib b/extlibs/libs-msvc-universal/ARM64/vorbisfile.lib new file mode 100644 index 000000000..dba0d3255 Binary files /dev/null and b/extlibs/libs-msvc-universal/ARM64/vorbisfile.lib differ diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 4874325f5..3118b9c86 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -5,16 +5,26 @@ include(${PROJECT_SOURCE_DIR}/cmake/Macros.cmake) if(SFML_OS_WINDOWS) list(APPEND CMAKE_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/extlibs/headers") if(SFML_COMPILER_GCC OR (SFML_COMPILER_CLANG AND MINGW)) - if(ARCH_32BITS) - list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x86") - elseif(ARCH_64BITS) - list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x64") + if(ARCH_X86) + if(SFML_RUNTIME_UCRT) + # taking precendence for provided libraries linking UCRT + list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw-ucrt/x86") + endif() + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x86") + elseif(ARCH_X64) + if(SFML_RUNTIME_UCRT) + # taking precendence for provided libraries linking UCRT + list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw-ucrt/x64") + endif() + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x64") endif() elseif(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW)) - if(ARCH_32BITS) - list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x86") - elseif(ARCH_64BITS) - list(APPEND CMAKE_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x64") + if(ARCH_ARM64) + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/ARM64") + elseif(ARCH_X86) + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x86") + elseif(ARCH_X64) + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x64") endif() endif() elseif(SFML_OS_MACOS) diff --git a/src/SFML/Window/Win32/ClipboardImpl.cpp b/src/SFML/Window/Win32/ClipboardImpl.cpp index 33c90b854..84585d711 100644 --- a/src/SFML/Window/Win32/ClipboardImpl.cpp +++ b/src/SFML/Window/Win32/ClipboardImpl.cpp @@ -35,6 +35,26 @@ #include +namespace +{ +std::string getErrorString(DWORD error) +{ + PTCHAR buffer = nullptr; + + if (FormatMessage(FORMAT_MESSAGE_MAX_WIDTH_MASK | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + nullptr, + error, + 0, + reinterpret_cast(&buffer), + 0, + nullptr) == 0) + return "Unknown error."; + + sf::String message = buffer; + LocalFree(buffer); + return message.toAnsiString(); +} +} namespace sf::priv { @@ -45,13 +65,13 @@ String ClipboardImpl::getString() if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) { - err() << "Failed to get the clipboard data in Unicode format." << std::endl; + err() << "Failed to get the clipboard data in Unicode format: " << getErrorString(GetLastError()) << std::endl; return text; } if (!OpenClipboard(nullptr)) { - err() << "Failed to open the Win32 clipboard." << std::endl; + err() << "Failed to open the Win32 clipboard: " << getErrorString(GetLastError()) << std::endl; return text; } @@ -59,7 +79,7 @@ String ClipboardImpl::getString() if (!clipboardHandle) { - err() << "Failed to get Win32 handle for clipboard content." << std::endl; + err() << "Failed to get Win32 handle for clipboard content: " << getErrorString(GetLastError()) << std::endl; CloseClipboard(); return text; } @@ -77,13 +97,14 @@ void ClipboardImpl::setString(const String& text) { if (!OpenClipboard(nullptr)) { - err() << "Failed to open the Win32 clipboard." << std::endl; + err() << "Failed to open the Win32 clipboard: " << getErrorString(GetLastError()) << std::endl; return; } if (!EmptyClipboard()) { - err() << "Failed to empty the Win32 clipboard." << std::endl; + err() << "Failed to empty the Win32 clipboard: " << getErrorString(GetLastError()) << std::endl; + CloseClipboard(); return; }