Link legacy_stdio_definitions.lib on newer MSVC -- fixes linker errors for sprintf() & Co.

Starting from Visual Studio 2015, some standard symbols are inlined and thus no longer linkable.
Code that was linked against earlier versions can use a compatibility library, as described here:
https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp?view=msvc-160#libraries
This commit is contained in:
Jan Haller 2020-10-31 11:59:06 +01:00 committed by Lukas Dürrenberger
parent ea7408e1ee
commit d1f4db39c8

View File

@ -117,6 +117,12 @@ elseif(SFML_OS_IOS)
target_link_libraries(sfml-graphics PRIVATE z bz2)
endif()
# starting from Visual Studio 2015, inline versions of some C functions are used; for compatibility link this library
# see https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp?view=msvc-160#libraries
if(SFML_COMPILER_MSVC AND MSVC_VERSION GREATER_EQUAL 1900)
target_link_libraries(sfml-graphics PRIVATE legacy_stdio_definitions.lib)
endif()
sfml_find_package(Freetype INCLUDE "FREETYPE_INCLUDE_DIRS" LINK "FREETYPE_LIBRARY")
target_link_libraries(sfml-graphics PRIVATE Freetype)