NVlabs / instant-ngp

Instant neural graphics primitives: lightning fast NeRF and more
https://nvlabs.github.io/instant-ngp
Other
15.81k stars 1.9k forks source link

[OptiX not found problem] `CMakeLists.txt` is not compatible with `FindOptiX.cmake` within OptiX package. #27

Closed somisawa closed 2 years ago

somisawa commented 2 years ago

Question: Was my way correct? Or do there exist other solutions you suppose?

Environment: Ubuntu 20.04 Objective package: OptiX™ SDK 7.4.0 downloaded from here.

In this part, you use find_package but path/to/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64/SDK/CMake/FindOptiX.cmake does not set OptiX_FOUND even if optix.h exists in OptiX_INSTALL_DIR or OptiX_INSTALL_DIR/include. https://github.com/NVlabs/instant-ngp/blob/06ee0a2839be8d52e47ebe86ec86246b8ca19c1d/CMakeLists.txt#L162-L174

I've solved this problem by adding the following code at the end of path/to/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64/SDK/CMake/FindOptiX.cmake so that find_package correctly set OptiX_FOUND.

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OptiX
  REQUIRED_VARS
    OptiX_INCLUDE
  )

if(OptiX_FOUND AND NOT TARGET OptiX::OptiX)
  add_library(OptiX::OptiX UNKNOWN IMPORTED)
  set_target_properties(OptiX::OptiX PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${OptiX_INCLUDE}"
    )
endif()
Tom94 commented 2 years ago

Apologies for this, I had forgotten to include the relevant cmake/FindOptiX.cmake file in this repository and only remedied the issue 2 hours ago. (see https://github.com/NVlabs/instant-ngp/commit/8bd9ff435a89d4ae71372056a7a6d0f44f4c4378)

OptiX should now be found out-of-the-box (assuming OptiX_INSTALL_DIR is set)

somisawa commented 2 years ago

Oh, I missed your recent update. Thank you so much for fixing. I will close this issue.