mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-15 02:57:56 +08:00
[sdl2] Use cmake for UWP
This commit is contained in:
parent
26a180b804
commit
e6c65b93b1
@ -1,3 +1,3 @@
|
||||
Source: sdl2
|
||||
Version: 2.0.7-2
|
||||
Version: 2.0.7-3
|
||||
Description: Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.
|
||||
|
206
ports/sdl2/enable-winrt-cmake.patch
Normal file
206
ports/sdl2/enable-winrt-cmake.patch
Normal file
@ -0,0 +1,206 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 73d9407..082fbc5 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -3,7 +3,11 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
-project(SDL2 C)
|
||||
+if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||
+ project(SDL2 C CXX)
|
||||
+else()
|
||||
+ project(SDL2 C)
|
||||
+endif()
|
||||
|
||||
# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
|
||||
# !!! FIXME: for the SDL2 shared library (so you get an
|
||||
@@ -358,7 +362,6 @@ file(GLOB SOURCE_FILES
|
||||
${SDL2_SOURCE_DIR}/src/timer/*.c
|
||||
${SDL2_SOURCE_DIR}/src/video/*.c)
|
||||
|
||||
-
|
||||
if(ASSERTIONS STREQUAL "auto")
|
||||
# Do nada - use optimization settings to determine the assertion level
|
||||
elseif(ASSERTIONS STREQUAL "disabled")
|
||||
@@ -1132,6 +1135,22 @@ elseif(WINDOWS)
|
||||
file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
|
||||
|
||||
+ if(WINDOWS_STORE)
|
||||
+ cmake_minimum_required(VERSION 3.0)
|
||||
+ 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()
|
||||
+
|
||||
+ if(WINDOWS_STORE)
|
||||
+ file(GLOB WINRT_SOURCE_FILES ${SDL2_SOURCE_DIR}/src/core/winrt/*.c ${SDL2_SOURCE_DIR}/src/core/winrt/*.cpp)
|
||||
+ set(SOURCE_FILES ${SOURCE_FILES} ${WINRT_SOURCE_FILES})
|
||||
+ endif()
|
||||
+
|
||||
if(MSVC)
|
||||
# Prevent codegen that would use the VC runtime libraries.
|
||||
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-")
|
||||
@@ -1176,7 +1195,11 @@ elseif(WINDOWS)
|
||||
check_include_file(d3d11_1.h HAVE_D3D11_H)
|
||||
check_include_file(ddraw.h HAVE_DDRAW_H)
|
||||
check_include_file(dsound.h HAVE_DSOUND_H)
|
||||
- check_include_file(dinput.h HAVE_DINPUT_H)
|
||||
+ if(WINDOWS_STORE)
|
||||
+ set(HAVE_DINPUT_H 0)
|
||||
+ else()
|
||||
+ check_include_file(dinput.h HAVE_DINPUT_H)
|
||||
+ endif()
|
||||
check_include_file(xaudio2.h HAVE_XAUDIO2_H)
|
||||
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
|
||||
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
|
||||
@@ -1193,12 +1216,14 @@ elseif(WINDOWS)
|
||||
endif()
|
||||
|
||||
if(SDL_AUDIO)
|
||||
- set(SDL_AUDIO_DRIVER_WINMM 1)
|
||||
- file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
|
||||
- set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
|
||||
- set(HAVE_SDL_AUDIO TRUE)
|
||||
+ if(NOT WINDOWS_STORE)
|
||||
+ set(SDL_AUDIO_DRIVER_WINMM 1)
|
||||
+ file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
|
||||
+ set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
|
||||
+ set(HAVE_SDL_AUDIO TRUE)
|
||||
+ endif()
|
||||
|
||||
- if(HAVE_DSOUND_H)
|
||||
+ if(HAVE_DSOUND_H AND NOT WINDOWS_STORE)
|
||||
set(SDL_AUDIO_DRIVER_DSOUND 1)
|
||||
file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
|
||||
@@ -1208,9 +1233,10 @@ elseif(WINDOWS)
|
||||
set(SDL_AUDIO_DRIVER_XAUDIO2 1)
|
||||
file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
|
||||
+ set(HAVE_SDL_AUDIO TRUE)
|
||||
endif()
|
||||
|
||||
- if(HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
|
||||
+ if(HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H AND NOT WINDOWS_STORE)
|
||||
set(SDL_AUDIO_DRIVER_WASAPI 1)
|
||||
file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES})
|
||||
@@ -1222,11 +1248,20 @@ elseif(WINDOWS)
|
||||
if(NOT SDL_LOADSO)
|
||||
message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
|
||||
endif()
|
||||
- set(SDL_VIDEO_DRIVER_WINDOWS 1)
|
||||
- file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
|
||||
+ if(WINDOWS_STORE)
|
||||
+ set(SDL_VIDEO_DRIVER_WINRT 1)
|
||||
+ file(GLOB WIN_VIDEO_SOURCES
|
||||
+ ${SDL2_SOURCE_DIR}/src/video/winrt/*.c
|
||||
+ ${SDL2_SOURCE_DIR}/src/video/winrt/*.cpp
|
||||
+ ${SDL2_SOURCE_DIR}/src/render/direct3d11/*.cpp
|
||||
+ )
|
||||
+ else()
|
||||
+ set(SDL_VIDEO_DRIVER_WINDOWS 1)
|
||||
+ file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
|
||||
+ endif()
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
|
||||
|
||||
- if(RENDER_D3D AND HAVE_D3D_H)
|
||||
+ if(RENDER_D3D AND HAVE_D3D_H AND NOT WINDOWS_STORE)
|
||||
set(SDL_VIDEO_RENDER_D3D 1)
|
||||
set(HAVE_RENDER_D3D TRUE)
|
||||
endif()
|
||||
@@ -1249,20 +1284,31 @@ elseif(WINDOWS)
|
||||
endif()
|
||||
|
||||
if(SDL_POWER)
|
||||
- set(SDL_POWER_WINDOWS 1)
|
||||
- set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
|
||||
+ if(WINDOWS_STORE)
|
||||
+ set(SDL_POWER_WINRT 1)
|
||||
+ set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/winrt/SDL_syspower.cpp)
|
||||
+ else()
|
||||
+ set(SDL_POWER_WINDOWS 1)
|
||||
+ set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
|
||||
+ endif()
|
||||
set(HAVE_SDL_POWER TRUE)
|
||||
endif()
|
||||
|
||||
if(SDL_FILESYSTEM)
|
||||
set(SDL_FILESYSTEM_WINDOWS 1)
|
||||
- file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
|
||||
+ if(WINDOWS_STORE)
|
||||
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/winrt/*.cpp)
|
||||
+ else()
|
||||
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
|
||||
+ endif()
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
|
||||
set(HAVE_SDL_FILESYSTEM TRUE)
|
||||
endif()
|
||||
|
||||
# Libraries for Win32 native and MinGW
|
||||
- list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
|
||||
+ if(NOT WINDOWS_STORE)
|
||||
+ list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
|
||||
+ endif()
|
||||
|
||||
# TODO: in configure.in the check for timers is set on
|
||||
# cygwin | mingw32* - does this include mingw32CE?
|
||||
@@ -1284,7 +1330,7 @@ elseif(WINDOWS)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
|
||||
|
||||
if(SDL_VIDEO)
|
||||
- if(VIDEO_OPENGL)
|
||||
+ if(VIDEO_OPENGL AND NOT WINDOWS_STORE)
|
||||
set(SDL_VIDEO_OPENGL 1)
|
||||
set(SDL_VIDEO_OPENGL_WGL 1)
|
||||
set(SDL_VIDEO_RENDER_OGL 1)
|
||||
@@ -1688,9 +1734,11 @@ endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
||||
|
||||
# Always build SDLmain
|
||||
-add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
|
||||
-target_include_directories(SDL2main PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
-set(_INSTALL_LIBS "SDL2main")
|
||||
+if(NOT WINDOWS_STORE)
|
||||
+ add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
|
||||
+ target_include_directories(SDL2main PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
+ set(_INSTALL_LIBS "SDL2main")
|
||||
+endif()
|
||||
|
||||
if(SDL_SHARED)
|
||||
add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
|
||||
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
|
||||
index 9b20398..7ae6e35 100644
|
||||
--- a/include/SDL_config.h.cmake
|
||||
+++ b/include/SDL_config.h.cmake
|
||||
@@ -298,6 +298,7 @@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
|
||||
+#cmakedefine SDL_VIDEO_DRIVER_WINRT @SDL_VIDEO_DRIVER_WINRT@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
|
||||
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
|
||||
@@ -365,6 +366,7 @@
|
||||
#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@
|
||||
#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
|
||||
#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
|
||||
+#cmakedefine SDL_POWER_WINRT @SDL_POWER_WINRT@
|
||||
#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
|
||||
#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@
|
||||
#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@
|
||||
@@ -387,7 +389,7 @@
|
||||
#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@
|
||||
|
||||
/* Platform specific definitions */
|
||||
-#if !defined(__WIN32__)
|
||||
+#if !defined(__WIN32__) && !defined(__WINRT__)
|
||||
# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
|
||||
typedef unsigned int size_t;
|
||||
typedef signed char int8_t;
|
@ -15,61 +15,35 @@ vcpkg_apply_patches(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PATCHES
|
||||
${CMAKE_CURRENT_LIST_DIR}/export-symbols-only-in-shared-build.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/enable-winrt-cmake.patch
|
||||
)
|
||||
|
||||
if(VCPKG_CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
|
||||
vcpkg_build_msbuild(
|
||||
PROJECT_PATH ${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
|
||||
)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED)
|
||||
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT)
|
||||
|
||||
file(COPY
|
||||
${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.dll
|
||||
${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.pdb
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
file(COPY
|
||||
${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.dll
|
||||
${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.pdb
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
|
||||
file(COPY ${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
|
||||
file(COPY ${SOURCE_PATH}/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DSDL_STATIC=${SDL_STATIC}
|
||||
-DSDL_SHARED=${SDL_SHARED}
|
||||
-DVIDEO_VULKAN=OFF
|
||||
-DFORCE_STATIC_VCRT=${FORCE_STATIC_VCRT}
|
||||
-DLIBC=ON
|
||||
)
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include)
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include)
|
||||
file(COPY ${SOURCE_PATH}/include DESTINATION ${CURRENT_PACKAGES_DIR}/include)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/include/include ${CURRENT_PACKAGES_DIR}/include/SDL2)
|
||||
else()
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
||||
set(SDL_STATIC_LIB ON)
|
||||
set(SDL_SHARED_LIB OFF)
|
||||
else()
|
||||
set(SDL_STATIC_LIB OFF)
|
||||
set(SDL_SHARED_LIB ON)
|
||||
endif()
|
||||
if(VCPKG_CRT_LINKAGE STREQUAL static)
|
||||
set(SDL_STATIC_CRT ON)
|
||||
else()
|
||||
set(SDL_STATIC_CRT OFF)
|
||||
endif()
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
OPTIONS
|
||||
-DSDL_STATIC=${SDL_STATIC_LIB}
|
||||
-DSDL_SHARED=${SDL_SHARED_LIB}
|
||||
-DFORCE_STATIC_VCRT=${SDL_STATIC_CRT}
|
||||
-DLIBC=ON
|
||||
)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH "cmake")
|
||||
|
||||
if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib/manual-link ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib ${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib)
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH "cmake")
|
||||
|
||||
file(GLOB SHARE_FILES ${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake)
|
||||
foreach(SHARE_FILE ${SHARE_FILES})
|
||||
file(READ "${SHARE_FILE}" _contents)
|
||||
|
Loading…
x
Reference in New Issue
Block a user