Skip to content

Commit

Permalink
Prefer pkg-config over CMake not to lose version checking
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Nov 29, 2021
1 parent 7e95d25 commit d46f7cc
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions cmake/FindIgnURDFDOM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,39 @@
# limitations under the License.
#

if (IgnURDFDOM_FIND_VERSION)
if(IgnURDFDOM_FIND_VERSION)
set(find_version VERSION ${IgnURDFDOM_FIND_VERSION})
else()
set(find_version "")
endif()
# NOTE: urdfdom cmake does not support version checking
ign_find_package(urdfdom ${find_version} QUIET)

if (urdfdom_FOUND)
add_library(IgnURDFDOM::IgnURDFDOM INTERFACE IMPORTED)
target_link_libraries(IgnURDFDOM::IgnURDFDOM
INTERFACE
urdfdom::urdfdom_model
urdfdom::urdfdom_world
urdfdom::urdfdom_sensor
urdfdom::urdfdom_model_state
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IgnURDFDOM DEFAULT_MSG)
else()
message(VERBOSE "unable to find urdf cmake package, trying pkgconfig...")
include(IgnPkgConfig)
# Prefer pkg-config over cmake if possible since version checking is not working
# on urdfdom series from 1.x to 3.0.0 (at least)
include(IgnPkgConfig)
if (NOT PKG_CONFIG_FOUND)
if (IgnURDFDOM_FIND_VERSION)
set(signature "urdfdom >= ${IgnURDFDOM_FIND_VERSION}")
else()
set(signature "urdfdom")
endif()
ign_pkg_check_modules(IgnURDFDOM "${signature}")
else()
message(VERBOSE "Unable to find pkg-config in the system, fallback to use CMake")
endif()

if(NOT IgnURDFDOM_FOUND)
# NOTE: urdfdom cmake does not support version checking
ign_find_package(urdfdom ${find_version} QUIET)
if (urdfdom_FOUND)
add_library(IgnURDFDOM::IgnURDFDOM INTERFACE IMPORTED)
target_link_libraries(IgnURDFDOM::IgnURDFDOM
INTERFACE
urdfdom::urdfdom_model
urdfdom::urdfdom_world
urdfdom::urdfdom_sensor
urdfdom::urdfdom_model_state
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IgnURDFDOM DEFAULT_MSG)
endif()
endif()

0 comments on commit d46f7cc

Please sign in to comment.