cmake: add support for Torsten's UDev EventInput
(Hopefully meeting Torsten's quality expectations)
This commit is contained in:
parent
ded106fe31
commit
9933a7cb4a
5 changed files with 92 additions and 102 deletions
|
@ -80,8 +80,11 @@ IF(APPLE)
|
||||||
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
|
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
|
||||||
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
# disabled while DBus / HAL / udev issues are decided
|
find_package(UDev)
|
||||||
#set(EVENT_INPUT_DEFAULT 1)
|
|
||||||
|
if(UDEV_FOUND)
|
||||||
|
set(EVENT_INPUT_DEFAULT 1)
|
||||||
|
endif(UDEV_FOUND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
@ -160,19 +163,23 @@ endif (MSVC AND MSVC_3RDPARTY_ROOT)
|
||||||
|
|
||||||
if(EVENT_INPUT)
|
if(EVENT_INPUT)
|
||||||
message(STATUS "checking event-based Input")
|
message(STATUS "checking event-based Input")
|
||||||
|
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
find_package(DBus)
|
if(NOT UDEV_FOUND)
|
||||||
if(NOT DBUS_FOUND)
|
message(WARNING "UDev not found, event input is disabled!")
|
||||||
message(WARNING "DBus not found, event input will be disabled")
|
set(EVENT_INPUT 0)
|
||||||
set(EVENT_INPUT 0)
|
else()
|
||||||
endif()
|
set(EVENT_INPUT_LIBRARIES ${UDEV_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
message(WARNING "event input is not supported on this platform yet")
|
message(WARNING "event input is not supported on this platform yet")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Keep PLIB INPUT enabled as long as EventInput does not replace current joystick configurations.
|
||||||
|
set(ENABLE_PLIB_JOYSTICK 1)
|
||||||
else(EVENT_INPUT)
|
else(EVENT_INPUT)
|
||||||
set(ENABLE_PLIB_JOYSTICK 1)
|
set(ENABLE_PLIB_JOYSTICK 1)
|
||||||
endif(EVENT_INPUT)
|
endif(EVENT_INPUT)
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
# - Try to find the low-level D-Bus library
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# DBUS_FOUND - system has D-Bus
|
|
||||||
# DBUS_INCLUDE_DIR - the D-Bus include directory
|
|
||||||
# DBUS_ARCH_INCLUDE_DIR - the D-Bus architecture-specific include directory
|
|
||||||
# DBUS_LIBRARIES - the libraries needed to use D-Bus
|
|
||||||
|
|
||||||
# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at>
|
|
||||||
# modeled after FindLibArt.cmake:
|
|
||||||
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
|
||||||
|
|
||||||
if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
# in cache already
|
|
||||||
SET(DBUS_FOUND TRUE)
|
|
||||||
|
|
||||||
else (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
IF (NOT WIN32)
|
|
||||||
FIND_PACKAGE(PkgConfig)
|
|
||||||
IF (PKG_CONFIG_FOUND)
|
|
||||||
# use pkg-config to get the directories and then use these values
|
|
||||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
|
||||||
pkg_check_modules(_DBUS_PC QUIET dbus-1)
|
|
||||||
ENDIF (PKG_CONFIG_FOUND)
|
|
||||||
ENDIF (NOT WIN32)
|
|
||||||
|
|
||||||
FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h
|
|
||||||
${_DBUS_PC_INCLUDE_DIRS}
|
|
||||||
/usr/include
|
|
||||||
/usr/include/dbus-1.0
|
|
||||||
/usr/local/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
|
|
||||||
${_DBUS_PC_INCLUDE_DIRS}
|
|
||||||
/usr/lib${LIB_SUFFIX}/include
|
|
||||||
/usr/lib${LIB_SUFFIX}/dbus-1.0/include
|
|
||||||
/usr/lib64/include
|
|
||||||
/usr/lib64/dbus-1.0/include
|
|
||||||
/usr/lib/include
|
|
||||||
/usr/lib/dbus-1.0/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(DBUS_LIBRARIES NAMES dbus-1 dbus
|
|
||||||
PATHS
|
|
||||||
${_DBUS_PC_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
set(DBUS_FOUND TRUE)
|
|
||||||
endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
|
|
||||||
if (DBUS_FOUND)
|
|
||||||
if (NOT DBus_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found D-Bus: ${DBUS_LIBRARIES}")
|
|
||||||
endif (NOT DBus_FIND_QUIETLY)
|
|
||||||
else (DBUS_FOUND)
|
|
||||||
if (DBus_FIND_REQUIRED)
|
|
||||||
message(FATAL_ERROR "Could NOT find D-Bus")
|
|
||||||
endif (DBus_FIND_REQUIRED)
|
|
||||||
endif (DBUS_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
53
CMakeModules/FindUDev.cmake
Normal file
53
CMakeModules/FindUDev.cmake
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# Configure libudev environment
|
||||||
|
#
|
||||||
|
# UDEV_FOUND - system has a libudev
|
||||||
|
# UDEV_INCLUDE_DIR - where to find header files
|
||||||
|
# UDEV_LIBRARIES - the libraries to link against udev
|
||||||
|
# UDEV_STABLE - it's true when is the version greater or equals to 143 - version when the libudev was stabilized in its API
|
||||||
|
#
|
||||||
|
# copyright (c) 2011 Petr Vanek <petr@scribus.info>
|
||||||
|
# Redistribution and use of this file is allowed according to the terms of the BSD license.
|
||||||
|
#
|
||||||
|
|
||||||
|
FIND_PATH(
|
||||||
|
UDEV_INCLUDE_DIR
|
||||||
|
libudev.h
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
${UDEV_PATH_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(
|
||||||
|
UDEV_LIBRARIES
|
||||||
|
NAMES udev libudev
|
||||||
|
PATHS
|
||||||
|
/usr/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
/usr/local/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
${UDEV_PATH_LIB}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
|
||||||
|
SET(UDEV_FOUND "YES")
|
||||||
|
execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
|
||||||
|
# retvale is 0 of the condition is "true" so we need to negate the value...
|
||||||
|
if (UDEV_STABLE)
|
||||||
|
set(UDEV_STABLE 0)
|
||||||
|
else (UDEV_STABLE)
|
||||||
|
set(UDEV_STABLE 1)
|
||||||
|
endif (UDEV_STABLE)
|
||||||
|
message(STATUS "libudev stable: ${UDEV_STABLE}")
|
||||||
|
ENDIF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF (UDEV_FOUND)
|
||||||
|
MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
|
||||||
|
MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}")
|
||||||
|
ELSE (UDEV_FOUND)
|
||||||
|
MESSAGE(STATUS "UDev not found.")
|
||||||
|
MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
|
||||||
|
MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}")
|
||||||
|
MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
|
||||||
|
MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}")
|
||||||
|
IF (UDev_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find UDev library")
|
||||||
|
ENDIF (UDev_FIND_REQUIRED)
|
||||||
|
ENDIF (UDEV_FOUND)
|
|
@ -4,7 +4,7 @@ IF(APPLE)
|
||||||
set(EVENT_INPUT_SOURCES FGMacOSXEventInput.cxx)
|
set(EVENT_INPUT_SOURCES FGMacOSXEventInput.cxx)
|
||||||
set(EVENT_INPUT_HEADERS FGMacOSXEventInput.hxx)
|
set(EVENT_INPUT_HEADERS FGMacOSXEventInput.hxx)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
message(STATUS "EventInput not implemented for Windows yet")
|
message(STATUS "EventInput not implemented for Windows yet")
|
||||||
else()
|
else()
|
||||||
set(EVENT_INPUT_SOURCES FGLinuxEventInput.cxx)
|
set(EVENT_INPUT_SOURCES FGLinuxEventInput.cxx)
|
||||||
set(EVENT_INPUT_HEADERS FGLinuxEventInput.hxx)
|
set(EVENT_INPUT_HEADERS FGLinuxEventInput.hxx)
|
||||||
|
@ -21,36 +21,37 @@ set(SOURCES
|
||||||
FGMouseInput.cxx
|
FGMouseInput.cxx
|
||||||
input.cxx
|
input.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
FGButton.hxx
|
FGButton.hxx
|
||||||
FGCommonInput.hxx
|
FGCommonInput.hxx
|
||||||
FGDeviceConfigurationMap.hxx
|
FGDeviceConfigurationMap.hxx
|
||||||
FGEventInput.hxx
|
FGEventInput.hxx
|
||||||
FGJoystickInput.hxx
|
FGJoystickInput.hxx
|
||||||
FGKeyboardInput.hxx
|
FGKeyboardInput.hxx
|
||||||
FGMouseInput.hxx
|
FGMouseInput.hxx
|
||||||
input.hxx
|
input.hxx
|
||||||
)
|
)
|
||||||
|
|
||||||
if(EVENT_INPUT)
|
if(EVENT_INPUT)
|
||||||
list(APPEND SOURCES ${EVENT_INPUT_SOURCES})
|
list(APPEND SOURCES ${EVENT_INPUT_SOURCES})
|
||||||
list(APPEND SOURCES ${EVENT_INPUT_HEADERS})
|
list(APPEND SOURCES ${EVENT_INPUT_HEADERS})
|
||||||
include_directories(${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
|
include_directories(${UDEV_INCLUDE_DIR})
|
||||||
|
add_definitions(-DWITH_EVENTINPUT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FGJS_SOURCES
|
set(FGJS_SOURCES
|
||||||
fgjs.cxx
|
fgjs.cxx
|
||||||
jsinput.cxx
|
jsinput.cxx
|
||||||
jssuper.cxx
|
jssuper.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(fgjs ${FGJS_SOURCES})
|
add_executable(fgjs ${FGJS_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(fgjs
|
target_link_libraries(fgjs
|
||||||
${SIMGEAR_CORE_LIBRARIES}
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
${PLIB_LIBRARIES}
|
${PLIB_LIBRARIES}
|
||||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
add_executable(js_demo js_demo.cxx)
|
add_executable(js_demo js_demo.cxx)
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,12 @@ get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
|
||||||
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
||||||
|
|
||||||
if(RTI_FOUND)
|
if(RTI_FOUND)
|
||||||
find_sg_component(hla SIMGEAR_LIBRARIES)
|
find_sg_component(hla SIMGEAR_LIBRARIES)
|
||||||
find_sg_component(rti13 SIMGEAR_LIBRARIES)
|
find_sg_component(rti13 SIMGEAR_LIBRARIES)
|
||||||
find_sg_component(rti SIMGEAR_LIBRARIES)
|
find_sg_component(rti SIMGEAR_LIBRARIES)
|
||||||
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(HLA_LIBRARIES "")
|
set(HLA_LIBRARIES "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(fgfs
|
target_link_libraries(fgfs
|
||||||
|
@ -77,6 +77,7 @@ target_link_libraries(fgfs
|
||||||
${PLIB_LIBRARIES}
|
${PLIB_LIBRARIES}
|
||||||
${JPEG_LIBRARY}
|
${JPEG_LIBRARY}
|
||||||
${HLA_LIBRARIES}
|
${HLA_LIBRARIES}
|
||||||
|
${EVENT_INPUT_LIBRARIES}
|
||||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
|
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
|
|
Loading…
Add table
Reference in a new issue