cleanup and refactoring
This commit is contained in:
parent
2302158928
commit
76f6bf62a4
1285 changed files with 757994 additions and 8 deletions
19
raytracer/nvpro_core/cmake/find/FindGLM.cmake
Normal file
19
raytracer/nvpro_core/cmake/find/FindGLM.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path( GLM_INCLUDE_DIR glm/glm.hpp HINTS ${GLM_LOCATION}
|
||||
$ENV{GLM_LOCATION}
|
||||
${BASE_DIRECTORY}/nvpro_core/third_party/glm
|
||||
$ENV{VK_SDK_PATH}/include
|
||||
${VULKAN_HEADERS_OVERRIDE_INCLUDE_DIR}
|
||||
${Vulkan_INCLUDE_DIR} )
|
||||
|
||||
# Handle REQUIRD argument, define *_FOUND variable
|
||||
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR)
|
||||
|
||||
# Define GLM_INCLUDE_DIRS
|
||||
if (GLM_FOUND)
|
||||
set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# Hide some variables
|
||||
mark_as_advanced(GLM_INCLUDE_DIR)
|
||||
71
raytracer/nvpro_core/cmake/find/FindKitSDK.cmake
Normal file
71
raytracer/nvpro_core/cmake/find/FindKitSDK.cmake
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# Try to find KIT_SDK project so and include file
|
||||
#
|
||||
unset(KIT_SDK_LIBRARIES CACHE)
|
||||
unset(KIT_SDK_INCLUDE_DIR CACHE)
|
||||
unset(KIT_SDK_LIBRARY_DIR CACHE)
|
||||
unset(KIT_SDK_FOUND CACHE)
|
||||
unset(KIT_SDK_ALL_DEPS_FILE CACHE)
|
||||
|
||||
if(EXISTS ${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
include(${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
endif()
|
||||
|
||||
if(USE_PACKMAN)
|
||||
message(STATUS "attempting to using packman to source kit-sdk")
|
||||
|
||||
pull_dependencies(DEPENDENCY_FILE "kit-sdk-deps.packman.xml")
|
||||
|
||||
set(KitSDK_DIR "${BASE_DIRECTORY}/nvpro_core/OV/downloaded/kit")
|
||||
|
||||
find_file(KIT_SDK_ALL_DEPS_FILE
|
||||
NAMES all-deps.packman.xml
|
||||
PATHS ${KitSDK_DIR}/dev
|
||||
)
|
||||
if (NOT KIT_SDK_ALL_DEPS_FILE)
|
||||
message(WARNING "Kit all-deps.packman.xml not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
find_file(KIT_SDK_LAUNCH_SCRIPT
|
||||
NAMES omni.app.full.bat
|
||||
PATHS ${KitSDK_DIR}
|
||||
)
|
||||
find_file(KIT_APP
|
||||
NAMES kit.exe
|
||||
PATHS ${KitSDK_DIR}
|
||||
)
|
||||
elseif(UNIX)
|
||||
find_file(KIT_SDK_LAUNCH_SCRIPT
|
||||
NAMES omni.app.full.sh
|
||||
PATHS ${KitSDK_DIR}
|
||||
)
|
||||
find_file(KIT_APP
|
||||
NAMES kit
|
||||
PATHS ${KitSDK_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(KIT_SDK_LAUNCH_SCRIPT)
|
||||
message(STATUS " Kit launch script found at ${KIT_SDK_LAUNCH_SCRIPT}")
|
||||
else(KIT_SDK_LAUNCH_SCRIPT)
|
||||
message(WARNING "
|
||||
Kit launch script not found.")
|
||||
endif(KIT_SDK_LAUNCH_SCRIPT)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(KitSDK DEFAULT_MSG
|
||||
KIT_SDK_LAUNCH_SCRIPT
|
||||
KIT_APP
|
||||
KitSDK_DIR
|
||||
KIT_SDK_ALL_DEPS_FILE
|
||||
)
|
||||
|
||||
# Do we have to rewrite the variable here...
|
||||
set(KIT_SDK_LAUNCH_SCRIPT ${KIT_SDK_LAUNCH_SCRIPT} CACHE FILEPATH "filepath")
|
||||
set(KIT_APP ${KIT_APP} CACHE FILEPATH "filepath")
|
||||
set(KitSDK_DIR ${KitSDK_DIR} CACHE PATH "path")
|
||||
|
||||
mark_as_advanced( KIT_SDK_FOUND )
|
||||
114
raytracer/nvpro_core/cmake/find/FindNVML.cmake
Normal file
114
raytracer/nvpro_core/cmake/find/FindNVML.cmake
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
# Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Try to find NVML.
|
||||
# Once done this will define
|
||||
#
|
||||
# NVML_FOUND - whether all of the components of NVML were found
|
||||
# NVML_INCLUDE_DIRS - same as the CUDA include dir
|
||||
# NVML_LIBRARIES - the linker library for NVML
|
||||
#
|
||||
# The NVML headers and linker library are distributed as part of the CUDA SDK.
|
||||
# We use the variables set by finding CUDA
|
||||
# (see https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html and
|
||||
# https://cmake.org/cmake/help/v3.3/module/FindCUDA.html)
|
||||
# However, the shared library (DLL on Windows) should be found at runtime.
|
||||
#
|
||||
# Please note that on Windows, NVML is only available for 64-bit systems.
|
||||
set(NVML_FOUND OFF)
|
||||
|
||||
# FindCUDAToolkit is the new module to use here, but it's only available in
|
||||
# CMake 3.17+.
|
||||
# FindCUDA is available until 3.27. So we switch between the two
|
||||
# depending on the CMake version:
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
|
||||
find_package(CUDA)
|
||||
if(WIN32) # Windows
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_ARCH "x64")
|
||||
else()
|
||||
message(FATAL_ERROR "FindNVML.cmake was called with a 32-bit platform on \
|
||||
Windows, but NVML and nvpro_core are not available for 32-bit systems on \
|
||||
Windows. Did you mean to use a 64-bit platform?")
|
||||
endif()
|
||||
endif()
|
||||
set(_CUDA_LIB_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib/${_ARCH})
|
||||
set(_CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_ROOT_DIR}/include)
|
||||
else() # CMake >= 3.17.0
|
||||
find_package(CUDAToolkit)
|
||||
set(_CUDA_LIB_DIR ${CUDAToolkit_LIBRARY_DIR})
|
||||
set(_CUDA_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# Finding CUDA doesn't guarantee that NVML was installed with CUDA, since
|
||||
# one can turn that off during installation. Search for NVML in a number of
|
||||
# locations:
|
||||
|
||||
find_library(NVML_LIBRARIES NAMES nvml nvidia-ml PATHS ${_CUDA_LIB_DIR})
|
||||
|
||||
if(NOT NVML_LIBRARIES)
|
||||
if(WIN32)
|
||||
message(WARNING "CMake couldn't locate the NVML library, so compilation \
|
||||
will likely fail. You may need to install the CUDA toolkit.")
|
||||
else()
|
||||
message(WARNING "CMake couldn't locate the nvidia-ml library, so \
|
||||
compilation will likely fail. You may need to install NVML using your OS' \
|
||||
package manager; for instance, by running `sudo apt install libnvidia-ml-dev`.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(NVML_INCLUDE_DIRS nvml.h
|
||||
${NVML_LOCATION}
|
||||
$ENV{NVML_LOCATION}
|
||||
${_CUDA_INCLUDE_DIRS}
|
||||
# if no CUDA, let's try to find nvml locally in our third_party supplement.
|
||||
# FindNVML.cmake is located in nvpro_core/cmake/find.
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../third_party/binaries/nvml
|
||||
)
|
||||
|
||||
if(NOT NVML_INCLUDE_DIRS)
|
||||
message(WARNING "
|
||||
NVML headers not found. To explicitly locate it, set NVML_LOCATION,
|
||||
which should be a folder containing nvml.h."
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NVML_LIBRARIES AND NVML_INCLUDE_DIRS)
|
||||
set(NVML_FOUND ON)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(NVML DEFAULT_MSG
|
||||
NVML_INCLUDE_DIRS
|
||||
NVML_LIBRARIES
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
NVML_INCLUDE_DIRS
|
||||
NVML_LIBRARIES
|
||||
)
|
||||
99
raytracer/nvpro_core/cmake/find/FindNsightAftermath.cmake
Normal file
99
raytracer/nvpro_core/cmake/find/FindNsightAftermath.cmake
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# Copyright (c) 2021 NVIDIA Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#.rst:
|
||||
# FindNsightAftermath
|
||||
# ----------
|
||||
#
|
||||
# Try to find the NVIDIA Nsight Aftermath SDK based on the NSIGHT_AFTERMATH_SDK environment variable
|
||||
#
|
||||
# IMPORTED Targets
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines :prop_tgt:`IMPORTED` target ``NsightAftermath::NsightAftermath``, if
|
||||
# the NVIDIA Nsight Aftermath SDK has been found.
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following variables::
|
||||
#
|
||||
# NsightAftermath_FOUND - True if the NVIDIA Nsight Aftermath SDK was found
|
||||
# NsightAftermath_INCLUDE_DIRS - include directories for the NVIDIA Nsight Aftermath SDK
|
||||
# NsightAftermath_LIBRARIES - link against this library to use the NVIDIA Nsight Aftermath SDK
|
||||
# NsightAftermath_DLLS - .dll or .so files needed for distribution
|
||||
#
|
||||
# The module will also define two cache variables::
|
||||
#
|
||||
# NsightAftermath_INCLUDE_DIR - the NVIDIA Nsight Aftermath SDK include directory
|
||||
# NsightAftermath_LIBRARY - the path to the NVIDIA Nsight Aftermath SDK library
|
||||
#
|
||||
|
||||
if(WIN32 OR UNIX)
|
||||
find_path(NsightAftermath_INCLUDE_DIR
|
||||
NAMES GFSDK_Aftermath.h
|
||||
PATHS
|
||||
"${NSIGHT_AFTERMATH_SDK}/include"
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
find_library(NsightAftermath_LIBRARY
|
||||
NAMES GFSDK_Aftermath_Lib.x64
|
||||
PATHS
|
||||
"${NSIGHT_AFTERMATH_SDK}/lib/x64"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
find_library(NsightAftermath_LIBRARY
|
||||
NAMES GFSDK_Aftermath_Lib.x86
|
||||
PATHS
|
||||
"${NSIGHT_AFTERMATH_SDK}/lib/x86"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
find_path(NsightAftermath_INCLUDE_DIR
|
||||
NAMES GFSDK_Aftermath.h
|
||||
PATHS
|
||||
"${NSIGHT_AFTERMATH_SDK}/include")
|
||||
find_library(NsightAftermath_LIBRARY
|
||||
NAMES GFSDK_Aftermath_Lib
|
||||
PATHS
|
||||
"${NSIGHT_AFTERMATH_SDK}/lib")
|
||||
endif()
|
||||
|
||||
string(REPLACE ".lib" ".dll" NsightAftermath_DLLS ${NsightAftermath_LIBRARY})
|
||||
|
||||
set(NsightAftermath_LIBRARIES ${NsightAftermath_LIBRARY})
|
||||
set(NsightAftermath_INCLUDE_DIRS ${NsightAftermath_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(NsightAftermath
|
||||
DEFAULT_MSG
|
||||
NsightAftermath_LIBRARY NsightAftermath_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(NsightAftermath_INCLUDE_DIR NsightAftermath_LIBRARY)
|
||||
|
||||
if(NsightAftermath_FOUND AND NOT TARGET NsightAftermath::NsightAftermath)
|
||||
add_library(NsightAftermath::NsightAftermath UNKNOWN IMPORTED)
|
||||
set_target_properties(NsightAftermath::NsightAftermath PROPERTIES
|
||||
IMPORTED_LOCATION "${NsightAftermath_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${NsightAftermath_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
if(NOT NsightAftermath_FOUND)
|
||||
message("NSIGHT_AFTERMATH_SDK environment variable not set to a valid location (value: ${NSIGHT_AFTERMATH_SDK})")
|
||||
endif()
|
||||
|
||||
53
raytracer/nvpro_core/cmake/find/FindOmniUsdResolver.cmake
Normal file
53
raytracer/nvpro_core/cmake/find/FindOmniUsdResolver.cmake
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Try to find OMNI_USD_RESOLVER project so and include file
|
||||
#
|
||||
unset(OMNI_USD_RESOLVER_LIBRARIES CACHE)
|
||||
unset(OMNI_USD_RESOLVER_INCLUDE_DIR CACHE)
|
||||
unset(OMNI_USD_RESOLVER_LIBRARY_DIR CACHE)
|
||||
unset(OMNI_USD_RESOLVER_FOUND CACHE)
|
||||
|
||||
if ("nopy" IN_LIST OmniUsdResolver_FIND_COMPONENTS OR (DEFINED PYTHON_VERSION AND PYTHON_VERSION EQUAL "nopy"))
|
||||
set(INCLUDE_PYTHON 0)
|
||||
set(PYTHON_VERSION "nopy")
|
||||
elseif()
|
||||
set(INCLUDE_PYTHON 1)
|
||||
if (NOT DEFINED PYTHON_VERSION)
|
||||
message(STATUS "PYTHON_VERSION must be set to compatible python version string ['py37, 'py310', or 'nopy']")
|
||||
message(STATUS "Defaulting PYTHON_VERSION to 'py37'")
|
||||
set(PYTHON_VERSION "py37")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EXISTS ${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
include(${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
endif()
|
||||
|
||||
if(USE_PACKMAN)
|
||||
message(STATUS "attempting to using packman to source omni usd resolver")
|
||||
|
||||
pull_dependencies(DEPENDENCY_FILE "omniusdresolver-deps.packman.xml")
|
||||
|
||||
set(OMNI_USD_RESOLVER_DIR "${BASE_DIRECTORY}/nvpro_core/OV/downloaded/omni_usd_resolver")
|
||||
endif()
|
||||
|
||||
#message("OMNI_USD_RESOLVER_DIR: " ${OMNI_USD_RESOLVER_DIR})
|
||||
|
||||
if(OMNI_USD_RESOLVER_DIR)
|
||||
set(OMNI_USD_RESOLVER_PLUGINS_DIR "${OMNI_USD_RESOLVER_DIR}/$<IF:$<CONFIG:Debug>,debug,release>")
|
||||
set(OMNI_USD_RESOLVER_RESOURCES_DIR "${OMNI_USD_RESOLVER_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/usd/omniverse/resources")
|
||||
else(OMNI_USD_RESOLVER_DIR)
|
||||
message(WARNING "Omni usd resolver plugin not found.")
|
||||
endif(OMNI_USD_RESOLVER_DIR)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(OmniUsdResolver DEFAULT_MSG
|
||||
OMNI_USD_RESOLVER_PLUGINS_DIR
|
||||
OMNI_USD_RESOLVER_RESOURCES_DIR
|
||||
)
|
||||
|
||||
# Do we have to rewrite the variable here...
|
||||
set(OMNI_USD_RESOLVER_PLUGINS_DIR ${OMNI_USD_RESOLVER_PLUGINS_DIR} CACHE PATH "path")
|
||||
set(OMNI_USD_RESOLVER_RESOURCES_DIR ${OMNI_USD_RESOLVER_RESOURCES_DIR} CACHE PATH "path")
|
||||
|
||||
mark_as_advanced( OMNI_USD_RESOLVER_FOUND )
|
||||
171
raytracer/nvpro_core/cmake/find/FindOptix.cmake
Normal file
171
raytracer/nvpro_core/cmake/find/FindOptix.cmake
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
# Try to find OptiX project dll/so and headers
|
||||
#
|
||||
|
||||
# outputs
|
||||
unset(OPTIX_DLL CACHE)
|
||||
unset(OPTIX_LIB CACHE)
|
||||
unset(OPTIX_FOUND CACHE)
|
||||
unset(OPTIX_INCLUDE_DIR CACHE)
|
||||
|
||||
# OPTIX_LOCATION can be setup to search versions somewhere else
|
||||
|
||||
macro ( folder_list result curdir substring )
|
||||
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*${substring}*)
|
||||
SET(dirlist "")
|
||||
foreach ( child ${children})
|
||||
IF(IS_DIRECTORY ${curdir}/${child})
|
||||
LIST(APPEND dirlist ${child})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(${result} ${dirlist})
|
||||
ENDMACRO()
|
||||
|
||||
macro(_find_version_path targetVersion targetPath rootName searchList )
|
||||
unset ( targetVersion )
|
||||
unset ( targetPath )
|
||||
SET ( bestver "0.0.0" )
|
||||
SET ( bestpath "" )
|
||||
foreach ( basedir ${searchList} )
|
||||
folder_list ( dirList ${basedir} ${rootName} )
|
||||
foreach ( checkdir ${dirList} )
|
||||
string ( REGEX MATCH "${rootName}(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" result "${checkdir}" )
|
||||
if ( "${result}" STREQUAL "${checkdir}" )
|
||||
# found a path with versioning
|
||||
SET ( ver "${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${CMAKE_MATCH_4}" )
|
||||
if ( ver VERSION_GREATER bestver )
|
||||
SET ( bestver ${ver} )
|
||||
SET ( bestmajorver ${CMAKE_MATCH_2})
|
||||
SET ( bestminorver ${CMAKE_MATCH_3})
|
||||
SET ( bestpath "${basedir}/${checkdir}" )
|
||||
endif ()
|
||||
endif()
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
SET ( ${targetVersion} "${bestver}" )
|
||||
SET ( ${targetPath} "${bestpath}" )
|
||||
endmacro()
|
||||
|
||||
macro(_find_files targetVar incDir dllName dllName64 folder)
|
||||
unset ( fileList )
|
||||
if(ARCH STREQUAL "x86")
|
||||
file(GLOB fileList "${${incDir}}/../${folder}${dllName}")
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
file(GLOB fileList "${${incDir}}/${folder}${dllName}")
|
||||
endif()
|
||||
else()
|
||||
file(GLOB fileList "${${incDir}}/../${folder}${dllName64}")
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
file(GLOB fileList "${${incDir}}/${folder}${dllName64}")
|
||||
endif()
|
||||
endif()
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
message(STATUS "MISSING: unable to find ${targetVar} files (${folder}${dllName}, ${folder}${dllName64})" )
|
||||
set (${targetVar} "NOTFOUND")
|
||||
endif()
|
||||
list(APPEND ${targetVar} ${fileList} )
|
||||
|
||||
# message ( "File list: ${${targetVar}}" ) #-- debugging
|
||||
endmacro()
|
||||
|
||||
if (DEFINED OPTIX_LOCATION OR DEFINED ENV{OPTIX_LOCATION} )
|
||||
Message(STATUS "using OPTIX_LOCATION (${OPTIX_LOCATION})...")
|
||||
if(NOT DEFINED OPTIX_LOCATION)
|
||||
if(DEFINED ENV{OPTIX_LOCATION})
|
||||
set(OPTIX_LOCATION $ENV{OPTIX_LOCATION})
|
||||
endif()
|
||||
endif()
|
||||
# Locate by version failed. Handle user override for OPTIX_LOCATION.
|
||||
string ( REGEX MATCH ".*([0-9]+).([0-9]+).([0-9]+)(.*)$" result "${OPTIX_LOCATION}" )
|
||||
if ( "${result}" STREQUAL "${OPTIX_LOCATION}" )
|
||||
SET ( bestver "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" )
|
||||
SET ( bestmajorver ${CMAKE_MATCH_1})
|
||||
SET ( bestminorver ${CMAKE_MATCH_2})
|
||||
Message(STATUS "found version ${bestver}")
|
||||
else()
|
||||
Message(WARNING "Could NOT extract the version from OptiX folder : ${result}")
|
||||
endif()
|
||||
find_path( OPTIX_INCLUDE_DIR optix.h ${OPTIX_LOCATION}/include )
|
||||
if ( OPTIX_INCLUDE_DIR )
|
||||
set (OPTIX_ROOT_DIR ${OPTIX_INCLUDE_DIR}/../ )
|
||||
endif()
|
||||
endif()
|
||||
if(NOT DEFINED OPTIX_ROOT_DIR)
|
||||
# Locate OptiX by version
|
||||
set ( SEARCH_PATHS
|
||||
$ENV{OPTIX_LOCATION}
|
||||
${OPTIX_LOCATION}
|
||||
${PROJECT_SOURCE_DIR}/../LocalPackages/Optix
|
||||
${PROJECT_SOURCE_DIR}/../../LocalPackages/Optix
|
||||
${PROJECT_SOURCE_DIR}/../../../LocalPackages/Optix
|
||||
C:/ProgramData/NVIDIA\ Corporation
|
||||
|
||||
)
|
||||
|
||||
_find_version_path ( OPTIX_VERSION OPTIX_ROOT_DIR "OptiX" "${SEARCH_PATHS}" )
|
||||
|
||||
message ( STATUS "OptiX version: ${OPTIX_VERSION}")
|
||||
endif()
|
||||
|
||||
if (OPTIX_ROOT_DIR)
|
||||
|
||||
if (WIN32)
|
||||
#-------- Locate DLLS
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/optix.${bestmajorver}.${bestminorver}.0.dll" "bin64/optix.${bestmajorver}.${bestminorver}.0.dll" "")
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/optixu.${bestmajorver}.${bestminorver}.0.dll" "bin64/optixu.${bestmajorver}.${bestminorver}.0.dll" "")
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/optix_prime.${bestmajorver}.${bestminorver}.0.dll" "bin64/optix_prime.${bestmajorver}.${bestminorver}.0.dll" "")
|
||||
|
||||
#-------- Locate LIBS
|
||||
_find_files( OPTIX_LIB OPTIX_ROOT_DIR "lib/optix.${bestmajorver}.${bestminorver}.0.lib" "lib64/optix.${bestmajorver}.${bestminorver}.0.lib" "")
|
||||
_find_files( OPTIX_LIB OPTIX_ROOT_DIR "lib/optixu.${bestmajorver}.${bestminorver}.0.lib" "lib64/optixu.${bestmajorver}.${bestminorver}.0.lib" "")
|
||||
_find_files( OPTIX_LIB OPTIX_ROOT_DIR "lib/optix_prime.${bestmajorver}.${bestminorver}.0.lib" "lib64/optix_prime.${bestmajorver}.${bestminorver}.0.lib" "")
|
||||
if(NOT OPTIX_LIB)
|
||||
message(STATUS "setting OPTIX_LIB to ${OPTIX_LIB}" )
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
if (UNIX)
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/liboptix.so" "lib64/liboptix.so" "" )
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/liboptixu.so" "lib64/liboptixu.so" "" )
|
||||
_find_files( OPTIX_DLL OPTIX_ROOT_DIR "lib/liboptix_prime.so" "lib64/liboptix_prime.so" "" )
|
||||
|
||||
set(OPTIX_LIB ${OPTIX_DLL})
|
||||
|
||||
endif(UNIX)
|
||||
|
||||
#-------- Locate HEADERS
|
||||
_find_files( OPTIX_HEADERS OPTIX_ROOT_DIR "optix.h" "optix.h" "include/" )
|
||||
|
||||
|
||||
if(OPTIX_DLL)
|
||||
set( OPTIX_FOUND "YES" )
|
||||
else()
|
||||
message(STATUS "setting OPTIX_DLL to ${OPTIX_DLL}" )
|
||||
endif(OPTIX_DLL)
|
||||
else(OPTIX_ROOT_DIR)
|
||||
|
||||
message(WARNING "
|
||||
OPTIX not found.
|
||||
The OPTIX folder you would specify with OPTIX_LOCATION should contain:
|
||||
- lib[64] folder: containing the Optix[64_]*.dll or *.so
|
||||
- include folder: containing the include files"
|
||||
)
|
||||
endif(OPTIX_ROOT_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
SET(OPTIX_DLL ${OPTIX_DLL} CACHE PATH "path")
|
||||
SET(OPTIX_LIB ${OPTIX_LIB} CACHE PATH "path")
|
||||
SET(OPTIX_INCLUDE_DIR "${OPTIX_ROOT_DIR}/include" CACHE PATH "path")
|
||||
add_definitions("-DOPTIX_PATH=R\"(${OPTIX_ROOT_DIR})\"")
|
||||
add_definitions("-DOPTIX_VERSION_STR=\"${OPTIX_VERSION}\"")
|
||||
|
||||
find_package_handle_standard_args(OPTIX DEFAULT_MSG
|
||||
OPTIX_INCLUDE_DIR
|
||||
OPTIX_DLL
|
||||
)
|
||||
|
||||
mark_as_advanced( OPTIX_FOUND )
|
||||
|
||||
134
raytracer/nvpro_core/cmake/find/FindOptix7.cmake
Normal file
134
raytracer/nvpro_core/cmake/find/FindOptix7.cmake
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
# Try to find OptiX project dll/so and headers
|
||||
#
|
||||
|
||||
# outputs
|
||||
unset(OPTIX7_DLL CACHE)
|
||||
unset(OPTIX7_LIB CACHE)
|
||||
unset(OPTIX7_FOUND CACHE)
|
||||
unset(OPTIX7_INCLUDE_DIR CACHE)
|
||||
|
||||
# OPTIX7_LOCATION can be setup to search versions somewhere else
|
||||
|
||||
macro ( folder_list result curdir substring )
|
||||
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*${substring}*)
|
||||
SET(dirlist "")
|
||||
foreach ( child ${children})
|
||||
IF(IS_DIRECTORY ${curdir}/${child})
|
||||
LIST(APPEND dirlist ${child})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(${result} ${dirlist})
|
||||
ENDMACRO()
|
||||
|
||||
macro(_find_version_path targetVersion targetPath rootName searchList )
|
||||
unset ( targetVersion )
|
||||
unset ( targetPath )
|
||||
SET ( bestver "0.0.0" )
|
||||
SET ( bestpath "" )
|
||||
foreach ( basedir ${searchList} )
|
||||
folder_list ( dirList ${basedir} ${rootName} )
|
||||
foreach ( checkdir ${dirList} )
|
||||
string ( REGEX MATCH "${rootName}(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" result "${checkdir}" )
|
||||
if ( "${result}" STREQUAL "${checkdir}" )
|
||||
# found a path with versioning
|
||||
SET ( ver "${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${CMAKE_MATCH_4}" )
|
||||
if ( ver VERSION_GREATER bestver )
|
||||
SET ( bestver ${ver} )
|
||||
SET ( bestmajorver ${CMAKE_MATCH_2})
|
||||
SET ( bestminorver ${CMAKE_MATCH_3})
|
||||
SET ( bestpath "${basedir}/${checkdir}" )
|
||||
endif ()
|
||||
endif()
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
SET ( ${targetVersion} "${bestver}" )
|
||||
SET ( ${targetPath} "${bestpath}" )
|
||||
endmacro()
|
||||
|
||||
macro(_find_files targetVar incDir dllName dllName64 folder)
|
||||
unset ( fileList )
|
||||
if(ARCH STREQUAL "x86")
|
||||
file(GLOB fileList "${${incDir}}/../${folder}${dllName}")
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
file(GLOB fileList "${${incDir}}/${folder}${dllName}")
|
||||
endif()
|
||||
else()
|
||||
file(GLOB fileList "${${incDir}}/../${folder}${dllName64}")
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
file(GLOB fileList "${${incDir}}/${folder}${dllName64}")
|
||||
endif()
|
||||
endif()
|
||||
list(LENGTH fileList NUMLIST)
|
||||
if(NUMLIST EQUAL 0)
|
||||
message(STATUS "MISSING: unable to find ${targetVar} files (${folder}${dllName}, ${folder}${dllName64})" )
|
||||
set (${targetVar} "NOTFOUND")
|
||||
endif()
|
||||
list(APPEND ${targetVar} ${fileList} )
|
||||
|
||||
# message ( "File list: ${${targetVar}}" ) #-- debugging
|
||||
endmacro()
|
||||
|
||||
if (DEFINED OPTIX7_LOCATION OR DEFINED ENV{OPTIX7_LOCATION} )
|
||||
Message(STATUS "using OPTIX7_LOCATION (${OPTIX7_LOCATION})...")
|
||||
if(NOT DEFINED OPTIX7_LOCATION)
|
||||
if(DEFINED ENV{OPTIX7_LOCATION})
|
||||
set(OPTIX7_LOCATION $ENV{OPTIX7_LOCATION})
|
||||
endif()
|
||||
endif()
|
||||
# Locate by version failed. Handle user override for OPTIX7_LOCATION.
|
||||
string ( REGEX MATCH ".*([7]+).([0-9]+).([0-9]+)(.*)$" result "${OPTIX7_LOCATION}" )
|
||||
if ( "${result}" STREQUAL "${OPTIX7_LOCATION}" )
|
||||
SET ( bestver "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" )
|
||||
SET ( bestmajorver ${CMAKE_MATCH_1})
|
||||
SET ( bestminorver ${CMAKE_MATCH_2})
|
||||
Message(STATUS "found version ${bestver}")
|
||||
else()
|
||||
Message(WARNING "Could NOT extract the version from OptiX7 folder : ${result}")
|
||||
endif()
|
||||
find_path( OPTIX7_INCLUDE_DIR optix.h ${OPTIX7_LOCATION}/include )
|
||||
if ( OPTIX7_INCLUDE_DIR )
|
||||
set (OPTIX7_ROOT_DIR ${OPTIX7_INCLUDE_DIR}/../ )
|
||||
endif()
|
||||
endif()
|
||||
if(NOT DEFINED OPTIX7_ROOT_DIR)
|
||||
# Locate OptiX by version
|
||||
set ( SEARCH_PATHS
|
||||
$ENV{OPTIX7_LOCATION}
|
||||
${OPTIX7_LOCATION}
|
||||
${PROJECT_SOURCE_DIR}/../LocalPackages/Optix
|
||||
${PROJECT_SOURCE_DIR}/../../LocalPackages/Optix
|
||||
${PROJECT_SOURCE_DIR}/../../../LocalPackages/Optix
|
||||
C:/ProgramData/NVIDIA\ Corporation
|
||||
|
||||
)
|
||||
|
||||
_find_version_path ( OPTIX7_VERSION OPTIX7_ROOT_DIR "OptiX" "${SEARCH_PATHS}" )
|
||||
|
||||
message ( STATUS "OptiX version: ${OPTIX7_VERSION}")
|
||||
endif()
|
||||
|
||||
if (OPTIX7_ROOT_DIR)
|
||||
#-------- Locate HEADERS
|
||||
_find_files( OPTIX7_HEADERS OPTIX7_ROOT_DIR "optix.h" "optix.h" "include/" )
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
SET(OPTIX7_INCLUDE_DIR "${OPTIX7_ROOT_DIR}/include" CACHE PATH "path")
|
||||
add_definitions("-DOPTIX7_PATH=R\"(${OPTIX7_ROOT_DIR})\"")
|
||||
add_definitions("-DOPTIX7_VERSION_STR=\"${OPTIX7_VERSION}\"")
|
||||
|
||||
else(OPTIX7_ROOT_DIR)
|
||||
|
||||
message(WARNING "
|
||||
OPTIX not found.
|
||||
The OPTIX folder you would specify with OPTIX7_LOCATION should contain:
|
||||
- lib[64] folder: containing the Optix[64_]*.dll or *.so
|
||||
- include folder: containing the include files"
|
||||
)
|
||||
endif(OPTIX7_ROOT_DIR)
|
||||
|
||||
find_package_handle_standard_args(Optix7 DEFAULT_MSG OPTIX7_ROOT_DIR)
|
||||
mark_as_advanced( OPTIX7_FOUND )
|
||||
|
||||
48
raytracer/nvpro_core/cmake/find/FindPybind11.cmake
Normal file
48
raytracer/nvpro_core/cmake/find/FindPybind11.cmake
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Try to find PYBIND11 project so and include file
|
||||
#
|
||||
set(PYBIND11_LOCATION "" CACHE STRING "Set to location of pybind11 library/headers")
|
||||
unset(PYBIND11_INCLUDE_DIR CACHE)
|
||||
unset(PYBIND11_FOUND CACHE)
|
||||
|
||||
if(EXISTS ${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
include(${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake)
|
||||
endif()
|
||||
|
||||
if(USE_PACKMAN)
|
||||
message(STATUS "attempting to using packman to source pybind11")
|
||||
|
||||
pull_dependencies(DEPENDENCY_FILE "pybind11-deps.packman.xml")
|
||||
|
||||
set(PYBIND11_LOCATION "${BASE_DIRECTORY}/nvpro_core/OV/downloaded/pybind11")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PYBIND11_LOCATION)
|
||||
message(WARNING "PYBIND11_LOCATION is not defined")
|
||||
elseif(NOT EXISTS ${PYBIND11_LOCATION})
|
||||
message(WARNING "PYBIND11_LOCATION doesn't exist")
|
||||
endif()
|
||||
|
||||
find_path(PYBIND11_INCLUDE_DIR
|
||||
NAMES pybind11/pybind11.h
|
||||
PATHS ${PYBIND11_LOCATION}
|
||||
)
|
||||
|
||||
if(PYBIND11_INCLUDE_DIR)
|
||||
message(STATUS " pybind11.h found in ${PYBIND11_INCLUDE_DIR}")
|
||||
|
||||
set( PYBIND11_FOUND "YES" )
|
||||
|
||||
else(PYBIND11_INCLUDE_DIR)
|
||||
message(WARNING "
|
||||
pybind11 not found.")
|
||||
endif(PYBIND11_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(Pybind11 DEFAULT_MSG
|
||||
PYBIND11_INCLUDE_DIR
|
||||
)
|
||||
|
||||
set(PYBIND11_INCLUDE_DIR ${PYBIND11_INCLUDE_DIR} CACHE PATH "path")
|
||||
|
||||
mark_as_advanced( PYBIND11_FOUND )
|
||||
98
raytracer/nvpro_core/cmake/packman.cmake
Normal file
98
raytracer/nvpro_core/cmake/packman.cmake
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#*****************************************************************************
|
||||
# Copyright 2023 NVIDIA Corporation. All rights reserved.
|
||||
#*****************************************************************************
|
||||
include_guard(GLOBAL)
|
||||
|
||||
unset(PYTHON_VERSION)
|
||||
|
||||
|
||||
if (EXISTS "${BASE_DIRECTORY}/nvpro_core/OV")
|
||||
message(STATUS "Packman is available, toggle off USE_PACKMAN to disable")
|
||||
option(USE_PACKMAN "Enable to use packman dependencies where possible" ON)
|
||||
else()
|
||||
option(USE_PACKMAN "Enable to use packman dependencies where possible" OFF)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(PACKMAN_PLATFORM "windows-x86_64" CACHE INTERNAL "")
|
||||
set(PACKMAN_COMMAND "packman.cmd" CACHE INTERNAL "")
|
||||
elseif (UNIX)
|
||||
set(PACKMAN_PLATFORM "linux-${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE INTERNAL "")
|
||||
set(PACKMAN_COMMAND "packman" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if (DEBUG)
|
||||
set(PACKMAN_CONFIG "debug" CACHE INTERNAL "")
|
||||
else()
|
||||
set(PACKMAN_CONFIG "release" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
# Configure all-deps file
|
||||
function(configure_all_deps_file)
|
||||
set(oneValueArgs ALL_DEPS_FILEPATH PYTHON_VERSION_STRING)
|
||||
cmake_parse_arguments(PACKMAN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT DEFINED PACKMAN_ALL_DEPS_FILEPATH)
|
||||
set(PACKMAN_ALL_DEPS_FILEPATH "${BASE_DIRECTORY}/nvpro_core/OV/all-deps.packman.xml")
|
||||
message(STATUS "Using default packman all-deps ${PACKMAN_ALL_DEPS_FILEPATH}")
|
||||
else()
|
||||
message(STATUS "Using custom packman all-deps ${PACKMAN_ALL_DEPS_FILEPATH}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PACKMAN_PYTHON_VERSION_STRING)
|
||||
set(PACKMAN_PYTHON_VERSION_STRING "py37")
|
||||
message(WARNING "PYTHON_VERSION_STRING not defined, defaulting to py37 (none, py37, py310)")
|
||||
endif()
|
||||
|
||||
message(STATUS "PACKMAN_PYTHON_VERSION_STRING ${PACKMAN_PYTHON_VERSION_STRING}")
|
||||
message(STATUS "PACKMAN_ALL_DEPS_FILEPATH ${PACKMAN_ALL_DEPS_FILEPATH}")
|
||||
|
||||
set(PYTHON_VERSION ${PACKMAN_PYTHON_VERSION_STRING} CACHE INTERNAL "")
|
||||
|
||||
file(MAKE_DIRECTORY "${BASE_DIRECTORY}/nvpro_core/OV/downloaded")
|
||||
configure_file(
|
||||
"${PACKMAN_ALL_DEPS_FILEPATH}"
|
||||
"${BASE_DIRECTORY}/nvpro_core/OV/downloaded/all-deps.packman.xml"
|
||||
@ONLY
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Use packman to pull dependencies from ${BASE_DIRECTORY}/nvpro_core/OV/${PACKMAN_DEPENDENCY_FILE} where DEPENDENCY_FILE is an arg
|
||||
function(pull_dependencies)
|
||||
set(oneValueArgs DEPENDENCY_FILE COMMAND)
|
||||
cmake_parse_arguments(PACKMAN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT EXISTS ${BASE_DIRECTORY}/nvpro_core/OV/packman/${PACKMAN_COMMAND})
|
||||
message(FATAL_ERROR "PACKMAN_COMMAND \"${BASE_DIRECTORY}/nvpro_core/OV/packman/${PACKMAN_COMMAND}\" does not exist!")
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS ${BASE_DIRECTORY}/nvpro_core/OV/${PACKMAN_DEPENDENCY_FILE})
|
||||
message(FATAL_ERROR "PACKMAN_DEPENDENCY_FILE \"${BASE_DIRECTORY}/nvpro_core/OV/${PACKMAN_DEPENDENCY_FILE}\" does not exist!")
|
||||
endif()
|
||||
|
||||
message(STATUS "Pulling dependencies from ${PACKMAN_DEPENDENCY_FILE}...")
|
||||
message(STATUS " Platform: ${PACKMAN_PLATFORM}")
|
||||
message(STATUS " Config: ${PACKMAN_CONFIG}")
|
||||
message(STATUS " Python: ${PYTHON_VERSION}")
|
||||
|
||||
file(MAKE_DIRECTORY "${BASE_DIRECTORY}/nvpro_core/OV/downloaded")
|
||||
configure_file(
|
||||
"${BASE_DIRECTORY}/nvpro_core/OV/${PACKMAN_DEPENDENCY_FILE}"
|
||||
"${BASE_DIRECTORY}/nvpro_core/OV/downloaded/${PACKMAN_DEPENDENCY_FILE}"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
message(STATUS "execute_process(COMMAND ${BASE_DIRECTORY}/nvpro_core/OV/packman/${PACKMAN_COMMAND} pull ${BASE_DIRECTORY}/nvpro_core/OV/downloaded/${PACKMAN_DEPENDENCY_FILE} -p \"${PACKMAN_PLATFORM}\" -t config=${PACKMAN_CONFIG}
|
||||
WORKING_DIRECTORY ${BASE_DIRECTORY}/nvpro_core/OV/downloaded
|
||||
RESULT_VARIABLE PACKMAN_RESULT)")
|
||||
|
||||
execute_process(COMMAND "${BASE_DIRECTORY}/nvpro_core/OV/packman/${PACKMAN_COMMAND}" pull "${BASE_DIRECTORY}/nvpro_core/OV/downloaded/${PACKMAN_DEPENDENCY_FILE}" -p "${PACKMAN_PLATFORM}" -t config=${PACKMAN_CONFIG}
|
||||
WORKING_DIRECTORY "${BASE_DIRECTORY}/nvpro_core/OV/downloaded"
|
||||
RESULT_VARIABLE PACKMAN_RESULT)
|
||||
|
||||
if (${PACKMAN_RESULT} EQUAL 0)
|
||||
message(STATUS "Packman result: success")
|
||||
else()
|
||||
message(FATAL_ERROR "Packman result: ${PACKMAN_RESULT}")
|
||||
endif()
|
||||
endfunction()
|
||||
1151
raytracer/nvpro_core/cmake/setup.cmake
Normal file
1151
raytracer/nvpro_core/cmake/setup.cmake
Normal file
File diff suppressed because it is too large
Load diff
355
raytracer/nvpro_core/cmake/utilities.cmake
Normal file
355
raytracer/nvpro_core/cmake/utilities.cmake
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
#*****************************************************************************
|
||||
# Copyright 2020-2023 NVIDIA Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
#*****************************************************************************
|
||||
include_guard(GLOBAL)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# function that copies a list of files into the target directory
|
||||
#
|
||||
# target_copy_to_output_dir(TARGET foo
|
||||
# [RELATIVE <path_prefix>] # allows to keep the folder structure starting from this level
|
||||
# FILES <absolute_file_path> [<absolute_file_path>]
|
||||
# )
|
||||
#
|
||||
function(target_copy_to_output_dir)
|
||||
set(options)
|
||||
set(oneValueArgs TARGET RELATIVE DEST_SUBFOLDER)
|
||||
set(multiValueArgs FILES)
|
||||
cmake_parse_arguments(TARGET_COPY_TO_OUTPUT_DIR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
foreach(_ELEMENT ${TARGET_COPY_TO_OUTPUT_DIR_FILES} )
|
||||
|
||||
# handle absolute and relative paths
|
||||
if(TARGET_COPY_TO_OUTPUT_DIR_RELATIVE)
|
||||
set(_SOURCE_FILE ${TARGET_COPY_TO_OUTPUT_DIR_RELATIVE}/${_ELEMENT})
|
||||
set(_FOLDER_PATH ${_ELEMENT})
|
||||
else()
|
||||
set(_SOURCE_FILE ${_ELEMENT})
|
||||
get_filename_component(_FOLDER_PATH ${_ELEMENT} NAME)
|
||||
set (_ELEMENT "")
|
||||
endif()
|
||||
|
||||
# handle directories and files slightly different
|
||||
if(IS_DIRECTORY ${_SOURCE_FILE})
|
||||
if(MDL_LOG_FILE_DEPENDENCIES)
|
||||
MESSAGE(STATUS "- folder to copy: ${_SOURCE_FILE}")
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_COPY_TO_OUTPUT_DIR_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${_SOURCE_FILE} $<TARGET_FILE_DIR:${TARGET_COPY_TO_OUTPUT_DIR_TARGET}>/${TARGET_COPY_TO_OUTPUT_DIR_DEST_SUBFOLDER}${_FOLDER_PATH}
|
||||
)
|
||||
else()
|
||||
if(MDL_LOG_FILE_DEPENDENCIES)
|
||||
MESSAGE(STATUS "- file to copy: ${_SOURCE_FILE}")
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_COPY_TO_OUTPUT_DIR_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_SOURCE_FILE} $<TARGET_FILE_DIR:${TARGET_COPY_TO_OUTPUT_DIR_TARGET}>/${TARGET_COPY_TO_OUTPUT_DIR_DEST_SUBFOLDER}${_ELEMENT}
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Downloading the URL to FILENAME and extract its content if EXTRACT option is present
|
||||
# ZIP files should have a folder of the name of the archive
|
||||
# - ex. foo.zip -> foo/<data>
|
||||
# Arguements
|
||||
# FILENAMES : all filenames to download
|
||||
# EXTRACT : if present, will extract the content of the file
|
||||
# NOINSTALL : if present, will not make files part of install
|
||||
# INSTALL_DIR : folder for the 'install' build, default is 'media' next to the executable
|
||||
# TARGET_DIR : folder where to download to, default is {DOWNLOAD_TARGET_DIR}
|
||||
# SOURCE_DIR : folder on server, if not present 'scenes'
|
||||
#
|
||||
# Examples:
|
||||
# download_files(FILENAMES sample1.zip EXTRACT)
|
||||
# download_files(FILENAMES env.hdr)
|
||||
# download_files(FILENAMES zlib.zip EXTRACT TARGET_DIR ${BASE_DIRECTORY}/blah SOURCE_DIR libraries NOINSTALL)
|
||||
#
|
||||
function(download_files)
|
||||
set(options EXTRACT NOINSTALL)
|
||||
set(oneValueArgs INSTALL_DIR SOURCE_DIR TARGET_DIR)
|
||||
set(multiValueArgs FILENAMES)
|
||||
cmake_parse_arguments(DOWNLOAD_FILES "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
if(NOT DEFINED DOWNLOAD_FILES_INSTALL_DIR)
|
||||
set(DOWNLOAD_FILES_INSTALL_DIR "media")
|
||||
endif()
|
||||
if(NOT DEFINED DOWNLOAD_FILES_SOURCE_DIR)
|
||||
set(DOWNLOAD_FILES_SOURCE_DIR "")
|
||||
endif()
|
||||
if(NOT DEFINED DOWNLOAD_FILES_TARGET_DIR)
|
||||
set(DOWNLOAD_FILES_TARGET_DIR ${DOWNLOAD_TARGET_DIR})
|
||||
endif()
|
||||
|
||||
# Check each file to download
|
||||
foreach(FILENAME ${DOWNLOAD_FILES_FILENAMES})
|
||||
|
||||
set(TARGET_FILENAME ${DOWNLOAD_FILES_TARGET_DIR}/${FILENAME})
|
||||
if(NOT EXISTS ${TARGET_FILENAME})
|
||||
message(STATUS "Downloading ${DOWNLOAD_SITE}/${FILENAME} to ${TARGET_FILENAME}")
|
||||
file(DOWNLOAD ${DOWNLOAD_SITE}${DOWNLOAD_FILES_SOURCE_DIR}/${FILENAME} ${TARGET_FILENAME}
|
||||
SHOW_PROGRESS
|
||||
STATUS _DOWNLOAD_STATUS)
|
||||
|
||||
# Check whether the download succeeded. _DOWNLOAD_STATUS is a list of
|
||||
# length 2; element 0 is the return value (0 == no error), element 1 is
|
||||
# a string value for the error.
|
||||
list(GET _DOWNLOAD_STATUS 0 _DOWNLOAD_STATUS_CODE)
|
||||
if(NOT (${_DOWNLOAD_STATUS_CODE} EQUAL 0))
|
||||
list(GET _DOWNLOAD_STATUS 1 _DOWNLOAD_STATUS_MESSAGE)
|
||||
message(FATAL_ERROR "Download of ${DOWNLOAD_SITE}/${FILENAME} to ${TARGET_FILENAME} failed with code ${_DOWNLOAD_STATUS_CODE}: ${_DOWNLOAD_STATUS_MESSAGE}")
|
||||
endif()
|
||||
|
||||
# Extracting the ZIP file
|
||||
if(DOWNLOAD_FILES_EXTRACT)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${TARGET_FILENAME}
|
||||
WORKING_DIRECTORY ${DOWNLOAD_FILES_TARGET_DIR})
|
||||
# ARCHIVE_EXTRACT needs CMake 3.18+
|
||||
# file(ARCHIVE_EXTRACT INPUT ${TARGET_FILENAME}
|
||||
# DESTINATION ${DOWNLOAD_FILES_TARGET_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Installing the files or directory
|
||||
if (NOT DOWNLOAD_FILES_NOINSTALL)
|
||||
if(DOWNLOAD_FILES_EXTRACT)
|
||||
get_filename_component(FILE_DIR ${FILENAME} NAME_WE)
|
||||
install(DIRECTORY ${DOWNLOAD_FILES_TARGET_DIR}/${FILE_DIR} CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${DOWNLOAD_FILES_INSTALL_DIR}")
|
||||
install(DIRECTORY ${DOWNLOAD_FILES_TARGET_DIR}/${FILE_DIR} CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${DOWNLOAD_FILES_INSTALL_DIR}")
|
||||
else()
|
||||
install(FILES ${TARGET_FILENAME} CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${DOWNLOAD_FILES_INSTALL_DIR}")
|
||||
install(FILES ${TARGET_FILENAME} CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${DOWNLOAD_FILES_INSTALL_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Find dependencies for GLSL files (#include ...)
|
||||
# Call 'glslc -M' to find all dependencies of the file and return the list
|
||||
# in GLSL_DEPENDENCY
|
||||
#
|
||||
function(get_glsl_dependencies )
|
||||
cmake_parse_arguments(GGD "" "SRC" "FLAGS" ${ARGN} )
|
||||
get_filename_component(FILE_NAME ${GGD_SRC} NAME)
|
||||
get_filename_component(DIR_NAME ${GGD_SRC} DIRECTORY)
|
||||
|
||||
# glslc has a bug where it won't quote paths with spaces
|
||||
# As a workaround, assume all paths are absolute and separate based on matching the root path
|
||||
# Include any added include paths in case they are on different windows drives
|
||||
set(INCLUDE_PATHS ${GGD_FLAGS})
|
||||
list(FILTER INCLUDE_PATHS INCLUDE REGEX "-I.*")
|
||||
list(TRANSFORM INCLUDE_PATHS REPLACE "-I" "")
|
||||
list(APPEND INCLUDE_PATHS ${DIR_NAME})
|
||||
set(INCLUDE_ROOTS)
|
||||
foreach(INCLUDE_PATH ${INCLUDE_PATHS})
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
|
||||
string(REGEX MATCH "^([A-Za-z]:)?/" INCLUDE_ROOT ${INCLUDE_PATH})
|
||||
else()
|
||||
cmake_path(GET INCLUDE_PATH ROOT_PATH INCLUDE_ROOT)
|
||||
endif()
|
||||
list(APPEND INCLUDE_ROOTS ${INCLUDE_ROOT})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES INCLUDE_ROOTS)
|
||||
|
||||
message(STATUS " - Find dependencies for ${FILE_NAME}")
|
||||
#message(STATUS "calling : ${Vulkan_GLSLC_EXECUTABLE} ${GGD_FLAGS} -M ${GGD_SRC} OUTPUT_VARIABLE DEP RESULT_VARIABLE RES")
|
||||
execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} ${GGD_FLAGS} -M ${GGD_SRC} OUTPUT_VARIABLE DEP RESULT_VARIABLE RES )
|
||||
if(RES EQUAL 0)
|
||||
# Removing "name.spv: "
|
||||
string(REGEX REPLACE "[^:]*: " "" DEP ${DEP})
|
||||
# The command line may end with newlines. This breaks the Ninja generator on
|
||||
# CMake 3.16.2 (fixed as of 3.24.1). As a workaround, remove trailing newlines.
|
||||
string(REGEX REPLACE "[\r\n]+$" "" DEP ${DEP})
|
||||
# Splitting each root with a ';'. On linux this is just ' /' -> ';/'.
|
||||
foreach(ROOT ${INCLUDE_ROOTS})
|
||||
string(REPLACE " ${ROOT}" ";${ROOT}" DEP ${DEP})
|
||||
endforeach()
|
||||
set(GLSL_DEPENDENCY ${DEP} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Function to compile all GLSL source files to Spir-V
|
||||
#
|
||||
# SOURCE_FILES : List of sources to compile
|
||||
# HEADER_FILES : List of dependency header files
|
||||
# DST : The destination directory (need to be absolute)
|
||||
# VULKAN_TARGET : to define the vulkan target i.e vulkan1.2 (default vulkan1.1)
|
||||
# HEADER ON: if ON, will generate headers instead of binary Spir-V files
|
||||
# DEPENDENCY : ON|OFF will create the list of dependencies for the GLSL source file
|
||||
# FLAGS: List of compile flags
|
||||
#
|
||||
# compile_glsl(
|
||||
# SOURCE_FILES foo.vert foo.frag
|
||||
# DST ${CMAKE_CURRENT_SOURCE_DIR}/shaders
|
||||
# FLAGS -g0
|
||||
# )
|
||||
|
||||
function(compile_glsl)
|
||||
set(oneValueArgs DST VULKAN_TARGET HEADER DEPENDENCY)
|
||||
set(multiValueArgs SOURCE_FILES HEADER_FILES FLAGS)
|
||||
cmake_parse_arguments(COMPILE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
# Check if the GLSL compiler is present
|
||||
if(NOT Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
|
||||
message(ERROR "Could not find Vulkan_GLSLANG_VALIDATOR_EXECUTABLE to compile shaders")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# By default use Vulkan 1.1
|
||||
if(NOT DEFINED COMPILE_VULKAN_TARGET)
|
||||
set(COMPILE_VULKAN_TARGET vulkan1.1)
|
||||
endif()
|
||||
|
||||
# If destination is not present, same as source
|
||||
if(NOT DEFINED COMPILE_DST)
|
||||
message(ERROR " --- DST not defined")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Make the output directory if needed
|
||||
file(MAKE_DIRECTORY ${COMPILE_DST})
|
||||
|
||||
# If no flag set -g (debug)
|
||||
if(NOT DEFINED COMPILE_FLAGS)
|
||||
set(COMPILE_FLAGS -g)
|
||||
endif()
|
||||
|
||||
# Compiling all GLSL sources
|
||||
foreach(GLSL_SRC ${COMPILE_SOURCE_FILES})
|
||||
|
||||
# Find the dependency files for the GLSL source
|
||||
# or use all headers as dependencies.
|
||||
if(COMPILE_DEPENDENCY)
|
||||
get_glsl_dependencies(SRC ${GLSL_SRC} FLAGS ${COMPILE_FLAGS})
|
||||
else()
|
||||
set(GLSL_DEPENDENCY ${HEADER_FILES})
|
||||
endif()
|
||||
|
||||
# Default compiler command, always adding debug information (Add and option to opt-out?)
|
||||
set(COMPILE_CMD ${COMPILE_FLAGS} --target-env ${COMPILE_VULKAN_TARGET})
|
||||
|
||||
# Compilation to headers need a variable name, the output will be a .h
|
||||
get_filename_component(FILE_NAME ${GLSL_SRC} NAME)
|
||||
if(COMPILE_HEADER)
|
||||
STRING(REPLACE "." "_" VAR_NAME ${FILE_NAME}) # Name of the variable in the header
|
||||
list(APPEND COMPILE_CMD --vn ${VAR_NAME})
|
||||
set(GLSL_OUT "${COMPILE_DST}/${FILE_NAME}.h")
|
||||
else()
|
||||
set(GLSL_OUT "${COMPILE_DST}/${FILE_NAME}.spv")
|
||||
list(APPEND _SPVS ${GLSL_OUT})
|
||||
endif()
|
||||
|
||||
|
||||
# Appending the output name and the file source
|
||||
list(APPEND COMPILE_CMD -o ${GLSL_OUT} ${GLSL_SRC} )
|
||||
# The custom command is added to the build system, check for the presence of the output
|
||||
# but also for changes done in GLSL headers
|
||||
add_custom_command(
|
||||
PRE_BUILD
|
||||
OUTPUT ${GLSL_OUT}
|
||||
COMMAND echo ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} ${COMPILE_CMD}
|
||||
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} ${COMPILE_CMD}
|
||||
MAIN_DEPENDENCY ${GLSL_SRC}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${GLSL_DEPENDENCY}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Setting OUT variables
|
||||
set(GLSL_SOURCES ${COMPILE_SOURCE_FILES} PARENT_SCOPE)
|
||||
set(GLSL_HEADERS ${COMPILE_HEADER_FILES} PARENT_SCOPE)
|
||||
set(SPV_OUTPUT ${_SPVS} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Function to compile all GLSL files from a source to Spir-V
|
||||
# The sources are all .vert, .frag, .r* and the headers for the source are .glsl and .h
|
||||
# This allows to modify one of the header and getting the sources recompiled.
|
||||
#
|
||||
# SRC : The directory source of the shaders
|
||||
# DST : The destination directory (need to be absolute)
|
||||
# VULKAN_TARGET : to define the vulkan target i.e vulkan1.2 (default vulkan1.1)
|
||||
# HEADER ON: if present, will generate headers instead of binary Spir-V files
|
||||
# DEPENDENCY : ON|OFF will create the list of dependencies for the GLSL source file
|
||||
# FLAGS : other glslValidator flags
|
||||
#
|
||||
# compile_glsl_directory(
|
||||
# SRC "${CMAKE_CURRENT_SOURCE_DIR}/shaders"
|
||||
# DST "${CMAKE_CURRENT_SOURCE_DIR}/autogen"
|
||||
# VULKAN_TARGET "vulkan1.2"
|
||||
# HEADER ON
|
||||
# )
|
||||
#
|
||||
function(compile_glsl_directory)
|
||||
set(oneValueArgs SRC DST VULKAN_TARGET HEADER DEPENDENCY FLAGS)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(COMPILE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
# Collecting all source files
|
||||
file(GLOB GLSL_SOURCE_FILES
|
||||
"${COMPILE_SRC}/*.comp" # Compute
|
||||
"${COMPILE_SRC}/*.frag" # Fragment
|
||||
"${COMPILE_SRC}/*.geom" # Geometry
|
||||
"${COMPILE_SRC}/*.mesh" # Mesh
|
||||
"${COMPILE_SRC}/*.rahit" # Ray any hit
|
||||
"${COMPILE_SRC}/*.rcall" # Ray callable
|
||||
"${COMPILE_SRC}/*.rchit" # Ray closest hit
|
||||
"${COMPILE_SRC}/*.rgen" # Ray generation
|
||||
"${COMPILE_SRC}/*.rint" # Ray intersection
|
||||
"${COMPILE_SRC}/*.rmiss" # Ray miss
|
||||
"${COMPILE_SRC}/*.task" # Task
|
||||
"${COMPILE_SRC}/*.tesc" # Tessellation control
|
||||
"${COMPILE_SRC}/*.tese" # Tessellation evaluation
|
||||
"${COMPILE_SRC}/*.vert" # Vertex
|
||||
)
|
||||
|
||||
# Collecting headers for dependencies
|
||||
file(GLOB GLSL_HEADER_FILES
|
||||
"${COMPILE_SRC}/*.glsl" # Auto detect - used for header
|
||||
"${COMPILE_SRC}/*.h"
|
||||
)
|
||||
|
||||
# By default use Vulkan 1.1
|
||||
if(NOT DEFINED COMPILE_VULKAN_TARGET)
|
||||
set(COMPILE_VULKAN_TARGET vulkan1.1)
|
||||
endif()
|
||||
|
||||
# If destination is not present, same as source
|
||||
if(NOT DEFINED COMPILE_DST)
|
||||
set(COMPILE_DST ${COMPILE_SRC})
|
||||
endif()
|
||||
|
||||
# If no flag set -g (debug)
|
||||
if(NOT DEFINED COMPILE_FLAGS)
|
||||
set(COMPILE_FLAGS -g)
|
||||
endif()
|
||||
|
||||
# Compiling all GLSL
|
||||
compile_glsl(SOURCE_FILES ${GLSL_SOURCE_FILES}
|
||||
HEADER_FILES ${GLSL_HEADER_FILES}
|
||||
DST ${COMPILE_DST}
|
||||
VULKAN_TARGET ${COMPILE_VULKAN_TARGET}
|
||||
HEADER ${COMPILE_HEADER}
|
||||
DEPENDENCY ${COMPILE_DEPENDENCY}
|
||||
FLAGS ${COMPILE_FLAGS}
|
||||
)
|
||||
|
||||
# Setting OUT variables
|
||||
set(GLSL_SOURCES ${GLSL_SOURCE_FILES} PARENT_SCOPE)
|
||||
set(GLSL_HEADERS ${GLSL_HEADER_FILES} PARENT_SCOPE)
|
||||
set(SPV_OUTPUT ${SPV_OUTPUT} PARENT_SCOPE) # propagate value set in compile_glsl
|
||||
endfunction()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue