RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
982 stars 178 forks source link

OSPRay determining wrong installation dir when `/lib64` is a symlink to `/usr/lib` #511

Open blurgyy opened 2 years ago

blurgyy commented 2 years ago

Hi, when I try to build pcl on Arch Linux, OSPRay dumps an error message saying:

CMake Error at /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:26 (message):
  Failed to find OSPRay - OSPRay install root: /, determined from relative
  path from osprayConfg.cmake install location: /lib64/cmake/ospray-2.8.0,
  does not contain OSPRay headers.  Either the install directory was deleted,
  or the install tree was only partially relocated outside of CMake after
  OSPRay was built.
Call Stack (most recent call first):
  /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:69 (ospray_report_not_found)
  /lib64/cmake/vtk/VTK-vtk-module-find-packages.cmake:209 (find_package)
  /lib64/cmake/vtk/vtk-config.cmake:150 (include)
  cmake/pcl_find_vtk.cmake:25 (find_package)
  CMakeLists.txt:379 (include)

It comes from these lines in my OSPRay installation at file /usr/lib/cmake/ospray-2.8.0/osprayConfig.cmake:

# Build the absolute root install directory as a relative path (determined when
# OSPRay was configured & built) from the current install directory for this
# this file. This allows for the install tree to be relocated, after OSPRay
# was built, outside of CMake.
get_filename_component(CURRENT_ROOT_INSTALL_DIR
  ${CURRENT_CONFIG_INSTALL_DIR}/../../../ ABSOLUTE
)

if (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR})
  ospray_report_not_found(
    "OSPRay install root: ${CURRENT_ROOT_INSTALL_DIR}, "
    "determined from relative path from osprayConfig.cmake install location:  "
    "${CURRENT_CONFIG_INSTALL_DIR}, does not exist.  Either the install "
    "directory was deleted, or the install tree was only partially relocated "
    "outside of CMake after OSPRay was built.")
endif()

Where the value of variable CURRENT_CONFIG_INSTALL_DIR is /lib64/cmake/ospray-2.8.0, which I think the cmake config expects this to be /usr/lib64/cmake/ospray-2.8.0. On default Arch Linux installations, /lib64 is a symlink to /usr/lib, so I have to create another symlink at /include to point to /usr/include as a workaround, so that cmake can find the OSPRay headers. Is there a way that could solve this in the released CMake script from this repo? It seems that these lines are related:

https://github.com/ospray/ospray/blob/fe4b3806f8626b22defbeda172609aa7c8c74a2e/cmake/ospray_cmake_config/osprayConfig.cmake.in#L47-L53

Thank you!

johguenther commented 2 years ago

I also have an Arch-based system (with /lib64 sym-linking to /usr/lib) and OSPRay installed (config at /usr/lib/cmake/ospray-2.8.0/), yet when compiling pcl, CMake correctly finds OSPRay:

-- Found OSPRay: /usr

Could it be that you have /lib64 in CMAKE_MODULE_PATH (before /usr/lib)? Because CMake finds all dependencies (vtk, ...) in /lib64/cmake/ on your system (as opposed to /usr/lib64/cmake on my system).

blurgyy commented 2 years ago

Hi @johguenther, thank you for your reply.

I don't think I have mangled with CMAKE_MODULE_PATH before, and I just checked that it's neither in my shell environment nor in my cmake commands.

Nevertheless, when I tried to build pcl (with code extracted from pcl-1.12.0.tar.gz), my CMake still finds OSPRay's cmake configs from /lib64. The CMake command is:

$ cmake -S . -B build

The error still says it fails to find OSPRay headers (same as before):

related error log (same as before): ```log CMake Error at /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:26 (message): Failed to find OSPRay - OSPRay install root: /, determined from relative path from osprayConfg.cmake install location: /lib64/cmake/ospray-2.8.0, does not contain OSPRay headers. Either the install directory was deleted, or the install tree was only partially relocated outside of CMake after OSPRay was built. Call Stack (most recent call first): /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:69 (ospray_report_not_found) /lib64/cmake/vtk/VTK-vtk-module-find-packages.cmake:210 (find_package) /lib64/cmake/vtk/vtk-config.cmake:154 (include) cmake/pcl_find_vtk.cmake:25 (find_package) CMakeLists.txt:379 (include) ```

I also tried with a single CMakeLists.txt in an empty directory, and the problem is reproduced on 3 of my Arch Linux machines. My CMakeLists.txt has content as follows:

cmake_minimum_required(VERSION 3.22)
project(ospray-test)

message("CMAKE_MODULE_PATH is: ${CMAKE_MODULE_PATH}")
find_package(ospray REQUIRED)

With this CMakeLists.txt, here's the full error log:

with empty CMAKE_MODULE_PATH: ```shell $ ls CMakeLists.txt $ cmake -S . -B build -- The C compiler identification is GNU 11.1.0 -- The CXX compiler identification is GNU 11.1.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMAKE_MODULE_PATH is: CMake Error at /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:26 (message): Failed to find OSPRay - OSPRay install root: /, determined from relative path from osprayConfg.cmake install location: /lib64/cmake/ospray-2.8.0, does not contain OSPRay headers. Either the install directory was deleted, or the install tree was only partially relocated outside of CMake after OSPRay was built. Call Stack (most recent call first): /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:69 (ospray_report_not_found) CMakeLists.txt:5 (find_package) -- Configuring incomplete, errors occurred! See also "/.../build/CMakeFiles/CMakeOutput.log". ```

If I specify CMAKE_MODULE_PATH to be /usr/lib/cmake, the problem persists:

with CMAKE_MODULE_PATH set to /usr/lib/cmake: ```shell $ rm -rf build/ $ cmake -DCMAKE_MODULE_PATH='/usr/lib/cmake' -S . -B build -- The C compiler identification is GNU 11.1.0 -- The CXX compiler identification is GNU 11.1.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMAKE_MODULE_PATH is: /usr/lib/cmake CMake Error at /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:26 (message): Failed to find OSPRay - OSPRay install root: /, determined from relative path from osprayConfg.cmake install location: /lib64/cmake/ospray-2.8.0, does not contain OSPRay headers. Either the install directory was deleted, or the install tree was only partially relocated outside of CMake after OSPRay was built. Call Stack (most recent call first): /lib64/cmake/ospray-2.8.0/osprayConfig.cmake:69 (ospray_report_not_found) CMakeLists.txt:5 (find_package) -- Configuring incomplete, errors occurred! See also "/.../build/CMakeFiles/CMakeOutput.log". ```

If you have time, could you please try a cmake run with the above 4-line CMakeLists.txt in an empty directory and see if my problem occurs on your system? My cmake version is 3.22.1-5, if it helps.

johguenther commented 2 years ago

CMake version 3.22.1 here as well, yet all is found in /usr/.... It seems to be a CMake issue (config? installation?); CMAKE_MODULE_PATH was a guess, but when I set it to /lib64 it still finds the packages in /usr. Puzzling.

blurgyy commented 2 years ago

Well, in my case, all is found in /lib64/... by default and neither setting CMAKE_MODULE_PATH to /usr/lib/cmake nor setting it to /usr made any differences. There is a workaround as mentioned in my initial description, though.

Thank you for your help @johguenther, I will update this if I get any clue in the future.

fbartelt commented 1 year ago

I just got a similar error on Arch (6.1.12-arch1-1) with cmake=3.25.2, ospray=2.10.0. CMAKE_MODULE_PATH didn't work, only the symlink workaround.

The only difference is that it's not related to /lib64 but to /lib:

CMake Error at /lib/cmake/ospray-2.10.0/osprayConfig.cmake:26 (message):
  Failed to find OSPRay - OSPRay install root: /, determined from relative
  path from osprayConfg.cmake install location: /lib/cmake/ospray-2.10.0,
  does not contain OSPRay headers.  Either the install directory was deleted,
  or the install tree was only partially relocated outside of CMake after
  OSPRay was built.