Skip to content

Commit

Permalink
Update vcpkg discussion in README.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLeone committed Aug 25, 2023
1 parent c90e973 commit 9f9314a
Showing 1 changed file with 38 additions and 44 deletions.
82 changes: 38 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ After checking out the OptiX Toolkit repository, be sure to initialize the submo
```
git submodule update --init --recursive
```
Alternatively, a subset of the submodules can be specified. For example, the DemandLoading library
Alternatively, a subset of the submodules can be specified. For example, the OTK memory allocator library
can be built in isolation by initializing its submodule, along with the submodules upon which it depends:
```
git submodule update --init --recursive DemandLoading Memory ShaderUtil CMake
git submodule update --init --recursive Memory CMake
```

## Requirements
Expand All @@ -31,70 +31,41 @@ git submodule update --init --recursive DemandLoading Memory ShaderUtil CMake
- Using the latest CMake is highly recommended, to ensure up-to-date CUDA language support.
- CUDA 11.1 or later ([download](https://developer.nvidia.com/cuda-downloads))
- OptiX 7.3 or later ([download](https://developer.nvidia.com/designworks/optix/download))
- Other third-party libraries are downloaded and built on demand (see below).

On some Linux systems it may be necessary to install some commonly used developer packages with the following commands:
```
sudo apt-get install curl git-lfs pkg-config
git lfs install
```
Building the OptiX Toolkit examples requires an OpenGL development environment. On most Linux systems the necessary packages can be installed using the following command:
Building the examples included with the OptiX Toolkit requires an OpenGL development environment.
On most Linux systems the necessary packages can be installed using the following command:
```
sudo apt-get install libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev mesa-common-dev
sudo apt-get install libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev mesa-common-dev
```

### Third-party libraries

The OptiX Toolkit build system employs a "download if missing" workflow. The following third-party libraries
are downloaded and built if necessary:
- Imath 3.1.5 or later
- OpenEXR 3.1.5 or later
- GLFW 3.3 or later
- glad (any recent version)

The DemandLoading library can optionally employ OpenImageIO (if installed) to read image files.
However, OpenImageIO is not downloaded if missing.

### Using vcpkg

Alternatively, [vcpkg](https://github.com/microsoft/vcpkg) is a convenient way to provide the third-party libraries required by OTK.
First, create a local `vcpkg` repository as follows:
```
git clone https://github.com/microsoft/vcpkg
./vcpkg/bootstrap-vcpkg
./vcpkg/vcpkg integrate install
```
The final step will print the path to a "toolchain file" that should be provided during CMake configuration, e.g.
```
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg.cmake [...]
```
OTK provides a `vcpkg` manifest (called [vcpkg.json](https://github.com/NVIDIA/optix-toolkit/blob/master/vcpkg.json))
that specifies which third-party libraries are required. CMake invokes `vcpkg` to download and
build these packages during configuration.

Tip: if you use an existing `vcpkg` repository, be sure to update it (using `git pull`) before configuring OTK to ensure
that up-to-date versions of third-party libraries are used (particularly OpenEXR).

## Building the OptiX Toolkit

- In the directory containing the OTK source code, create a subdirectory called `build` and `cd` to that directory.
```
mkdir build
cd build
```
- Configure CMake, specifying the location of the OptiX SDK and (optionally) the `vcpkg` toolchain file. This can be accomplished using `cmake-gui` or by entering the following command in a terminal window. (Note that `..` specifies the path to the source code in the parent directory.)
- Configure CMake, specifying the location of the OptiX SDK. This can be accomplished using `cmake-gui` or by entering the following command in a terminal window. (Note that `..` specifies the path to the source code in the parent directory.)
```
cmake -DOptiX_INSTALL_DIR=/path/to/optix -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg.cmake ..
cmake -DOptiX_INSTALL_DIR=/path/to/optix ..
```
Under Windows, be sure to use a
Under Windows, be sure to use a
[Visual Studio developer console](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell)
or use the `vcvarsall.bat` batch file to set up necessary environment variables. It might also be
necessary to specify a generator and a toolset under Windows:
```
cmake -G "Visual Studio 15 2017 Win64" -T host=x64 -DOptiX_INSTALL_DIR=/path/to/optix -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg.cmake ..
cmake -G "Visual Studio 15 2017 Win64" -T host=x64 -DOptiX_INSTALL_DIR=/path/to/optix ..
```
- If the configuration is successful, build the OTK libraries.
* Under Windows, simply load the Visual Studio solution file from the `build` directory.
* Under Linux, run `make -j` in the `build` directory.

- Alternatively, building with [Ninja](https://ninja-build.org/) works well under both Linux and Windows.
```
cmake -G Ninja [...]
Expand All @@ -103,11 +74,34 @@ ninja

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).

### Disabling FetchContent
## Third-party libraries

The OptiX Toolkit build system employs a "download if missing" workflow. The following third-party libraries
are downloaded and built if necessary:
- Imath 3.1.5 or later
- OpenEXR 3.1.5 or later
- GLFW 3.3 or later
- glad (any recent version)

The DemandLoading library can optionally employ OpenImageIO to read image files (see below).

### vcpkg

The OptiX Toolkit repository uses [vcpkg](https://github.com/microsoft/vcpkg) to download and build
third party libraries. OTK includes the `vcpkg` repository as a submodule and generates a `vcpkg`
manifest that specifies which third-party libraries are required. CMake then invokes `vcpkg` to
download and build these packages during configuration.

The use of `vcpkg` can be disabled by configuring with `OTK_USE_VCPKG=OFF`. It is disabled by
default if the OTK repository is included as a submodule within another project (because generating
a top-level `vcpkg` manifest is presumptuous under such circumstances).

### FetchContent

The OptiX Toolkit uses CMake's `FetchContent` feature to download and build any missing third-party libraries.
The use of `FetchContent` can be disabled by setting `OTK_FETCH_CONTENT=OFF` during CMake configuration,
which is necessary when building statically linked libraries, as described below.
If `vcpkg` is disabled, the OptiX Toolkit can use CMake's `FetchContent` feature to download and build
any missing third-party libraries. The use of `FetchContent` can be disabled by setting
`OTK_FETCH_CONTENT=OFF` during CMake configuration, which is necessary when building statically
linked libraries, as described below.

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
Expand Down

0 comments on commit 9f9314a

Please sign in to comment.