diff --git a/CMakeLists.txt b/CMakeLists.txt index a4c02cc5..7530fd2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ include(GNUInstallDirs) option(BUILD_APPS "Build applications" ON) option(BUILD_TESTING "Build tests" OFF) +option(USE_VENDORED_DEPS "Use vendored dependencies" ON) option(APPEND_PROJECT_NAME_TO_INCLUDEDIR "When ON headers are installed to a folder ending with an extra ${PROJECT_NAME}. \ This avoids include directory search order issues when overriding this package @@ -47,11 +48,13 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -find_package(tinyxml2_vendor QUIET) -find_package(TinyXML2 REQUIRED) - find_package(urdfdom_headers 1.0 REQUIRED) -find_package(console_bridge_vendor QUIET) # Provides console_bridge 0.4.0 on platforms without it. + +if(USE_VENDORED_DEPS) + find_package(tinyxml2_vendor QUIET) + find_package(console_bridge_vendor QUIET) # Provides console_bridge 0.4.0 on platforms without it. +endif() +find_package(TinyXML2 REQUIRED) find_package(console_bridge REQUIRED) # Control where libraries and executables are placed during the build diff --git a/cmake/urdfdom-config.cmake.in b/cmake/urdfdom-config.cmake.in index 25a76c21..ee018b1f 100644 --- a/cmake/urdfdom-config.cmake.in +++ b/cmake/urdfdom-config.cmake.in @@ -8,16 +8,16 @@ set(@PKG_NAME@_CONFIG_INCLUDED TRUE) set(CMAKE_MODULE_PATH_BACKUP_URDFDOM ${CMAKE_MODULE_PATH}) list(APPEND CMAKE_MODULE_PATH "${@PROJECT_NAME@_DIR}") -set(@PKG_NAME@_INCLUDE_DIRS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") +set(@PKG_NAME@_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@") foreach(lib @PKG_LIBRARIES@) set(onelib "${lib}-NOTFOUND") set(onelibd "${lib}-NOTFOUND") find_library(onelib ${lib} - PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" + PATHS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@" NO_DEFAULT_PATH) find_library(onelibd ${lib}d - PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" + PATHS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@" NO_DEFAULT_PATH) if(onelib-NOTFOUND AND onelibd-NOTFOUND) message(FATAL_ERROR "Library '${lib}' in package @PKG_NAME@ is not installed properly") @@ -36,17 +36,31 @@ foreach(lib @PKG_LIBRARIES@) endforeach() include(CMakeFindDependencyMacro) -find_dependency(tinyxml2_vendor QUIET) +if(@USE_VENDORED_DEPS@) + find_dependency(tinyxml2_vendor QUIET) + find_dependency(console_bridge_vendor QUIET) +else() + find_dependency(TinyXML2 REQUIRED) + find_dependency(console_bridge REQUIRED) +endif() foreach(dep @PKG_DEPENDS@) if(NOT ${dep}_FOUND) find_dependency(${dep}) endif() - list(APPEND @PKG_NAME@_INCLUDE_DIRS ${${dep}_INCLUDE_DIRS}) - list(APPEND @PKG_NAME@_LIBRARIES ${${dep}_LIBRARIES}) endforeach() +if(NOT TARGET urdfdom_headers::urdfdom_headers) + add_library(urdfdom_headers::urdfdom_headers INTERFACE IMPORTED) + set_target_properties(urdfdom_headers::urdfdom_headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${urdfdom_headers_INCLUDE_DIRS}" + ) +endif() +list(APPEND @PKG_NAME@_INCLUDE_DIRS "${urdfdom_headers_INCLUDE_DIRS}") + foreach(exp @PKG_EXPORTS@) include(${@PROJECT_NAME@_DIR}/${exp}Export.cmake) endforeach() +set(@PKG_NAME@_LIBRARIES ${@PKG_NAME@_TARGETS}) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_BACKUP_URDFDOM})