Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ospTutorialGLM #1604

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions RenderingToolkit/Tutorial/ospTutorialGLM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.16)
project(OSPRAY_TUTORIAL_GLM LANGUAGES CXX)

include(CMakePrintHelpers)
include(GNUInstallDirs)


set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

list(APPEND CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake/dependencies
)


set(INSTALL_DIR_ABSOLUTE "Release")
set(ONEAPI_ROOT "")
if(DEFINED ENV{ONEAPI_ROOT})
set(ONEAPI_ROOT "$ENV{ONEAPI_ROOT}")
message(STATUS "ONEAPI_ROOT FROM ENVIRONMENT: ${ONEAPI_ROOT}")
else()
if(WIN32)
set(ONEAPI_ROOT "C:/Program Files (x86)/Intel/oneAPI")
else()
set(ONEAPI_ROOT /opt/intel/oneapi)
endif()
message(STATUS "ONEAPI_ROOT DEFAULT: ${ONEAPI_ROOT}")
endif(DEFINED ENV{ONEAPI_ROOT})

list(APPEND CMAKE_PREFIX_PATH "${ONEAPI_ROOT}/rkcommon/latest")
find_package(ospray REQUIRED PATHS ${ONEAPI_ROOT})

if(MSVC)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(MSVC)

include_directories(${OSPRAY_INCLUDE_DIR} ${RKCOMMON_INCLUDE_DIRS})
link_directories(${OSPRAY_ROOT}/lib ${ONEAPI_ROOT}/rkcommon/latest/lib)

include(cmake/ospray_macros.cmake)
include(cmake/dependencies/glm.cmake)

link_libraries(ospray rkcommon)

add_executable(ospTutorialGLM ${OSPRAY_RESOURCE} ospTutorialGLM.cpp)
target_link_libraries(ospTutorialGLM PRIVATE ospray glm)
51 changes: 51 additions & 0 deletions RenderingToolkit/Tutorial/ospTutorialGLM/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ospTutorialGLM
This is a small example tutorial how to use OSPRay in an application using GLM instead of rkcommon for math types.
## Build and Run

### Windows

1. Run a new **x64 Native Tools Command Prompt for MSVS 2019**.

```
call <path-to-oneapi-folder>\setvars.bat
cd <path-to-oneAPI-samples>\RenderingToolkit\Tutorial\ospTutorialGLM
mkdir build
cd build
cmake ..
cmake --build .
cd Debug
ospTutorialGLM.exe
```

### Linux

1. Start a new Terminal session.
```
source <path-to-oneapi-folder>/setvars.sh
cd <path-to-oneAPI-samples>/RenderingToolkit/Tutorial/ospTutorialGLM
mkdir build
cd build
cmake ..
cmake --build .
./ospTutorialGLM
```

### macOS

1. Start a new Terminal session.

```
source <path-to-oneapi-folder>/setvars.sh
cd <path-to-oneAPI-samples>/RenderingToolkit/Tutorial/ospTutorialGLM
mkdir build
cd build
cmake ..
cmake --build .
./ospTutorialGLM
```

### Additional Notes

oneAPI Rendering Toolkit 2023.1 version's cmake file contains an errata. The errata will produce an error while building the example. Please apply the following workaround described in the following page. 2023.1.1 version will address the issue.

https://community.intel.com/t5/Intel-oneAPI-Rendering-Toolkit/2023-1-troubleshoot-errata-CMake-Error/m-p/1476040#M98
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## Copyright 2020 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

if(glm_FOUND)
return()
endif()

if(NOT DEFINED GLM_VERSION)
set(GLM_VERSION 0.9.9.8)
endif()

## Look for any available version
message(STATUS "Looking for glm ${GLM_VERSION}")
find_package(glm ${GLM_VERSION} QUIET)

if(glm_FOUND)
message(STATUS "Found glm")
else()
## Download and build if not found
set(_ARCHIVE_EXT "zip")

if(NOT DEFINED GLM_URL)
set(GLM_URL "https://github.com/g-truc/glm/releases/download/${GLM_VERSION}/glm-${GLM_VERSION}.${_ARCHIVE_EXT}")
endif()

message(STATUS "Downloading glm ${GLM_URL}...")

include(FetchContent)

FetchContent_Declare(
glm
URL "${GLM_URL}"
# `patch` is not available on all systems, so use `git apply` instead.Note
# that we initialize a Git repo in the GLM download directory to allow the
# Git patching approach to work.Also note that we don't want to actually
# check out the GLM Git repo, since we want our GLM_HASH security checks
# to still function correctly.
PATCH_COMMAND git init -q . && git apply --ignore-whitespace -v -p1 < ${CMAKE_CURRENT_LIST_DIR}/glm.patch
)
## Bypass FetchContent_MakeAvailable() shortcut to disable install
FetchContent_GetProperties(glm)
if(NOT glm_POPULATED)
FetchContent_Populate(glm)
message(STATUS "Adding subdirectory for glm ${glm_SOURCE_DIR} and ${glm_BINARY_DIR}")

## the subdir will still be built since targets depend on it, but it won't be installed
add_subdirectory(${glm_SOURCE_DIR} ${glm_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
message(STATUS "Adding glm Library")

add_library(glm::glm ALIAS glm)

unset(${_ARCHIVE_EXT})

endif()
Loading