112 lines
4.0 KiB
Diff
112 lines
4.0 KiB
Diff
|
From 7393bdae70b445334157410f61372937b922cdc6 Mon Sep 17 00:00:00 2001
|
||
|
From: Neal Gompa <ngompa13@gmail.com>
|
||
|
Date: Tue, 4 Jan 2022 09:35:41 -0500
|
||
|
Subject: [PATCH] cmake: Split SDL2-static and SDL2main into their own target
|
||
|
exports
|
||
|
|
||
|
This makes it so that the generated targets are not interdependent,
|
||
|
which allows Linux distributions to split libraries into the
|
||
|
appropriate subpackages as needed.
|
||
|
---
|
||
|
CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++++++-----------
|
||
|
1 file changed, 44 insertions(+), 12 deletions(-)
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index 76cc3c516..be15edc74 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -2748,7 +2748,6 @@ if(NOT WINDOWS_STORE)
|
||
|
add_library(SDL2::SDL2main ALIAS SDL2main)
|
||
|
target_include_directories(SDL2main BEFORE PRIVATE "${SDL2_BINARY_DIR}/include")
|
||
|
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
|
||
|
- set(_INSTALL_LIBS "SDL2main")
|
||
|
if (NOT ANDROID)
|
||
|
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
||
|
endif()
|
||
|
@@ -2794,7 +2793,6 @@ if(SDL_SHARED)
|
||
|
endif()
|
||
|
set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
|
||
|
endif()
|
||
|
- set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
|
||
|
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||
|
target_include_directories(SDL2 BEFORE PRIVATE "${SDL2_BINARY_DIR}/include")
|
||
|
target_include_directories(SDL2 PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
||
|
@@ -2826,7 +2824,6 @@ if(SDL_STATIC)
|
||
|
endif()
|
||
|
# TODO: Win32 platforms keep the same suffix .lib for import and static
|
||
|
# libraries - do we need to consider this?
|
||
|
- set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
|
||
|
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||
|
target_include_directories(SDL2-static BEFORE PRIVATE "${SDL2_BINARY_DIR}/include")
|
||
|
target_include_directories(SDL2-static PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include/SDL2>)
|
||
|
@@ -2848,10 +2845,26 @@ if(SDL_TEST)
|
||
|
endif()
|
||
|
|
||
|
##### Installation targets #####
|
||
|
-install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
|
||
|
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||
|
+if(SDL_SHARED)
|
||
|
+ install(TARGETS SDL2 EXPORT SDL2Targets
|
||
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||
|
+endif()
|
||
|
+
|
||
|
+if(NOT WINDOWS_STORE)
|
||
|
+ install(TARGETS SDL2main EXPORT SDL2mainTargets
|
||
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||
|
+endif()
|
||
|
+
|
||
|
+if(SDL_STATIC)
|
||
|
+ install(TARGETS SDL2-static EXPORT SDL2staticTargets
|
||
|
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||
|
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||
|
+endif()
|
||
|
|
||
|
##### Export files #####
|
||
|
if (WINDOWS AND NOT MINGW)
|
||
|
@@ -2866,11 +2879,30 @@ write_basic_package_version_file("${CMAKE_BINARY_DIR}/SDL2ConfigVersion.cmake"
|
||
|
COMPATIBILITY AnyNewerVersion
|
||
|
)
|
||
|
|
||
|
-install(EXPORT SDL2Targets
|
||
|
- FILE SDL2Targets.cmake
|
||
|
- NAMESPACE SDL2::
|
||
|
- DESTINATION ${PKG_PREFIX}
|
||
|
-)
|
||
|
+if(SDL_SHARED)
|
||
|
+ install(EXPORT SDL2Targets
|
||
|
+ FILE SDL2Targets.cmake
|
||
|
+ NAMESPACE SDL2::
|
||
|
+ DESTINATION ${PKG_PREFIX}
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
+if(NOT WINDOWS_STORE)
|
||
|
+ install(EXPORT SDL2mainTargets
|
||
|
+ FILE SDL2mainTargets.cmake
|
||
|
+ NAMESPACE SDL2::
|
||
|
+ DESTINATION ${PKG_PREFIX}
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
+if(SDL_STATIC)
|
||
|
+ install(EXPORT SDL2staticTargets
|
||
|
+ FILE SDL2staticTargets.cmake
|
||
|
+ NAMESPACE SDL2::
|
||
|
+ DESTINATION ${PKG_PREFIX}
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
install(
|
||
|
FILES
|
||
|
${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
|
||
|
--
|
||
|
2.33.1
|
||
|
|