Browse Source

Joystick: Use find_package for mac and linux

Fix cmake build in macOS

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
QGC4.4
Patrick José Pereira 5 years ago committed by Daniel Agar
parent
commit
bab9fbe939
  1. 32
      src/Joystick/CMakeLists.txt

32
src/Joystick/CMakeLists.txt

@ -24,24 +24,7 @@ target_link_libraries(Joystick @@ -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) @@ -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()

Loading…
Cancel
Save