Skip to content

Commit

Permalink
Fix checking Package_FOUND variables (WPI-AIM#189)
Browse files Browse the repository at this point in the history
If a package was *not* found, Package_FOUND will not be set
so checking it's value will cause cmake to return an error.
Instead we just check if the variable exists.

I used the regex \${([\w-]+_FOUND)} to search/replace.
  • Loading branch information
kschwan authored Jan 10, 2023
1 parent 3a06b2f commit de003b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ include_directories (${OPENGL_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})

find_package(yaml-cpp QUIET)
if (NOT ${yaml-cpp_FOUND})
if (NOT yaml-cpp_FOUND)
message(STATUS "-- *** YAML-CPP NOT FOUND, ADDING IT AS AN EXTERNAL PROJECT")
include(cmake/ExternalYamlCpp.cmake)
endif()
Expand All @@ -119,7 +119,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
find_package(catkin COMPONENTS
roscpp
)
if (${catkin_FOUND})
if (catkin_FOUND)
message("-- *** FOUND ROS ON THIS MACHINE, ENABLING SUPPORT FOR AMBF_ROS MODULES")
add_subdirectory(${PROJECT_SOURCE_DIR}/ambf_ros_modules)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/tf_function)
Expand All @@ -128,7 +128,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
find_package(catkin QUIET COMPONENTS ambf_server ambf_msgs dvrk_arm razer_hydra cv_bridge image_transport ambf_client)
find_package(tf_function REQUIRED)

if(${ambf_server_FOUND} AND ${ambf_msgs_FOUND} AND ${dvrk_arm_FOUND} AND ${ambf_client_FOUND})
if(ambf_server_FOUND AND ambf_msgs_FOUND AND dvrk_arm_FOUND AND ambf_client_FOUND)
message(STATUS "-- *** FOUND AMBF_COMM, AMBF_MSGS, AMBF_CLIENT and DVRK_ARM, ENABLING DVRK DEVICE SUPPORT")

set(AMBF_ROS_INCLUDE_DIRS ${AMBF_ROS_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
Expand All @@ -142,9 +142,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
endif()

find_package(OpenCV QUIET)
if(${OpenCV_FOUND})
if(OpenCV_FOUND)
message(STATUS "-- *** FOUND OPENCV")
if(${cv_bridge_FOUND} AND ${image_transport_FOUND})
if(cv_bridge_FOUND AND image_transport_FOUND)
message(STATUS "-- *** FOUND ROS_CV_BRIDGE and IMAGE_TRANSPORT, ENABLING VIDEO PUBLISHING SUPPORT")

list(APPEND AMBF_DEFINITIONS -DAF_ENABLE_OPEN_CV_SUPPORT)
Expand All @@ -155,7 +155,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
endif()
endif()

if (${razer_hydra_FOUND})
if (razer_hydra_FOUND)
message(STATUS "-- *** FOUND RAZER HYDRA'S ROS PACKAGE, ENABLING DEVICE SUPPORT")

set(AMBF_ROS_INCLUDE_DIRS ${AMBF_ROS_INCLUDE_DIRS} ${razer_hydra_INCLUDE_DIRS})
Expand Down Expand Up @@ -318,7 +318,7 @@ list(APPEND COMMON_DEFINITIONS -DGLEW_STATIC)
# static library
add_library (adf_loader ${source_adf_loader})

if(NOT ${yaml-cpp_FOUND})
if(NOT yaml-cpp_FOUND)
add_dependencies(adf_loader YAML_CPP_EXTERNAL_PROJECT)
endif()

Expand Down Expand Up @@ -347,7 +347,7 @@ target_link_libraries(ambf_framework ${chai3d} ${bullet} ${Boost_LIBRARIES})

# To ensure the ambf_ros_modules are build before the ambf_framework,
# add catkin's targets as build dependency
if (${catkin_FOUND})
if (catkin_FOUND)
add_dependencies(ambf_framework ${catkin_EXPORTED_TARGETS})
endif()

Expand Down Expand Up @@ -400,7 +400,7 @@ add_subdirectory (${PROJECT_SOURCE_DIR}/ambf_simulator)

# AMBF Controller. Add if on Linux, Catkin Found and ambf_server Found
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
if (${catkin_FOUND} AND ${ambf_server_FOUND})
if (catkin_FOUND AND ambf_server_FOUND)
add_subdirectory (${PROJECT_SOURCE_DIR}/ambf_controller)
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions adf_loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

find_package(yaml-cpp QUIET)

if (NOT ${yaml-cpp_FOUND})
if (NOT yaml-cpp_FOUND)
message("-- *** YAML-CPP NOT FOUND, ADDING IT AS AN EXTERNAL PROJECT")
include(../cmake/ExternalYamlCpp.cmake)
endif()
Expand All @@ -50,7 +50,7 @@ file (GLOB_RECURSE source_adf_loader *.cpp *.h)

add_library(adf_loader ${source_adf_loader})

if(NOT ${yaml-cpp_FOUND})
if(NOT yaml-cpp_FOUND)
add_dependencies(adf_loader YAML_CPP_EXTERNAL_PROJECT)
endif()

Expand Down
4 changes: 2 additions & 2 deletions external/chai3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
dvrk_arm
chai_env
)
if (${chai_env_FOUND})
if (chai_env_FOUND)
message("-- ***FOUND CHAI ENV SUPPORT")
add_definitions(-DC_ENABLE_AMBF_DVRK_DEVICE_SUPPORT)
set (CHAI3D_DEFINITIONS -DC_ENABLE_AMBF_DVRK_DEVICE_SUPPORT)
endif()
find_package(razer_hydra)
if (${razer_hydra_FOUND})
if (razer_hydra_FOUND)
message("-- ***Found Razer Hydra")
add_definitions(-DC_ENABLE_RAZER_HYDRA_DEVICE_SUPPORT)
set(catkin_INCLUDE_DIRS ${catkin_INCLUDE_DIRS} ${razer_hydra_INCLUDE_DIRS})
Expand Down

0 comments on commit de003b4

Please sign in to comment.