Back to home page

EIC code displayed by LXR

 
 

    


Warning, /eic-opticks/cmake/FindOptiX.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
0002 # SPDX-License-Identifier: BSD-3-Clause
0003 #
0004 
0005 if(TARGET OptiX::OptiX)
0006     return()
0007 endif()
0008 
0009 find_package(CUDAToolkit REQUIRED)
0010 
0011 set(OptiX_INSTALL_DIR "OptiX_INSTALL_DIR-NOTFOUND" CACHE PATH "Path to the installed location of the OptiX SDK.")
0012 
0013 if(NOT OptiX_FIND_VERSION)
0014     set(OptiX_FIND_VERSION "*")
0015 endif()
0016 
0017 # If they haven't specified a specific OptiX SDK install directory, search likely default locations for SDKs.
0018 if(NOT OptiX_INSTALL_DIR)
0019     if(CMAKE_HOST_WIN32)
0020         # This is the default OptiX SDK install location on Windows.
0021         file(GLOB OPTIX_SDK_DIR "$ENV{ProgramData}/NVIDIA Corporation/OptiX SDK ${OptiX_FIND_VERSION}*")
0022     else()
0023         # On linux, there is no default install location for the SDK, but it does have a default subdir name.
0024         foreach(dir "/opt" "/usr/local" "$ENV{HOME}" "$ENV{HOME}/Downloads")
0025             file(GLOB OPTIX_SDK_DIR "${dir}/NVIDIA-OptiX-SDK-${OptiX_FIND_VERSION}*")
0026             if(OPTIX_SDK_DIR)
0027                 break()
0028             endif()
0029         endforeach()
0030     endif()
0031 
0032     # If we found multiple SDKs, try to pick the one with the highest version number
0033     list(LENGTH OPTIX_SDK_DIR len)
0034     if(${len} GREATER 0)
0035         list(SORT OPTIX_SDK_DIR)
0036         list(REVERSE OPTIX_SDK_DIR)
0037         list(GET OPTIX_SDK_DIR 0 OPTIX_SDK_DIR)
0038     endif()
0039 endif()
0040 
0041 find_path(OptiX_ROOT_DIR NAMES include/optix.h PATHS ${OptiX_INSTALL_DIR} ${OPTIX_SDK_DIR} /opt/optix /opt/optix-dev /usr/local/optix /usr/local/optix-dev REQUIRED)
0042 file(READ "${OptiX_ROOT_DIR}/include/optix.h" header)
0043 string(REGEX REPLACE "^.*OPTIX_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])[^0-9].*$" "\\1.\\2.\\3" OPTIX_VERSION ${header})
0044 string(REGEX REPLACE "^.*OPTIX_VERSION ([0-9]+)[^0-9].*$" "\\1" OptiX_VERSION ${header})
0045 
0046 include(FindPackageHandleStandardArgs)
0047 find_package_handle_standard_args(OptiX
0048     FOUND_VAR OptiX_FOUND
0049     VERSION_VAR OPTIX_VERSION
0050     REQUIRED_VARS
0051         OptiX_ROOT_DIR
0052     REASON_FAILURE_MESSAGE
0053         "OptiX installation not found. Please use CMAKE_PREFIX_PATH or OptiX_INSTALL_DIR to locate 'include/optix.h'."
0054 )
0055 
0056 set(OptiX_INCLUDE_DIR ${OptiX_ROOT_DIR}/include)
0057 
0058 add_library(OptiX::OptiX INTERFACE IMPORTED)
0059 target_include_directories(OptiX::OptiX INTERFACE ${OptiX_INCLUDE_DIR} ${CUDAToolkit_INCLUDE_DIRS})
0060 target_link_libraries(OptiX::OptiX INTERFACE ${CMAKE_DL_LIBS})