Skip to content

Commit

Permalink
Establish NanoVDB as header-only external project
Browse files Browse the repository at this point in the history
  • Loading branch information
szellmann committed Dec 8, 2024
1 parent 6d842ed commit a063032
Show file tree
Hide file tree
Showing 71 changed files with 31,148 additions and 10 deletions.
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ project(anari_library_visionaray LANGUAGES C CXX)

include(GNUInstallDirs)

# build external libraries

add_subdirectory(external)

# note: we're often tracking the most recent changes from ANARI-SDK
# (on branch "next_release")
find_package(anari 0.10.0 REQUIRED)
Expand All @@ -33,9 +37,6 @@ endif()

option(ANARI_VISIONARAY_ENABLE_NANOVDB "Enable NanoVDB spatial field type" OFF)
set(nanovdb ${ANARI_VISIONARAY_ENABLE_NANOVDB})
if (nanovdb)
find_package(OpenVDB COMPONENTS nanovdb REQUIRED)
endif()

anari_generate_queries(
NAME visionaray
Expand Down Expand Up @@ -130,14 +131,16 @@ target_sources(${PROJECT_NAME} PRIVATE
if (nanovdb)
target_sources(${PROJECT_NAME} PRIVATE scene/volume/spatial_field/NanoVDBField.cpp)
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_NANOVDB=1)
target_link_libraries(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:vsnray_nanovdb>)
endif()

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME}
EXPORT_MACRO_NAME "VISIONARAY_DEVICE_INTERFACE"
)

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} PUBLIC
visionaray::visionaray anari::anari anari::helium)

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down Expand Up @@ -173,19 +176,25 @@ if (cuda)
target_compile_definitions(${PROJECT_NAME}_cuda PRIVATE WITH_CUDA=1)
if (nanovdb)
target_sources(${PROJECT_NAME}_cuda PRIVATE
scene/volume/spatial_field/NanoVDBField.cpp)
scene/volume/spatial_field/NanoVDBField.cu)
set_source_files_properties(
scene/volume/spatial_field/NanoVDBField.cu
PROPERTIES COMPILE_FLAGS "--extended-lambda --expt-relaxed-constexpr"
)
target_link_libraries(${PROJECT_NAME}_cuda PRIVATE
$<BUILD_INTERFACE:vsnray_nanovdb>)
target_compile_definitions(${PROJECT_NAME}_cuda PRIVATE WITH_NANOVDB=1)
endif()

generate_export_header(${PROJECT_NAME}_cuda
EXPORT_MACRO_NAME "VISIONARAY_DEVICE_INTERFACE"
)

target_link_libraries(${PROJECT_NAME}_cuda
target_link_libraries(${PROJECT_NAME}_cuda PUBLIC
visionaray::visionaray anari::anari anari::helium)

if (TARGET CUDA::cudart)
target_link_libraries(${PROJECT_NAME}_cuda CUDA::cudart)
target_link_libraries(${PROJECT_NAME}_cuda PUBLIC CUDA::cudart)
endif()

target_include_directories(${PROJECT_NAME}_cuda PUBLIC
Expand All @@ -205,9 +214,7 @@ if (hip)
)
target_compile_definitions(${PROJECT_NAME}_hip PRIVATE WITH_HIP=1)
if (nanovdb)
target_sources(${PROJECT_NAME}_hip PRIVATE
scene/volume/spatial_field/NanoVDBField.cpp)
target_compile_definitions(${PROJECT_NAME}_hip PRIVATE WITH_NANOVDB=1)
message(WARNING "No VDB support with HIP")
endif()

target_link_libraries(${PROJECT_NAME}_hip
Expand Down
3 changes: 3 additions & 0 deletions external/nanovdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project(vsnray_nanovdb LANGUAGES CXX CUDA)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR}/..)
Loading

0 comments on commit a063032

Please sign in to comment.