Skip to content

Commit

Permalink
Merge pull request AcademySoftwareFoundation#1232 from apradhana/Fix_…
Browse files Browse the repository at this point in the history
…Building_NanoVDB_From_Root_Without_OpenVDB

Fix installing nanovdb from the root openvdb build directory.
  • Loading branch information
apradhana authored Oct 29, 2021
2 parents 431dc10 + c9ad78e commit 355598d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,19 @@ if(USE_STATIC_DEPENDENCIES)
endif()

# Configure OpenVDB Library and ABI versions
set(NEEDS_OPENVDB OFF)

if(OPENVDB_BUILD_AX OR
OPENVDB_BUILD_BINARIES OR
OPENVDB_BUILD_UNITTESTS OR
OPENVDB_BUILD_HOUDINI_PLUGIN OR
OPENVDB_BUILD_MAYA_PLUGIN OR
OPENVDB_BUILD_PYTHON_MODULE OR
OPENVDB_BUILD_HOUDINI_ABITESTS)
set(NEEDS_OPENVDB ON)
endif()

if(NOT OPENVDB_BUILD_CORE)
if(NOT OPENVDB_BUILD_CORE AND NEEDS_OPENVDB)
# Find VDB installation and determine lib/abi versions. This resets the
# version and ABI numbers
find_package(OpenVDB REQUIRED)
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,49 @@ cd build
cmake -DCMAKE_TOOLCHAIN_FILE=<PATH_TO_VCPKG>\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -A x64 ..
cmake --build . --parallel 4 --config Release --target install
```

#### Building NanoVDB

**First example: building NanoVDB and OpenVDB core**

NanoVDB is now a module of the larger OpenVDB project. A user can build both libraries together. This will build the OpenVDB core library, install the NanoVDB header files, and build the NanoVDB command-line tools in the `build/nanovdb/cmd` directory. From the 'root' OpenVDB project directory (change the dependency paths to match your environment):
```console
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DUSE_NANOVDB=ON -DTBB_ROOT=/path/to/tbb -DBOOST_ROOT=/path/to/boost -DBLOSC_ROOT=/path/to/blosc -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```
Note that the default value of `NANOVDB_USE_OPENVDB` is linked to `OPENVDB_BUILD_CORE` option and can be overriden by passing on `-DNANOVDB_USE_OPENVDB=OFF`. The `Boost` library is included because it is a requirement for building OpenVDB.

In general, CMake will try to find every optional dependency when a user opts to add an additional dependency. Be sure to check the CMake log to see what dependencies were **not** found.

**Second example: NanoVDB with no dependencies**

From the 'root' OpenVDB project directory:
```console
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DUSE_NANOVDB=ON -DOPENVDB_BUILD_CORE=OFF -DOPENVDB_BUILD_BINARIES=OFF -DNANOVDB_USE_TBB=OFF -DNANOVDB_USE_BLOSC=OFF -DNANOVDB_USE_ZLIB=OFF -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```

Another option is to build it from the NanoVDB directory itself, which is much simpler:
```console
foo@bar:~$ cd nanovdb/nanovdb
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```
Both options will install the NanoVDB header files to the `/install/path` as well as building `nanovdb_print` and `nanovdb_validate` executable. The path where these executables are installed will be different: in the first option they will be under `build/nanovdb/cmd` directory; whilst in the second option they will be under the `build/cmd/` directory.

**Third example: build 'everything' in NanoVDB along with OpenVDB core**

From the root OpenVDB directory:
```console
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DUSE_NANOVDB=ON -DNANOVDB_BUILD_UNITTESTS=ON -DNANOVDB_BUILD_EXAMPLES=ON -DNANOVDB_BUILD_BENCHMARK=ON -DNANOVDB_USE_INTRINSICS=ON -DNANOVDB_USE_CUDA=ON -DNANOVDB_CUDA_KEEP_PTX=ON -DTBB_ROOT=/path/to/tbb -DBOOST_ROOT=/path/to/boost -DBLOSC_ROOT=/path/to/blosc -DGTEST_ROOT=/path/to/gtest -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```
Note that if you already have the correct version of OpenVDB pre-installed, you can configure CMake to link against that library by passing the arguments `-DOPENVDB_BUILD_CORE=OFF -DOPENVDB_BUILD_BINARIES=OFF -DOPENVDB_ROOT=/path/to/openvdb` when invoking `cmake`.
14 changes: 11 additions & 3 deletions doc/nanovdb/HowToBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ In general, CMake will try to find every optional dependency when a user opts to

## Second example: NanoVDB with no dependencies

The simplest way is to build it from the NanoVDB directory itself:
From the 'root' OpenVDB project directory:
```console
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DUSE_NANOVDB=ON -DOPENVDB_BUILD_CORE=OFF -DOPENVDB_BUILD_BINARIES=OFF -DNANOVDB_USE_TBB=OFF -DNANOVDB_USE_BLOSC=OFF -DNANOVDB_USE_ZLIB=OFF -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```

Another option is to build it from the NanoVDB directory itself, which is much simpler:
```console
foo@bar:~$ cd nanovdb/nanovdb
foo@bar:~$ mkdir build
foo@bar:~$ cd build
foo@bar:~$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```
This will install the NanoVDB header files to the `/install/path` as well as building `nanovdb_print` and `nanovdb_validate` executable.
Both options will install the NanoVDB header files to the `/install/path` as well as building `nanovdb_print` and `nanovdb_validate` executable. The path where these executables are installed will be different: in the first option they will be under `build/nanovdb/cmd` directory; whilst in the second option they will be under the `build/cmd/` directory.

## Third example: build 'everything' in NanoVDB along with OpenVDB core

Expand All @@ -44,4 +52,4 @@ From the root OpenVDB directory:
foo@bar:~$ cmake .. -DUSE_NANOVDB=ON -DNANOVDB_BUILD_UNITTESTS=ON -DNANOVDB_BUILD_EXAMPLES=ON -DNANOVDB_BUILD_BENCHMARK=ON -DNANOVDB_USE_INTRINSICS=ON -DNANOVDB_USE_CUDA=ON -DNANOVDB_CUDA_KEEP_PTX=ON -DTBB_ROOT=/path/to/tbb -DBOOST_ROOT=/path/to/boost -DBLOSC_ROOT=/path/to/blosc -DGTEST_ROOT=/path/to/gtest -DCMAKE_INSTALL_PREFIX=/install/path
foo@bar:~$ make -j 4 && make install
```
Note that if you already have the correct version of OpenVDB pre-installed, you can configure CMake to link against that library by passing the arguments `-DOPENVDB_BUILD_CORE=OFF -DOPENVDB_BUILD_UNITTESTS=OFF -DOPENVDB_ROOT=/path/to/openvdb` when invoking `cmake`.
Note that if you already have the correct version of OpenVDB pre-installed, you can configure CMake to link against that library by passing the arguments `-DOPENVDB_BUILD_CORE=OFF -DOPENVDB_BUILD_BINARIES=OFF -DOPENVDB_ROOT=/path/to/openvdb` when invoking `cmake`.

0 comments on commit 355598d

Please sign in to comment.