From f701e36aa51416735b5a96c2ba5d352f472f1a69 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Nov 2018 21:08:00 -0600 Subject: [PATCH] CMake: Detect VRPN and build support for it when present I inadvertently rewrote FindVRPN.cmake doing this - I didn't think to check if it already existed before overwriting. Oh well, the new version is a bit simpler. --- cmake/modules/FindVRPN.cmake | 48 +++++++++++------------------------ panda/CMakeLists.txt | 5 ++++ panda/src/vrpn/CMakeLists.txt | 39 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 panda/src/vrpn/CMakeLists.txt diff --git a/cmake/modules/FindVRPN.cmake b/cmake/modules/FindVRPN.cmake index 759cbbf2a8..19d205547c 100644 --- a/cmake/modules/FindVRPN.cmake +++ b/cmake/modules/FindVRPN.cmake @@ -1,45 +1,27 @@ # Filename: FindVRPN.cmake -# Author: kestred (29 Nov, 2013) +# Authors: CFSworks (2 Nov, 2018) # # Usage: # find_package(VRPN [REQUIRED] [QUIET]) # -# It sets the following variables: -# VRPN_FOUND - system has libvrpn -# VRPN_INCLUDE_DIR - the vrpn include directory -# VRPN_LIBRARY_DIR - the vrpn library directory -# VRPN_LIBRARY - the path to the library binary +# Once done this will define: +# VRPN_FOUND - system has VRPN +# VRPN_INCLUDE_DIR - the include directory containing VRPN header files +# VRPN_LIBRARY - the path to the VRPN client library # -if(VRPN_INCLUDE_DIR AND VRPN_LIBRARY_DIR) - set(FOUND_VRPN TRUE) -else() - # Find the vrpn include files - find_path(VRPN_INCLUDE_DIR - NAMES "vrpn_Keyboard.h" - PATHS "/usr/include" - "/usr/local/include" - "/opt/vrpn/include" - PATH_SUFFIXES "" "vrpn" - DOC "The path to vrpn's include directory." - ) +if(NOT VRPN_INCLUDE_DIR) + find_path(VRPN_INCLUDE_DIR "vrpn_Connection.h") - # Find the libvrpn library (.a, .so) - find_library(VRPN_LIBRARY - NAMES "vrpn" - "libvrpn" - PATHS "/usr" - "/usr/local" - "/opt/vrpn" - PATH_SUFFIXES "lib" "lib32" "lib64" - ) - get_filename_component(VRPN_LIBRARY_DIR "${VRPN_LIBRARY}" PATH) - set(VRPN_LIBRARY_DIR "${VRPN_LIBRARY_DIR}" CACHE PATH "The path to vrpn's library directory.") # Library path + mark_as_advanced(VRPN_INCLUDE_DIR) +endif() - mark_as_advanced(VRPN_INCLUDE_DIR) - mark_as_advanced(VRPN_LIBRARY_DIR) - mark_as_advanced(VRPN_LIBRARY) +if(NOT VRPN_LIBRARY) + find_library(VRPN_LIBRARY + NAMES "vrpn") + + mark_as_advanced(VRPN_LIBRARY) endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(VRPN DEFAULT_MSG VRPN_LIBRARY VRPN_INCLUDE_DIR VRPN_LIBRARY_DIR) +find_package_handle_standard_args(VRPN DEFAULT_MSG VRPN_INCLUDE_DIR VRPN_LIBRARY) diff --git a/panda/CMakeLists.txt b/panda/CMakeLists.txt index afa730ed8e..bf75353f97 100644 --- a/panda/CMakeLists.txt +++ b/panda/CMakeLists.txt @@ -54,6 +54,7 @@ add_subdirectory(src/recorder) add_subdirectory(src/testbed) add_subdirectory(src/text) add_subdirectory(src/tform) +add_subdirectory(src/vrpn) add_subdirectory(src/wgldisplay) add_subdirectory(src/windisplay) add_subdirectory(src/x11display) @@ -108,4 +109,8 @@ if(HAVE_PYTHON) if(HAVE_ODE) add_python_module(ode p3ode IMPORT panda3d.core) endif() + + if(HAVE_VRPN) + add_python_module(vrpn p3vrpn IMPORT panda3d.core) + endif() endif() diff --git a/panda/src/vrpn/CMakeLists.txt b/panda/src/vrpn/CMakeLists.txt new file mode 100644 index 0000000000..e5c67d686b --- /dev/null +++ b/panda/src/vrpn/CMakeLists.txt @@ -0,0 +1,39 @@ +if(NOT HAVE_VRPN) + return() +endif() + +set(P3VRPN_HEADERS + config_vrpn.h + vrpnAnalogDevice.h vrpnAnalogDevice.I + vrpnAnalog.h vrpnAnalog.I + vrpnButtonDevice.h vrpnButtonDevice.I + vrpnButton.h vrpnButton.I + vrpnClient.h vrpnClient.I + vrpnDialDevice.h vrpnDialDevice.I + vrpnDial.h vrpnDial.I + vrpn_interface.h + vrpnTrackerDevice.h vrpnTrackerDevice.I + vrpnTracker.h vrpnTracker.I +) + +set(P3VRPN_SOURCES + config_vrpn.cxx + vrpnAnalog.cxx + vrpnAnalogDevice.cxx + vrpnButton.cxx + vrpnButtonDevice.cxx + vrpnClient.cxx + vrpnDial.cxx + vrpnDialDevice.cxx + vrpnTracker.cxx + vrpnTrackerDevice.cxx +) + +composite_sources(p3vrpn P3VRPN_SOURCES) +add_library(p3vrpn ${P3VRPN_HEADERS} ${P3VRPN_SOURCES}) +set_target_properties(p3vrpn PROPERTIES DEFINE_SYMBOL BUILDING_VRPN) +target_link_libraries(p3vrpn panda PKG::VRPN) +target_interrogate(p3vrpn ALL) + +install(TARGETS p3vrpn DESTINATION lib RUNTIME DESTINATION bin) +install(FILES ${P3VRPN_HEADERS} DESTINATION include/panda3d)