Skip to content

Commit

Permalink
terrible hack to suppress cmake warning (#534)
Browse files Browse the repository at this point in the history
* terrible hack to suppress cmake warning

Signed-off-by: William Woodall <william@osrfoundation.org>

* adjust terrible hack to account for different architectures

Signed-off-by: William Woodall <william@osrfoundation.org>

* fixup

Signed-off-by: William Woodall <william@osrfoundation.org>

* extend hack to packages which find package rviz_assimp_vendor

Signed-off-by: William Woodall <william@osrfoundation.org>
  • Loading branch information
wjwwood authored May 2, 2020
1 parent 2bb3f2a commit 9c69077
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
66 changes: 66 additions & 0 deletions rviz_assimp_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,72 @@ 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)
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(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 "${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 "${new_assimp_target_dir}/assimpTargets-release.cmake" "${assimp_targets_content}")
file(
COPY "${assimp_target_dir}/assimp-config.cmake"
DESTINATION "${new_assimp_target_dir}")
file(
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)

if(NOT assimp_FOUND OR "${assimp_VERSION}" VERSION_LESS 4.1.0)
Expand Down
27 changes: 27 additions & 0 deletions rviz_assimp_vendor/rviz_assimp_vendor-extras.cmake.in
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 9c69077

Please sign in to comment.