Skip to content

Commit

Permalink
Merge branch 'dev/mleone'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLeone committed Sep 8, 2022
2 parents aee9730 + 14432d5 commit dbc0303
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CMake/FetchGlad.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

option( OTK_FETCH_CONTENT "Use FetchContent for third party libraries" ON )
if( NOT OTK_FETCH_CONTENT )
find_package( glad REQUIRED )
return()
endif()

include(FetchContent)

set( GLAD_INSTALL OFF CACHE BOOL "Generate glad installation target" )
Expand Down
6 changes: 6 additions & 0 deletions CMake/FetchGlfw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

option( OTK_FETCH_CONTENT "Use FetchContent for third party libraries" ON )
if( NOT OTK_FETCH_CONTENT )
find_package( glfw3 REQUIRED )
return()
endif()

set( GLFW_BUILD_DOCS OFF CACHE BOOL "Build the GLFW documentation" )
set( GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build the GLFW example programs" )
set( GLFW_BUILD_TESTS OFF CACHE BOOL "Build the GLFW test programs" )
Expand Down
6 changes: 6 additions & 0 deletions CMake/FetchGtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

option( OTK_FETCH_CONTENT "Use FetchContent for third party libraries" ON )
if( NOT OTK_FETCH_CONTENT )
find_package( GTest REQUIRED )
return()
endif()

include(FetchContent)

set( INSTALL_GTEST OFF CACHE BOOL "Enable installation of googletest" )
Expand Down
6 changes: 6 additions & 0 deletions CMake/FetchOpenEXR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

option( OTK_FETCH_CONTENT "Use FetchContent for third party libraries" ON )
if( NOT OTK_FETCH_CONTENT )
find_package( OpenEXR 3.1 REQUIRED )
return()
endif()

include(FetchContent)

FetchContent_Declare(
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@ endif()
if( OTK_BUILD_DOCS )
add_subdirectory( docs/API )
endif()

set( OTK_BUILD_DOCS ON CACHE BOOL "Enable build of OptiXToolkit documentation" )
if( OTK_BUILD_DOCS )
add_subdirectory( docs/API )
endif()
4 changes: 3 additions & 1 deletion DemandLoading/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ if(PROJECT_IS_TOP_LEVEL)
find_package(OptiXToolkit REQUIRED)
endif()

add_library( DemandLoading SHARED
option( BUILD_SHARED_LIBS "Build using shared libraries" ON )

add_library( DemandLoading
src/DemandLoaderImpl.cpp
src/DemandLoaderImpl.h
src/DeviceContextImpl.cpp
Expand Down
2 changes: 1 addition & 1 deletion DemandLoading/tests/TestTextureFootprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

#include <optix.h>
#include <optix_function_table_definition.h>
#include <optix_stack_size.h>
#include <optix_stubs.h>
#include <optix_stack_size.h>
#include <optix_types.h>

#include <gtest/gtest.h>
Expand Down
6 changes: 4 additions & 2 deletions Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ if(PROJECT_IS_TOP_LEVEL)
find_package(OptiXToolkit REQUIRED)
endif()

add_library(Gui SHARED
option( BUILD_SHARED_LIBS "Build using shared libraries" ON )

add_library(Gui
src/Camera.cpp
src/GLCheck.cpp
src/GLDisplay.cpp
Expand Down Expand Up @@ -78,7 +80,7 @@ target_link_libraries(Gui
OptiXToolkit::Util
PRIVATE
glfw
glad
glad::glad
)

set_target_properties(Gui PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
Expand Down
4 changes: 3 additions & 1 deletion ImageSource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ if(PROJECT_IS_TOP_LEVEL)
find_package(OptiXToolkit REQUIRED)
endif()

add_library( ImageSource SHARED
option( BUILD_SHARED_LIBS "Build using shared libraries" ON )

add_library( ImageSource
src/CheckerBoardImage.cpp
src/CoreEXRReader.cpp
src/DeviceConstantImage.cpp
Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,57 @@ make -j

If you encounter problems or if you have any questions, we encourage you to post on the [OptiX developer forum](https://forums.developer.nvidia.com/c/gaming-and-visualization-technologies/visualization/optix/167).

### Building statically linked libraries

OptiX Toolkit components are compiled into dynamic libraries (DSOs/DLLs) to simplify linking client
applications. This eliminates the need for client applications to link with third-party libraries
like OpenEXR and GLFW.

Some clients of the OptiX Toolkit might prefer to use statically linked libraries. This can be accomplished
by setting the CMake configuration variable `BUILD_SHARED_LIBS=OFF`.

Important: when building statically linked libraries, the CMake configuration variable
`OTK_FETCH_CONTENT` should be set to `OFF`, and various third party libraries must be installed as
described below.

### Installing third-party libraries.

Normally the OptiX Toolkit CMake files use `FetchContent` to download and build various third-party
libraries:
- Imath 3.1.5 or later
- OpenEXR 3.1.5 or later
- GLFW 3.3 or later
- glad (any recent version)

This behavior can be disabled by setting `OTK_FETCH_CONTENT=OFF` during CMake configuration,
which is necessary when building statically linked libraries, as described above.

When `FetchContent` is disabled, the following CMake configuration variables should be used to
specify the locations of the third-party libraries: `Imath_DIR`, `OpenEXR_DIR`, `glfw3_DIR`, and
`glad_DIR`. The directory specified for each of these variables should be the location of the
project's CMake configuration file. For example:
```
cd build
cmake \
-DBUILD_SHARED_LIBS=OFF \
-DOTK_FETCH_CONTENT=OFF \
-DImath_DIR=/usr/local/Imath/lib/cmake/Imath \
-DOpenEXR_DIR=/usr/local/OpenEXR/lib/cmake/OpenEXR \
-Dglfw3_DIR=/usr/local/glfw3/lib/cmake/glfw3 \
-Dglad_DIR=/usr/local/glad/lib/cmake/glad \
-DOptiX_ROOT_DIR=/usr/local/OptiX-SDK-7.5 \
..
```

As of this writing, OpenEXR 3.1 binaries are not yet available via most package managers, so we
recommend building these third party libraries from source code downloaded from the following
locations:

- Imath 3.1.5: https://github.com/AcademySoftwareFoundation/Imath.git
- OpenEXR 3.1.5: https://github.com/AcademySoftwareFoundation/openexr.git
- GLFW 3.3: https://github.com/glfw/glfw.git
- glad: https://github.com/Dav1dde/glad

## Troubleshooting

Problem: CMake configuration error: "could not find git for clone of glad-populate" <br>
Expand Down
4 changes: 3 additions & 1 deletion Util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ set(OptiX_INSTALL_DIR "OptiX_INSTALL_DIR-NOTFOUND" CACHE PATH "Path to OptiX ins
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CMake)
find_package(OptiX REQUIRED)

add_library(Util SHARED
option( BUILD_SHARED_LIBS "Build using shared libraries" ON )

add_library(Util
src/Exception.cpp
src/Files.cpp
)
Expand Down
1 change: 0 additions & 1 deletion Util/src/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <OptiXToolkit/Util/Exception.h>

#include <optix_function_table_definition.h>
#include <optix_stubs.h>

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion examples/DemandLoading/Texture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ target_link_libraries( demandLoadTexture
OptiXToolkit::DemandLoading
OptiXToolkit::Gui
OptiXToolkit::Util
glad
glad::glad
)

set_target_properties( demandLoadTexture PROPERTIES INSTALL_RPATH ${OptiXToolkit_DIR}/../../OptiXToolkit )
Expand Down

0 comments on commit dbc0303

Please sign in to comment.