mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 12:14:41 +02:00
Re-apply megasource-specific changes to SDL's CMakeLists.
- Enable SDL_SHARED and disable SDL_STATIC. - Set SDL_LINK_DIR in parent scope. - Use custom install() directive. - Add target_include_directories.
This commit is contained in:
@@ -344,8 +344,8 @@ dep_option(KMSDRM_SHARED "Dynamically load KMS DRM support" ON "VIDEO_KMSD
|
|||||||
|
|
||||||
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
|
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
|
||||||
# The options below are for compatibility to configure's default behaviour.
|
# The options below are for compatibility to configure's default behaviour.
|
||||||
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
|
||||||
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
|
set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library")
|
||||||
|
|
||||||
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
|
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
|
||||||
set_option(SDL_TEST "Build the test directory" OFF)
|
set_option(SDL_TEST "Build the test directory" OFF)
|
||||||
@@ -1171,6 +1171,8 @@ elseif(WINDOWS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(SDL_LINK_DIR ${PARENT_SCOPE})
|
||||||
|
|
||||||
# Check for DirectX
|
# Check for DirectX
|
||||||
if(DIRECTX)
|
if(DIRECTX)
|
||||||
if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
|
if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
|
||||||
@@ -1213,7 +1215,7 @@ elseif(WINDOWS)
|
|||||||
set(HAVE_DIRECTX TRUE)
|
set(HAVE_DIRECTX TRUE)
|
||||||
if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
|
if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
|
||||||
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
||||||
link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
|
set(SDL_LINK_DIR $ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH} ${SDL_LINK_DIR})
|
||||||
include_directories($ENV{DXSDK_DIR}\\Include)
|
include_directories($ENV{DXSDK_DIR}\\Include)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -1225,6 +1227,8 @@ elseif(WINDOWS)
|
|||||||
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
|
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
|
||||||
check_include_file(endpointvolume.h HAVE_ENDPOINTVOLUME_H)
|
check_include_file(endpointvolume.h HAVE_ENDPOINTVOLUME_H)
|
||||||
|
|
||||||
|
link_directories(${SDL_LINK_DIR})
|
||||||
|
|
||||||
if(SDL_AUDIO)
|
if(SDL_AUDIO)
|
||||||
set(SDL_AUDIO_DRIVER_WINMM 1)
|
set(SDL_AUDIO_DRIVER_WINMM 1)
|
||||||
file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
|
file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
|
||||||
@@ -1729,7 +1733,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
|||||||
|
|
||||||
# Always build SDLmain
|
# Always build SDLmain
|
||||||
add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
|
add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
|
||||||
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include/SDL2>)
|
target_include_directories(SDL2main PUBLIC include)
|
||||||
set(_INSTALL_LIBS "SDL2main")
|
set(_INSTALL_LIBS "SDL2main")
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
||||||
@@ -1737,6 +1741,7 @@ endif()
|
|||||||
|
|
||||||
if(SDL_SHARED)
|
if(SDL_SHARED)
|
||||||
add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
|
add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
|
||||||
|
install(TARGETS SDL2 RUNTIME DESTINATION . LIBRARY DESTINATION .)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set_target_properties(SDL2 PROPERTIES
|
set_target_properties(SDL2 PROPERTIES
|
||||||
MACOSX_RPATH 1
|
MACOSX_RPATH 1
|
||||||
@@ -1760,7 +1765,7 @@ if(SDL_SHARED)
|
|||||||
endif()
|
endif()
|
||||||
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
|
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
|
||||||
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||||||
target_include_directories(SDL2 PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include/SDL2>)
|
target_include_directories(SDL2 PUBLIC include)
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
||||||
endif()
|
endif()
|
||||||
@@ -1802,6 +1807,11 @@ if(SDL_TEST)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
##### Installation targets #####
|
##### Installation targets #####
|
||||||
|
|
||||||
|
if(MEGA)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
|
install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
|
||||||
LIBRARY DESTINATION "lib${LIB_SUFFIX}"
|
LIBRARY DESTINATION "lib${LIB_SUFFIX}"
|
||||||
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
|
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
|
||||||
|
|||||||
Reference in New Issue
Block a user