From ac88a3837712e247aa828e4dc28c093675117cce Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Fri, 26 Aug 2022 07:09:46 +0900 Subject: [PATCH] Fix macOS build with the SDL2 2.24.0 SDL2 2.24.0 has a bug in its cmake for macOS: https://github.com/libsdl-org/SDL/issues/6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released. --- CMake/Dependencies.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake index fd23477ee..9d83d344a 100644 --- a/CMake/Dependencies.cmake +++ b/CMake/Dependencies.cmake @@ -31,7 +31,9 @@ else() if(DEVILUTIONX_SYSTEM_SDL2) find_package(SDL2 REQUIRED) if(TARGET SDL2::SDL2) - set(SDL2_MAIN SDL2::SDL2main) + if(TARGET SDL2::SDL2main) + set(SDL2_MAIN SDL2::SDL2main) + endif() elseif(TARGET SDL2::SDL2-static) # On some distros, such as vitasdk, only the SDL2::SDL2-static target is available. # Alias to SDL2::SDL2 because some finder scripts may refer to SDL2::SDL2. @@ -39,7 +41,9 @@ else() # Aliasing local targets is not supported on CMake < 3.18, so make it global. set_target_properties(SDL2::SDL2-static PROPERTIES IMPORTED_GLOBAL TRUE) endif() - set(SDL2_MAIN SDL2::SDL2main) + if(TARGET SDL2::SDL2main) + set(SDL2_MAIN SDL2::SDL2main) + endif() else() # Assume an older Debian derivate that comes with an sdl2-config.cmake # that only defines `SDL2_LIBRARIES` (as -lSDL2) and `SDL2_INCLUDE_DIRS`. @@ -54,7 +58,9 @@ else() find_package(SDL2 REQUIRED) else() add_subdirectory(3rdParty/SDL2) - set(SDL2_MAIN SDL2::SDL2main) + if(TARGET SDL2::SDL2main) + set(SDL2_MAIN SDL2::SDL2main) + endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/SDL2/CMake") endif() endif()