CMakeLists.txt 1.58 KB
Newer Older
1

2 3 4 5 6 7 8 9
set(EXTRA_SRC)

if (ANDROID)
	list(APPEND EXTRA_SRC
		JoystickAndroid.cc
	)
endif()

10 11 12 13
add_library(Joystick
	Joystick.cc
	JoystickManager.cc
	JoystickSDL.cc
14
	${EXTRA_SRC}
15 16 17
)

target_link_libraries(Joystick
Daniel Agar's avatar
Daniel Agar committed
18 19
        PRIVATE
            ui
20 21
	PUBLIC
		qgc
Daniel Agar's avatar
Daniel Agar committed
22
		ui
23 24 25 26 27
)

target_include_directories(Joystick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if(LINUX)
Daniel Agar's avatar
Daniel Agar committed
28
        find_package(SDL2 REQUIRED)
29 30 31 32 33 34 35 36 37
        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()

38
elseif(APPLE)
Daniel Agar's avatar
Daniel Agar committed
39 40 41 42 43
        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
        )
44 45 46 47 48 49 50 51 52 53 54 55 56 57
elseif(WIN32)
	include_directories(libs/lib/sdl2/msvc/include)
	# Support both 32 and 64 bit builds
	if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
		set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/libs/lib/sdl2/msvc/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/libs/lib/sdl2/msvc/lib/x64/SDL2main.lib")
	else ()
		set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/libs/lib/sdl2/msvc/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/libs/lib/sdl2/msvc/lib/x86/SDL2main.lib")
	endif ()

	string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
	
	target_link_libraries(Joystick ${SDL2_LIBRARIES})
endif()