CMakeLists.txt 1.22 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
)

target_include_directories(Joystick PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

27
if(WIN32)
28
        include_directories(${CMAKE_SOURCE_DIR}/libs/sdl2/msvc/include)
29 30
	# Support both 32 and 64 bit builds
	if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
31
                set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/libs/sdl2/msvc/lib/x64/SDL2.lib;${CMAKE_SOURCE_DIR}/libs/sdl2/msvc/lib/x64/SDL2main.lib")
32
	else ()
33
                set(SDL2_LIBRARIES "${CMAKE_SOURCE_DIR}/libs/sdl2/msvc/lib/x86/SDL2.lib;${CMAKE_SOURCE_DIR}/libs/sdl2/msvc/lib/x86/SDL2main.lib")
34 35 36
	endif ()

	string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
37

38
	target_link_libraries(Joystick PUBLIC ${SDL2_LIBRARIES})
39 40 41 42 43 44 45 46 47 48
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()
49
endif()