diff --git a/CMakeLists.txt b/CMakeLists.txt index 4af9dfbd5..144508a2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,8 +180,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() # Visual C++: remove warnings regarding SL security and algorithms on pointers diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 3d22c314f..c598867d4 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -110,13 +110,25 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT) string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}") + + 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_COMPILER_IS_GNUCXX) set(SFML_COMPILER_GCC 1) execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT) string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}") - 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() + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE) string(STRIP "${GCC_MACHINE}" GCC_MACHINE) 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/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index c60bc4fc9..0081ad5c2 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -7,9 +7,17 @@ if (SFML_OS_WINDOWS) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") if(SFML_COMPILER_GCC OR (SFML_COMPILER_CLANG AND MINGW)) if(ARCH_32BITS) + 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") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x86") elseif(ARCH_64BITS) + 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") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x64") endif()