From 6bd5472fd68ca3b411662efbd9cf062c32bd3eac Mon Sep 17 00:00:00 2001 From: William Woodall Date: Thu, 30 Apr 2020 11:54:26 -0700 Subject: [PATCH 1/4] terrible hack to suppress cmake warning Signed-off-by: William Woodall --- rviz_assimp_vendor/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/rviz_assimp_vendor/CMakeLists.txt b/rviz_assimp_vendor/CMakeLists.txt index 4eebc55c4..ff5b1c605 100644 --- a/rviz_assimp_vendor/CMakeLists.txt +++ b/rviz_assimp_vendor/CMakeLists.txt @@ -52,6 +52,47 @@ macro(build_assimp) ) endmacro() +# Copy and fix the assimp config files on Ubuntu, in order to suppress a warning. +# This should be removed once upstream is updated to assimp-0.5.1, see: +# https://github.com/ros2/rviz/issues/524 +# https://bugs.launchpad.net/ubuntu/+source/assimp/+bug/1869405 +### BEGIN HACKS +set(IS_UBUNTU FALSE) +if(UNIX AND NOT APPLE) + find_program(LSB_RELEASE_EXEC lsb_release) + execute_process(COMMAND ${LSB_RELEASE_EXEC} -is + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(${LSB_RELEASE_ID_SHORT} STREQUAL "Ubuntu") + set(IS_UBUNTU TRUE) + endif() +endif() +if(IS_UBUNTU) + file(READ "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimpTargets.cmake" assimp_targets_content) + string(REPLACE + "if(ON)" + "set(WORKAROUND ON)\nif(WORKAROUND)" + assimp_targets_content + ${assimp_targets_content}) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5/assimpTargets.cmake" "${assimp_targets_content}") + file(READ "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimpTargets-release.cmake" assimp_targets_content) + string(REPLACE + "if(ON)" + "set(WORKAROUND ON)\nif(WORKAROUND)" + assimp_targets_content + ${assimp_targets_content}) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5/assimpTargets-release.cmake" "${assimp_targets_content}") + file( + COPY "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimp-config.cmake" + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") + file( + COPY "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimp-config-version.cmake" + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") + set(assimp_DIR "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") +endif() +### END HACKS find_package(assimp QUIET) if(NOT assimp_FOUND OR "${assimp_VERSION}" VERSION_LESS 4.1.0) From a37cda581ae4d4ddc2c0b3088c39f6f0fe19313f Mon Sep 17 00:00:00 2001 From: William Woodall Date: Thu, 30 Apr 2020 12:31:13 -0700 Subject: [PATCH 2/4] adjust terrible hack to account for different architectures Signed-off-by: William Woodall --- rviz_assimp_vendor/CMakeLists.txt | 44 ++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/rviz_assimp_vendor/CMakeLists.txt b/rviz_assimp_vendor/CMakeLists.txt index ff5b1c605..3c0e771cb 100644 --- a/rviz_assimp_vendor/CMakeLists.txt +++ b/rviz_assimp_vendor/CMakeLists.txt @@ -60,37 +60,55 @@ endmacro() set(IS_UBUNTU FALSE) if(UNIX AND NOT APPLE) find_program(LSB_RELEASE_EXEC lsb_release) - execute_process(COMMAND ${LSB_RELEASE_EXEC} -is - OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) + if(EXISTS LSB_RELEASE_EXEC) + execute_process(COMMAND ${LSB_RELEASE_EXEC} -is + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + else() + set(LSB_RELEASE_ID_SHORT "Unknown") + endif() if(${LSB_RELEASE_ID_SHORT} STREQUAL "Ubuntu") set(IS_UBUNTU TRUE) endif() endif() + if(IS_UBUNTU) - file(READ "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimpTargets.cmake" assimp_targets_content) + file(GLOB_RECURSE assimp_target_files "/usr/lib/*/cmake/assimp-5.0/assimpTargets.cmake") + list(LENGTH assimp_target_files assimp_target_files_len) + if(assimp_target_files_len EQUAL 0) + message(FATAL_ERROR "failed to find assimpTargets.cmake as expected") + endif() + if(NOT assimp_target_files_len EQUAL 1) + message(FATAL_ERROR "found multiple assimpTargets.cmake files, unexpectedly") + endif() + list(GET assimp_target_files 0 assimp_target_file) + + get_filename_component(assimp_target_dir "${assimp_target_file}" DIRECTORY) + set(new_assimp_target_dir "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") + + file(READ "${assimp_target_dir}/assimpTargets.cmake" assimp_targets_content) string(REPLACE "if(ON)" "set(WORKAROUND ON)\nif(WORKAROUND)" assimp_targets_content ${assimp_targets_content}) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5/assimpTargets.cmake" "${assimp_targets_content}") - file(READ "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimpTargets-release.cmake" assimp_targets_content) + file(WRITE "${new_assimp_target_dir}/assimpTargets.cmake" "${assimp_targets_content}") + file(READ "${assimp_target_dir}/assimpTargets-release.cmake" assimp_targets_content) string(REPLACE "if(ON)" "set(WORKAROUND ON)\nif(WORKAROUND)" assimp_targets_content ${assimp_targets_content}) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5/assimpTargets-release.cmake" "${assimp_targets_content}") + file(WRITE "${new_assimp_target_dir}/assimpTargets-release.cmake" "${assimp_targets_content}") file( - COPY "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimp-config.cmake" - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") + COPY "${assimp_target_dir}/assimp-config.cmake" + DESTINATION "${new_assimp_target_dir}") file( - COPY "/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimp-config-version.cmake" - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") - set(assimp_DIR "${CMAKE_CURRENT_BINARY_DIR}/assimp-0.5") + COPY "${assimp_target_dir}/assimp-config-version.cmake" + DESTINATION "${new_assimp_target_dir}") + set(assimp_DIR "${new_assimp_target_dir}") endif() ### END HACKS find_package(assimp QUIET) From ff8f8e93998b44fe9b938ad7fb0c4948784c3e0d Mon Sep 17 00:00:00 2001 From: William Woodall Date: Thu, 30 Apr 2020 12:41:31 -0700 Subject: [PATCH 3/4] fixup Signed-off-by: William Woodall --- rviz_assimp_vendor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rviz_assimp_vendor/CMakeLists.txt b/rviz_assimp_vendor/CMakeLists.txt index 3c0e771cb..7d39d88ae 100644 --- a/rviz_assimp_vendor/CMakeLists.txt +++ b/rviz_assimp_vendor/CMakeLists.txt @@ -60,7 +60,7 @@ endmacro() set(IS_UBUNTU FALSE) if(UNIX AND NOT APPLE) find_program(LSB_RELEASE_EXEC lsb_release) - if(EXISTS LSB_RELEASE_EXEC) + if(EXISTS "${LSB_RELEASE_EXEC}") execute_process(COMMAND ${LSB_RELEASE_EXEC} -is OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE From b7dd0e4e7a23bcad633985be1d709e5fa1ca5a45 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Fri, 1 May 2020 16:43:33 -0700 Subject: [PATCH 4/4] extend hack to packages which find package rviz_assimp_vendor Signed-off-by: William Woodall --- rviz_assimp_vendor/CMakeLists.txt | 7 +++++ .../rviz_assimp_vendor-extras.cmake.in | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/rviz_assimp_vendor/CMakeLists.txt b/rviz_assimp_vendor/CMakeLists.txt index 7d39d88ae..47c066b4e 100644 --- a/rviz_assimp_vendor/CMakeLists.txt +++ b/rviz_assimp_vendor/CMakeLists.txt @@ -109,6 +109,13 @@ if(IS_UBUNTU) COPY "${assimp_target_dir}/assimp-config-version.cmake" DESTINATION "${new_assimp_target_dir}") set(assimp_DIR "${new_assimp_target_dir}") + + install( + DIRECTORY + ${new_assimp_target_dir}/ + DESTINATION + ${CMAKE_INSTALL_PREFIX}/opt/rviz_assimp_vendor_custom_config + ) endif() ### END HACKS find_package(assimp QUIET) diff --git a/rviz_assimp_vendor/rviz_assimp_vendor-extras.cmake.in b/rviz_assimp_vendor/rviz_assimp_vendor-extras.cmake.in index 8f8133d4f..971971563 100644 --- a/rviz_assimp_vendor/rviz_assimp_vendor-extras.cmake.in +++ b/rviz_assimp_vendor/rviz_assimp_vendor-extras.cmake.in @@ -1,3 +1,30 @@ +# Use custom CMake config files for assimp on Ubuntu to work around a cmake warning. +# This should be removed once upstream is updated to assimp-0.5.1, see: +# https://github.com/ros2/rviz/issues/524 +# https://bugs.launchpad.net/ubuntu/+source/assimp/+bug/1869405 +### BEGIN HACKS +set(IS_UBUNTU FALSE) +if(UNIX AND NOT APPLE) + find_program(LSB_RELEASE_EXEC lsb_release) + if(EXISTS "${LSB_RELEASE_EXEC}") + execute_process(COMMAND ${LSB_RELEASE_EXEC} -is + OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + else() + set(LSB_RELEASE_ID_SHORT "Unknown") + endif() + + if(${LSB_RELEASE_ID_SHORT} STREQUAL "Ubuntu") + set(IS_UBUNTU TRUE) + endif() +endif() + +if(IS_UBUNTU) + set(assimp_DIR "${@PROJECT_NAME@_DIR}/../../../opt/rviz_assimp_vendor_custom_config") +endif() +### END HACKS + find_package(assimp QUIET) if(NOT assimp_FOUND OR "${assimp_VERSION}" VERSION_LESS 4.1.0)