1#
2# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7#  * Redistributions of source code must retain the above copyright
8#    notice, this list of conditions and the following disclaimer.
9#  * Redistributions in binary form must reproduce the above copyright
10#    notice, this list of conditions and the following disclaimer in the
11#    documentation and/or other materials provided with the distribution.
12#  * Neither the name of NVIDIA CORPORATION nor the names of its
13#    contributors may be used to endorse or promote products derived
14#    from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29# Locate the OptiX distribution.  Search relative to the SDK first, then look in the system.
30
31# Our initial guess will be within the SDK.
32set(OptiX_INSTALL_DIR "${CMAKE_SOURCE_DIR}/../" CACHE PATH "Path to OptiX installed location.")
33
34# The distribution contains only 64 bit libraries.  Error when we have been mis-configured.
35if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
36  if(WIN32)
37    message(SEND_ERROR "Make sure when selecting the generator, you select one with Win64 or x64.")
38  endif()
39  message(FATAL_ERROR "OptiX only supports builds configured for 64 bits.")
40endif()
41
42# search path based on the bit-ness of the build.  (i.e. 64: bin64, lib; 32:
43# bin, lib).  Note that on Mac, the OptiX library is a universal binary, so we
44# only need to look in lib and not lib for 64 bit builds.
45if(NOT APPLE)
46  set(bit_dest "64")
47else()
48  set(bit_dest "")
49endif()
50
51# Include
52find_path(OptiX_INCLUDE
53  NAMES optix.h
54  PATHS "${OptiX_INSTALL_DIR}/include"
55  NO_DEFAULT_PATH
56  )
57find_path(OptiX_INCLUDE
58  NAMES optix.h
59  )
60
61# Check to make sure we found what we were looking for
62function(OptiX_report_error error_message required component )
63  if(DEFINED OptiX_FIND_REQUIRED_${component} AND NOT OptiX_FIND_REQUIRED_${component})
64    set(required FALSE)
65  endif()
66  if(OptiX_FIND_REQUIRED AND required)
67    message(FATAL_ERROR "${error_message}  Please locate before proceeding.")
68  else()
69    if(NOT OptiX_FIND_QUIETLY)
70      message(STATUS "${error_message}")
71    endif(NOT OptiX_FIND_QUIETLY)
72  endif()
73endfunction()
74
75if(NOT OptiX_INCLUDE)
76  OptiX_report_error("OptiX headers (optix.h and friends) not found." TRUE headers )
77endif()
78
79