Skip to content
Snippets Groups Projects
Commit c4d622ea authored by Thomas Müller's avatar Thomas Müller
Browse files

Make FindOptiX.cmake agnostic to the OptiX version

parent 3b085e02
No related branches found
No related tags found
No related merge requests found
......@@ -30,63 +30,54 @@
# Our initial guess will be within the SDK.
if(DEFINED ENV{OptiX_INSTALL_DIR})
set(OptiX_INSTALL_DIR $ENV{OptiX_INSTALL_DIR})
set(OptiX_INCLUDE_DIRS "$ENV{OptiX_INSTALL_DIR}/include")
else()
message(NOTICE "-- !!! Warning OptiX_INSTALL_DIR not set in environment. using default")
if (MSVC)
set(OptiX_INSTALL_DIR "C:\\ProgramData\\NVIDIA Corporation\\OptiX SDK 7.5.0")
else()
set(OptiX_INSTALL_DIR "/usr/local/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64")
endif()
#set(OptiX_INSTALL_DIR "${CMAKE_SOURCE_DIR}/../" CACHE PATH "Path to OptiX installed location.")
if (MSVC)
file(GLOB OptiX_INCLUDE_DIRS "C:/ProgramData/NVIDIA Corporation/OptiX SDK */include")
else()
file(GLOB OptiX_INCLUDE_DIRS "/usr/local/NVIDIA-OptiX-SDK-*-linux64-x86_64/include")
endif()
endif()
message(NOTICE "-- OptiX_INSTALL_DIR value: ${OptiX_INSTALL_DIR}")
# The distribution contains only 64 bit libraries. Error when we have been mis-configured.
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
if(WIN32)
message(SEND_ERROR "Make sure when selecting the generator, you select one with Win64 or x64.")
endif()
message(FATAL_ERROR "OptiX only supports builds configured for 64 bits.")
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
if(WIN32)
message(SEND_ERROR "Make sure when selecting the generator, you select one with Win64 or x64.")
endif()
message(FATAL_ERROR "OptiX only supports builds configured for 64 bits.")
endif()
# search path based on the bit-ness of the build. (i.e. 64: bin64, lib64; 32:
# bin, lib). Note that on Mac, the OptiX library is a universal binary, so we
# only need to look in lib and not lib64 for 64 bit builds.
if(NOT APPLE)
set(bit_dest "64")
else()
set(bit_dest "")
endif()
# Include
# Sort optix directories in descending natural order such that the highest version comes first.
list(SORT OptiX_INCLUDE_DIRS COMPARE NATURAL ORDER DESCENDING)
find_path(OptiX_INCLUDE
NAMES optix.h
PATHS "${OptiX_INSTALL_DIR}/include"
NO_DEFAULT_PATH
)
NAMES optix.h
PATHS ${OptiX_INCLUDE_DIRS}
NO_DEFAULT_PATH
)
find_path(OptiX_INCLUDE
NAMES optix.h
)
NAMES optix.h
)
# Check to make sure we found what we were looking for
function(OptiX_report_error error_message required component )
if(DEFINED OptiX_FIND_REQUIRED_${component} AND NOT OptiX_FIND_REQUIRED_${component})
set(required FALSE)
endif()
if(OptiX_FIND_REQUIRED AND required)
message(FATAL_ERROR "${error_message} Please locate before proceeding.")
else()
if(NOT OptiX_FIND_QUIETLY)
message(STATUS "${error_message}")
endif(NOT OptiX_FIND_QUIETLY)
endif()
if(DEFINED OptiX_FIND_REQUIRED_${component} AND NOT OptiX_FIND_REQUIRED_${component})
set(required FALSE)
endif()
if(OptiX_FIND_REQUIRED AND required)
message(FATAL_ERROR "${error_message} Please locate before proceeding.")
else()
if(NOT OptiX_FIND_QUIETLY)
message(STATUS "${error_message}")
endif(NOT OptiX_FIND_QUIETLY)
endif()
endfunction()
if(NOT OptiX_INCLUDE)
OptiX_report_error("OptiX headers (optix.h and friends) not found." TRUE headers )
set(OptiX_FOUND FALSE)
if (NOT OptiX_INCLUDE)
OptiX_report_error("OptiX headers (optix.h and friends) not found." TRUE headers )
set(OptiX_FOUND FALSE)
else()
set(OptiX_FOUND TRUE)
get_filename_component(OptiX_INSTALL_DIR ${OptiX_INCLUDE} DIRECTORY)
set(OptiX_FOUND TRUE)
message(NOTICE "-- Found OptiX: ${OptiX_INSTALL_DIR}")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment