From 732cc8ed5b55b804f93baaf2fdd9994b1af6cff8 Mon Sep 17 00:00:00 2001 From: okuoku Date: Thu, 8 Apr 2021 21:28:45 +0900 Subject: [PATCH] cmake: Fix UWP DLL build by removing /NODEFAUTLIB On UWP, we need default C runtime for C++ sources. --- CMakeLists.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cdab8cff..b5316e527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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$<$:d> - -nodefaultlib:msvcrt$<$:d> - vccorlib$<$:d>.lib - msvcrt$<$: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) - file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/windows/*.c) + 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$<$:d> + -nodefaultlib:msvcrt$<$:d> + vccorlib$<$:d>.lib + msvcrt$<$: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. - set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB") - set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB") + 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})