From 6d9602b12abc2eef650c1bdac144e685d165f1f2 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 21 Feb 2022 07:53:08 -0500 Subject: [PATCH] When building on Linux, prefer using the SDL2 config module This is shipped by SDL2 itself, so it should be the preferred way of finding it. Since SDL2 does not ship it in their Windows development libraries, we still need to use the regular Find module. --- CMakeLists.txt | 2 +- platforms/sdl/CMakeLists.txt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87e9e51..04d3c2e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ include(FetchContent) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") message("Linux build detected!") - find_package(SDL2 REQUIRED) + find_package(SDL2 REQUIRED CONFIG) set(ENABLE_VULKAN TRUE) set(ENABLE_LINUX TRUE) diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index 08531aa..ddfc767 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -7,6 +7,14 @@ if(ENABLE_MACOS) set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm) endif() +if(TARGET SDL2::Main) + set(EXTRA_LIBRARIES SDL2::Main) +endif() + +if(TARGET SDL2::SDL2main) + set(EXTRA_LIBRARIES SDL2::SDL2main) +endif() + add_platform( SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp @@ -17,9 +25,9 @@ add_platform( MACOSX_BUNDLE ON MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" LINK_LIBRARIES - SDL2::Main Core GFXVulkan + SDL2::SDL2 ${EXTRA_LIBRARIES} )