Skip to content

Commit

Permalink
Merge pull request #114 from neufieldrobotics/hotfix/spinnaker_cmake
Browse files Browse the repository at this point in the history
added cmake file to detect and find spinnaker library
  • Loading branch information
Vikrant Shah authored Feb 2, 2021
2 parents 2f9f14d + 3aec36d commit 4977ee8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
###
#SET("OpenCV_DIR" "~/apps/opencv-2.4.13/")
set(PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include" CACHE PATH "Project Include Directory")
set(SPINNAKER_INCLUDE_DIR "/usr/include/spinnaker" CACHE PATH "Spinnaker Include Directory")
set(SPINNAKER_LIB_DIR "/usr/lib" CACHE PATH "Spinnaker Libs Directory")
#set(SPINNAKER_INCLUDE_DIR "/usr/include/spinnaker" CACHE PATH "Spinnaker Include Directory")
#set(SPINNAKER_LIB_DIR "/usr/lib" CACHE PATH "Spinnaker Libs Directory")
# set(yaml-cpp_DIR "~/apps/yaml-cpp" CACHE PATH "yaml-cpp Directory")
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

Expand All @@ -32,6 +32,8 @@ find_package(catkin REQUIRED COMPONENTS
# Acquisition specific
###
# Find Packages
find_package(Spinnaker REQUIRED)
message("spinnaker lib : " ${Spinnaker_LIBRARIES})
find_package(OpenCV REQUIRED)
# use LibUnwind only for x86_64 or x86_32 architecture
# do not use LibUnwind for arm architecture
Expand Down Expand Up @@ -76,15 +78,15 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64 OR x86_32)
include_directories(
${PROJECT_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
SYSTEM ${SPINNAKER_INCLUDE_DIR}
SYSTEM ${Spinnaker_INCLUDE_DIRS}
SYSTEM ${OpenCV_INCLUDE_DIRS}
SYSTEM ${Boost_INCLUDE_DIR}
${LibUnwind_INCLUDE_DIRS}
)

link_directories( ${SPINNAKER_LIB_DIR} )
link_directories( ${Spinnaker_LIBRARIES} )

set (LIBS ${LibUnwind_LIBRARIES} Spinnaker ${OpenCV_LIBS} ${Boost_GENERAL})
set (LIBS ${LibUnwind_LIBRARIES} ${Spinnaker_LIBRARIES} ${OpenCV_LIBS} ${Boost_GENERAL})

endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64 OR x86_32)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES aarch64 OR arm)
Expand All @@ -97,14 +99,14 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES aarch64 OR arm)
include_directories(
${PROJECT_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
SYSTEM ${SPINNAKER_INCLUDE_DIR}
SYSTEM ${Spinnaker_INCLUDE_DIRS}
SYSTEM ${OpenCV_INCLUDE_DIRS}
SYSTEM ${Boost_INCLUDE_DIR}
)

link_directories( ${SPINNAKER_LIB_DIR} )
link_directories( ${Spinnaker_LIBRARIES} )

set (LIBS Spinnaker ${OpenCV_LIBS} ${Boost_GENERAL})
set (LIBS ${Spinnaker_LIBRARIES} ${OpenCV_LIBS} ${Boost_GENERAL})

endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES aarch64 OR arm)

Expand Down
42 changes: 42 additions & 0 deletions cmake/FindSpinnaker.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Find the Spinnaker library
#
# Spinnaker_FOUND - True if Spinnaker was found.
# Spinnaker_LIBRARIES - The libraries needed to use Spinnaker
# Spinnaker_INCLUDE_DIRS - Location of Spinnaker.h

unset(Spinnaker_FOUND)
unset(Spinnaker_INCLUDE_DIRS)
unset(Spinnaker_LIBRARIES)

find_path(Spinnaker_INCLUDE_DIRS NAMES
Spinnaker.h
PATHS
/opt/spinnaker/include
)
find_library(Spinnaker_LIBRARIES NAMES Spinnaker
PATHS
/opt/spinnaker/lib
)

if(NOT Spinnaker_INCLUDE_DIRS OR NOT Spinnaker_LIBRARIES)
message(STATUS "Couldnt find Spinnaker 2.2.x. Checking lower versions")
find_path(Spinnaker_INCLUDE_DIRS NAMES
Spinnaker.h
PATHS
/usr/include/spinnaker/
/usr/local/include/spinnaker/
)
find_library(Spinnaker_LIBRARIES NAMES Spinnaker
PATHS
/usr/lib
/usr/local/lib
)
if(NOT Spinnaker_INCLUDE_DIRS OR NOT Spinnaker_LIBRARIES)
message(STATUS "Couldnt find Spinnaker.")
endif()
endif()

if (Spinnaker_INCLUDE_DIRS AND Spinnaker_LIBRARIES)
message(STATUS "Spinnaker found in the system")
set(Spinnaker_FOUND 1)
endif (Spinnaker_INCLUDE_DIRS AND Spinnaker_LIBRARIES)

0 comments on commit 4977ee8

Please sign in to comment.