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
1 changed files with 18 additions and 10 deletions

View File

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