cmake: always create SDL2::SDL2main target in autotools' cmake config script

This commit is contained in:
Anonymous Maarten 2022-08-24 04:14:52 +02:00 committed by Sam Lantinga
parent dc2ef31c29
commit 5eb0f4328d
1 changed files with 29 additions and 28 deletions

View File

@ -62,38 +62,39 @@ string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_priv
if(_sdl2_libraries MATCHES ".*SDL2main.*") if(_sdl2_libraries MATCHES ".*SDL2main.*")
list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main) list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main) list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX}) endif()
if(EXISTS "${_sdl2main_library}")
set(SDL2MAIN_LIBRARY SDL2::SDL2main) set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
if(NOT TARGET SDL2::SDL2main) if(EXISTS "${_sdl2main_library}")
add_library(SDL2::SDL2main STATIC IMPORTED) set(SDL2MAIN_LIBRARY SDL2::SDL2main)
set_target_properties(SDL2::SDL2main if(NOT TARGET SDL2::SDL2main)
PROPERTIES add_library(SDL2::SDL2main STATIC IMPORTED)
IMPORTED_LOCATION "${_sdl2main_library}" set_target_properties(SDL2::SDL2main
) PROPERTIES
if(WIN32) IMPORTED_LOCATION "${_sdl2main_library}"
# INTERFACE_LINK_OPTIONS needs CMake 3.13 )
cmake_minimum_required(VERSION 3.13) if(WIN32)
# Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker. # INTERFACE_LINK_OPTIONS needs CMake 3.13
if(CMAKE_SIZEOF_VOID_P EQUAL 4) cmake_minimum_required(VERSION 3.13)
set_target_properties(SDL2::SDL2main # Mark WinMain/WinMain@16 as undefined, such that it will be withheld by the linker.
PROPERTIES if(CMAKE_SIZEOF_VOID_P EQUAL 4)
INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16" set_target_properties(SDL2::SDL2main
) PROPERTIES
else() INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16"
set_target_properties(SDL2::SDL2main )
PROPERTIES else()
INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain" set_target_properties(SDL2::SDL2main
) PROPERTIES
endif() INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain"
)
endif() endif()
endif() endif()
set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2main_FOUND FALSE)
endif() endif()
unset(_sdl2main_library) set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2main_FOUND FALSE)
endif() endif()
unset(_sdl2main_library)
# Remove SDL2 since this is the "central" library # Remove SDL2 since this is the "central" library
# Remove SDL2main since this will be provided by SDL2::SDL2main (if available) # Remove SDL2main since this will be provided by SDL2::SDL2main (if available)