From 7375d094e2e3b2b382fbf63258a3e6adbefe3eac Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 6 Jun 2020 14:02:44 +0300 Subject: [PATCH] Cmake for pylon --- CMakeLists.txt | 5 ++ cmake/FindPylon.cmake | 47 +++++++++++++++++++ components/common/cpp/include/ftl/config.h.in | 1 + 3 files changed, 53 insertions(+) create mode 100644 cmake/FindPylon.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 90be9db69..446407f04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ include(GNUInstallDirs) include(CTest) enable_testing() +option(WITH_PYLON "Use Pylon for Basler cameras" ON) option(WITH_OPTFLOW "Use NVIDIA Optical Flow if available" OFF) option(WITH_OPENVR "Build with OpenVR support" OFF) option(WITH_OPUS "Use Opus audio compression" ON) @@ -48,6 +49,10 @@ find_package( URIParser REQUIRED ) find_package( MsgPack REQUIRED ) find_package( Eigen3 REQUIRED ) +if (WITH_PYLON) + find_package( Pylon ) +endif() + VERSION_STR_TO_INTS(OPENCV_MAJOR OPENCV_MINOR OPENCV_PATCH ${OpenCV_VERSION}) math(EXPR OPENCV_NUMBER "(${OPENCV_MAJOR} * 10000) + (${OPENCV_MINOR} * 100) + ${OPENCV_PATCH}") diff --git a/cmake/FindPylon.cmake b/cmake/FindPylon.cmake new file mode 100644 index 000000000..ea13d339f --- /dev/null +++ b/cmake/FindPylon.cmake @@ -0,0 +1,47 @@ +############################################################################### +# Find Pylon +# + +set(PYLON_FOUND FALSE CACHE BOOL "" FORCE) + +if(WIN32) +find_path(PYLON_DIR NAMES include/pylon/PylonBase.h PATHS "C:/Program Files/Pylon" "C:/Program Files (x86)/Pylon") +else() +find_path(PYLON_DIR NAMES include/pylon/PylonBase.h PATHS "/opt/pylon" "/opt/pylon6") +endif() + +if (PYLON_DIR) + set(PYLON_FOUND TRUE CACHE BOOL "" FORCE) + set(HAVE_PYLON TRUE) + # Find lib dir + + # Find include + find_path(PYLON_LIBRARY_DIRS + NAMES libpylonbase.so + PATHS ${PYLON_DIR} + PATH_SUFFIXES lib + ) + + # Find include + find_path(PYLON_INCLUDE_DIRS + NAMES pylon/PylonBase.h + PATHS ${PYLON_DIR} + PATH_SUFFIXES include + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Pylon DEFAULT_MSG PYLON_DIR) + + mark_as_advanced(PYLON_FOUND) + mark_as_advanced(PYLON_INCLUDE_DIRS) + mark_as_advanced(PYLON_LIBRARY_DIRS) + + list(APPEND PYLON_LIBRARIES pylonbase pylonutility GenApi_gcc_v3_1_Basler_pylon GCBase_gcc_v3_1_Basler_pylon) + + add_library(Pylon UNKNOWN IMPORTED) + set_property(TARGET Pylon PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYLON_INCLUDE_DIRS}) + set_property(TARGET Pylon PROPERTY INTERFACE_LINK_DIRECTORIES ${PYLON_INCLUDE_DIRS}) + set_property(TARGET Pylon PROPERTY INTERFACE_LINK_LIBRARIES ${PYLON_LIBRARIES}) +else() + add_library(Pylon INTERFACE) +endif() diff --git a/components/common/cpp/include/ftl/config.h.in b/components/common/cpp/include/ftl/config.h.in index bb58bc207..99db4ca42 100644 --- a/components/common/cpp/include/ftl/config.h.in +++ b/components/common/cpp/include/ftl/config.h.in @@ -28,6 +28,7 @@ #cmakedefine HAVE_PORTAUDIO #cmakedefine HAVE_X11 #cmakedefine HAVE_OPUS +#cmakedefine HAVE_PYLON #cmakedefine ENABLE_PROFILER -- GitLab