Skip to content

assimp-config.cmake sets incorrect ASSIMP_ROOT_DIR when library path is deeply nested. #1914

@nuclearsandwich

Description

@nuclearsandwich

This may or may not prove related to #1912 but when ASSIMP_LIB_INSTALL_DIR contains more than one directory level the logic below isn't sufficient to find the root directory producing a broken CMake configuration.

get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_PREFIX "${_PREFIX}" PATH)
get_filename_component(_PREFIX "${_PREFIX}" PATH)
get_filename_component(ASSIMP_ROOT_DIR "${_PREFIX}" PATH)

This affects the libassimp-dev package on Debian Stretch, Buster, and Sid and Ubuntu Artful and Bionic. Verifiable on these platforms with the following example CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)
project(asitest)

find_package(assimp)

message(STATUS "ASSIMP_ROOT_DIR: ${ASSIMP_ROOT_DIR}")
message(STATUS "ASSIMP_LIBRARY_DIRS: ${ASSIMP_LIBRARY_DIRS}")
message(STATUS "ASSIMP_INCLUDE_DIRS: ${ASSIMP_INCLUDE_DIRS}")

Selected output from above CMakeLists.txt:

...
-- ASSIMP_ROOT_DIR: /usr/lib
-- ASSIMP_LIBRARY_DIRS: /usr/lib/lib/x86_64-linux-gnu
-- ASSIMP_INCLUDE_DIRS: /usr/lib/include
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    BuildGlobal flag to mark build relates topics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions