cmake: Fix UWP DLL build by removing /NODEFAUTLIB

On UWP, we need default C runtime for C++ sources.
This commit is contained in:
okuoku 2021-04-08 21:28:45 +09:00 committed by Sam Lantinga
parent 50db4a59b8
commit 732cc8ed5b

View file

@ -6,15 +6,8 @@ cmake_minimum_required(VERSION 3.0.0)
project(SDL2 C CXX)
if(WINDOWS_STORE)
enable_language(CXX)
cmake_minimum_required(VERSION 3.11)
add_definitions(-DSDL_BUILDING_WINRT=1 -ZW)
link_libraries(
-nodefaultlib:vccorlib$<$<CONFIG:Debug>:d>
-nodefaultlib:msvcrt$<$<CONFIG:Debug>:d>
vccorlib$<$<CONFIG:Debug>:d>.lib
msvcrt$<$<CONFIG:Debug>:d>.lib
)
endif()
# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
@ -1571,7 +1564,11 @@ elseif(WINDOWS)
endif()
if(SDL_LOCALE)
if(WINDOWS_STORE)
file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/winrt/*.c)
else()
file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/windows/*.c)
endif()
set(SOURCE_FILES ${SOURCE_FILES} ${LOCALE_SOURCES})
set(HAVE_SDL_LOCALE TRUE)
endif()
@ -1592,6 +1589,15 @@ elseif(WINDOWS)
list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32)
endif()
if(WINDOWS_STORE)
list(APPEND EXTRA_LIBS
-nodefaultlib:vccorlib$<$<CONFIG:Debug>:d>
-nodefaultlib:msvcrt$<$<CONFIG:Debug>:d>
vccorlib$<$<CONFIG:Debug>:d>.lib
msvcrt$<$<CONFIG:Debug>:d>.lib
)
endif()
# TODO: in configure.ac the check for timers is set on
# cygwin | mingw32* - does this include mingw32CE?
if(SDL_TIMERS)
@ -2401,8 +2407,10 @@ if(SDL_SHARED)
endif()
if(MSVC AND NOT LIBC)
# Don't try to link with the default set of libraries.
if(NOT WINDOWS_STORE)
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
endif()
set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
endif()
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})