From bab9fbe9397317544ef6b1458eb95425e7352465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Tue, 14 Jan 2020 10:33:38 -0300 Subject: [PATCH] Joystick: Use find_package for mac and linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix cmake build in macOS Signed-off-by: Patrick José Pereira --- src/Joystick/CMakeLists.txt | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index 2024dcd98..f7536972b 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -24,24 +24,7 @@ target_link_libraries(Joystick target_include_directories(Joystick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -if(LINUX) - find_package(SDL2 REQUIRED) - 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") - set_target_properties(Joystick PROPERTIES - MACOSX_BUNDLE YES - ) -elseif(WIN32) +if(WIN32) include_directories(libs/lib/sdl2/msvc/include) # Support both 32 and 64 bit builds if (${CMAKE_SIZEOF_VOID_P} MATCHES 8) @@ -51,7 +34,16 @@ elseif(WIN32) endif () string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) - + target_link_libraries(Joystick ${SDL2_LIBRARIES}) +else() + find_package(SDL2 REQUIRED) + 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() endif() - -- 2.22.0