Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terrible hack to suppress cmake warning #534

Merged
merged 4 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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