Skip to content

Commit d3f7d23

Browse files
authored
Updating package search (#99)
* Updating package search * Removing pkg_check_modules call
1 parent c3331a7 commit d3f7d23

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

gpsd_client/CMakeLists.txt

+19-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,25 @@ find_package(rclcpp REQUIRED)
1010
find_package(rclcpp_components REQUIRED)
1111
find_package(sensor_msgs REQUIRED)
1212

13-
find_package(PkgConfig REQUIRED)
14-
pkg_check_modules (libgps REQUIRED libgps)
13+
# Try to find libgps, first with CMake's usual library search method, then by
14+
# querying pkg-config.
15+
find_library(libgps_LIBRARIES NAMES gps)
16+
find_path(libgps_INCLUDE_DIRS NAMES libgpsmm.h gps.h)
17+
18+
if(NOT libgps_LIBRARIES)
19+
message(STATUS "Checking pkg-config for libgps")
20+
find_package(PkgConfig)
21+
if(PkgConfig_FOUND)
22+
pkg_check_modules(libgps libgps)
23+
endif()
24+
endif()
25+
26+
if(NOT libgps_LIBRARIES)
27+
message(FATAL_ERROR "Could not find libgps "
28+
"(hint for Debian/Ubuntu: apt install libgps-dev)")
29+
else()
30+
message(STATUS "Found libgps: ${libgps_LIBRARIES}")
31+
endif()
1532

1633
add_library(${PROJECT_NAME} SHARED
1734
src/client.cpp

0 commit comments

Comments
 (0)