From 867ea2dfcf9ab5036773da9794626234c3df639a Mon Sep 17 00:00:00 2001 From: Chris Rizzitello Date: Tue, 12 Feb 2019 13:34:26 -0500 Subject: [PATCH] Correctly Detect and link SDL2 for linux --- src/Joystick/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index 56e06fb4f..2024dcd98 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -26,9 +26,15 @@ target_include_directories(Joystick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(LINUX) find_package(SDL2 REQUIRED) - include_directories(${SDL2_INCLUDE_DIRS}) - string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES) # work around for cmake warning - target_link_libraries(Joystick PRIVATE ${SDL2_LIBRARIES}) + if (IS_DIRECTORY ${SDL2_INCLUDE_DIRS}) + include_directories(${SDL2_INCLUDE_DIRS}) + string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) + target_link_libraries(Joystick PRIVATE ${SDL2_LIBRARIES}) + else() + include_directories(${SDL2_DIR}) + target_link_libraries(Joystick PRIVATE SDL2::SDL2) + endif() + elseif(APPLE) include_directories(${CMAKE_SOURCE_DIR}/libs/lib/Frameworks/SDL2.framework/Headers) target_link_libraries(Joystick PRIVATE -F${CMAKE_SOURCE_DIR}/libs/lib/Frameworks "-framework SDL2") -- 2.22.0