Skip to content

Commit

Permalink
(#22892) urdfdom: add v4.0.0
Browse files Browse the repository at this point in the history
* urdfdom: add v4.0.0

* urdfdom: set CMP0077
  • Loading branch information
Martin Valgur authored Feb 27, 2024
1 parent 5f0d204 commit 4bc06cf
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 52 deletions.
22 changes: 18 additions & 4 deletions recipes/urdfdom/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
sources:
"4.0.0":
urdfdom:
url: "https://github.com/ros/urdfdom/archive/refs/tags/4.0.0.tar.gz"
sha256: "9848d106dc88dc0b907d5667c09da3ca53241fbcf17e982d8c234fe3e0d6ddcc"
urdfdom_headers:
url: "https://github.com/ros/urdfdom_headers/archive/refs/tags/1.1.1.zip"
sha256: "dde77e3dd96ffa41e2ee0a20bddcd6ef05863e95ce0143ede77130d8cd46c644"
"3.1.1":
urdfdom:
url: "https://github.com/ros/urdfdom/archive/refs/tags/3.1.1.tar.gz"
Expand All @@ -10,13 +17,20 @@ sources:
url: "https://github.com/ros/urdfdom_headers/archive/1fd21b64ed78493508a174f98af982605d1e4607.zip"
sha256: "aba42c1c83d6d1fb94e54ec84680a8b9e2417337fbaa85424da0e069d0cc89b6"
patches:
"4.0.0":
- patch_file: "patches/4.0.0/001-optional-build-apps.patch"
patch_type: "conan"
patch_description: "Disable building of apps by default"
- patch_file: "patches/4.0.0/002-use-conan-dependencies.patch"
patch_type: "conan"
patch_description: "Use dependencies from Conan, use merged urdfdom_headers"
"3.1.1":
- patch_file: "patches/001-optional-build-apps.patch"
- patch_file: "patches/3.1.1/001-optional-build-apps.patch"
patch_type: "conan"
patch_description: "Disable building of apps by default"
- patch_file: "patches/002-use-conan-dependencies.patch"
- patch_file: "patches/3.1.1/002-use-conan-dependencies.patch"
patch_type: "conan"
patch_description: "Use dependencies (console_bridge, TinyXML, GTest) from Conan"
- patch_file: "patches/003-use-merged-urdfdom_headers.patch"
patch_description: "Use dependencies (console_bridge, TinyXML) from Conan"
- patch_file: "patches/3.1.1/003-use-merged-urdfdom_headers.patch"
patch_type: "conan"
patch_description: "Use merged urdfdom_headers instead of a separate package"
16 changes: 12 additions & 4 deletions recipes/urdfdom/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
from conan.tools.scm import Version

required_conan_version = ">=1.53.0"

Expand Down Expand Up @@ -45,7 +46,10 @@ def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("tinyxml/2.6.2", transitive_headers=True)
if Version(self.version) >= "4.0":
self.requires("tinyxml2/10.0.0", transitive_headers=True, transitive_libs=True)
else:
self.requires("tinyxml/2.6.2", transitive_headers=True, transitive_libs=True)
self.requires("console_bridge/1.0.2")

def validate(self):
Expand All @@ -68,6 +72,8 @@ def generate(self):
tc.variables["BUILD_APPS"] = False
if not self.options.shared:
tc.preprocessor_definitions["URDFDOM_STATIC"] = "1"
# Need to set CMP0077 because CMake policy version is too old (3.5 as of v4.0.0)
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
CMakeDeps(self).generate()

Expand All @@ -84,11 +90,13 @@ def build(self):
cmake.build()

def package(self):
copy(self, "LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
# Copy urdfdom_headers
copy(self, "*",
src=os.path.join(self.source_folder, "urdf_parser", "include"),
dst=os.path.join(self.package_folder, "include"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "urdfdom"))
rmdir(self, os.path.join(self.package_folder, "CMake"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,3 @@ diff --git a/urdf_parser/CMakeLists.txt b/urdf_parser/CMakeLists.txt
target_compile_features(${add_urdfdom_library_LIBNAME} PUBLIC cxx_std_14)
endif()

diff --git a/urdf_parser/test/CMakeLists.txt b/urdf_parser/test/CMakeLists.txt
--- a/urdf_parser/test/CMakeLists.txt (revision 1ed7ca95b917f38feb4ff7bd1aa033baf2cfce0e)
+++ b/urdf_parser/test/CMakeLists.txt (revision 6592c04e28cb59b8e9ac5944e3229c50d706a2ee)
@@ -1,18 +1,8 @@
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/gtest/include
- ${CMAKE_CURRENT_SOURCE_DIR}/gtest
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-# Build gtest
-add_library(gtest STATIC gtest/src/gtest-all.cc)
-add_library(gtest_main STATIC gtest/src/gtest_main.cc)
-target_link_libraries(gtest_main gtest)
-target_compile_features(gtest PUBLIC cxx_std_11)
-
execute_process(COMMAND cmake -E remove_directory ${CMAKE_BINARY_DIR}/test_results)
execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results)

+find_package(GTest REQUIRED)
+
# unit test to fix geometry problems
set(tests
urdf_double_convert.cpp
@@ -27,8 +17,8 @@
add_executable(${BINARY_NAME} ${GTEST_SOURCE_file})

target_link_libraries(${BINARY_NAME}
- gtest_main
- gtest
+ GTest::gtest
+ GTest::gtest_main
urdfdom_model
)
if (UNIX)
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt

# Control where libraries and executables are placed during the build

diff --git a/urdf_parser/CMakeLists.txt b/urdf_parser/CMakeLists.txt
--- a/urdf_parser/CMakeLists.txt (revision 82fb54588f3ba5091d9a73d072559ac7061eccdf)
+++ b/urdf_parser/CMakeLists.txt (revision 1de2b88f231fa0f7f83a028e971d4ebaed1b164c)
@@ -135,4 +135,4 @@
FILE "urdfdomExport.cmake"
)

-INSTALL(DIRECTORY include/urdf_parser DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+INSTALL(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
34 changes: 34 additions & 0 deletions recipes/urdfdom/all/patches/4.0.0/001-optional-build-apps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- urdf_parser/CMakeLists.txt
+++ urdf_parser/CMakeLists.txt
@@ -81,6 +81,7 @@

# --------------------------------

+if(BUILD_APPS)
add_executable(check_urdf src/check_urdf.cpp)
target_include_directories(check_urdf PUBLIC include)
target_link_libraries(check_urdf urdfdom_model urdfdom_world)
@@ -97,6 +98,7 @@
add_executable(urdf_mem_test test/memtest.cpp)
target_include_directories(urdf_mem_test PUBLIC include)
target_link_libraries(urdf_mem_test urdfdom_model)
+endif()

include(CTest)
if(BUILD_TESTING)
@@ -104,6 +106,7 @@
add_subdirectory(test)
endif()

+if(BUILD_APPS)
INSTALL(
TARGETS
check_urdf
@@ -114,6 +117,7 @@
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+endif()
INSTALL(
TARGETS
urdfdom_model
14 changes: 14 additions & 0 deletions recipes/urdfdom/all/patches/4.0.0/002-use-conan-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -45,11 +45,8 @@

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.
find_package(console_bridge REQUIRED)

# Control where libraries and executables are placed during the build
2 changes: 2 additions & 0 deletions recipes/urdfdom/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"4.0.0":
folder: all
"3.1.1":
folder: all

0 comments on commit 4bc06cf

Please sign in to comment.