Skip to content

Commit

Permalink
Consolidate SKBUILD logic
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Cong <[email protected]>
  • Loading branch information
matthewdcong committed Oct 29, 2024
1 parent 40d1089 commit 18ad210
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 128 deletions.
30 changes: 25 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,30 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# Add cmake modules to installation command

if(SKBUILD)
set(OPENVDB_INSTALL_BINDIR openvdb/${CMAKE_INSTALL_BINDIR})
set(OPENVDB_INSTALL_LIBDIR openvdb/${CMAKE_INSTALL_LIBDIR})
set(OPENVDB_INSTALL_INCLUDEDIR openvdb/${CMAKE_INSTALL_INCLUDEDIR})

if(OPENVDB_BUILD_NANOVDB)
set(NANOVDB_INSTALL_BINDIR nanovdb/${CMAKE_INSTALL_BINDIR})
set(NANOVDB_INSTALL_LIBDIR nanovdb/${CMAKE_INSTALL_LIBDIR})
set(NANOVDB_INSTALL_INCLUDEDIR nanovdb/${CMAKE_INSTALL_INCLUDEDIR})
set(NANOVDB_INSTALL_DOCDIR nanovdb/${CMAKE_INSTALL_DOCDIR})
endif()
else()
set(OPENVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
set(OPENVDB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(OPENVDB_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})

if(OPENVDB_BUILD_NANOVDB)
set(NANOVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
set(NANOVDB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(NANOVDB_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(NANOVDB_INSTALL_DOCDIR ${CMAKE_INSTALL_DOCDIR})
endif()
endif()

if(OPENVDB_INSTALL_CMAKE_MODULES)
set(OPENVDB_CMAKE_MODULES
cmake/FindBlosc.cmake
Expand All @@ -298,11 +322,7 @@ if(OPENVDB_INSTALL_CMAKE_MODULES)
cmake/OpenVDBMayaSetup.cmake
cmake/OpenVDBUtils.cmake
)
if(SKBUILD)
install(FILES ${OPENVDB_CMAKE_MODULES} DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}/cmake/OpenVDB)
else()
install(FILES ${OPENVDB_CMAKE_MODULES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenVDB)
endif()
install(FILES ${OPENVDB_CMAKE_MODULES} DESTINATION ${OPENVDB_INSTALL_LIBDIR}/cmake/OpenVDB)
endif()

# Configure component dependencies by loading the Houdini/Maya setup
Expand Down
18 changes: 7 additions & 11 deletions nanovdb/nanovdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,16 @@ if(TARGET Threads::Threads)
target_link_libraries(nanovdb INTERFACE Threads::Threads)
endif()

if(SKBUILD)
set(NANOVDB_INSTALL_INCLUDE_DIR nanovdb/${CMAKE_INSTALL_INCLUDEDIR}/nanovdb)
else()
set(NANOVDB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/nanovdb)
endif()
set(NANOVDB_INSTALL_CUDA_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/cuda)
set(NANOVDB_INSTALL_IO_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/io)
set(NANOVDB_INSTALL_MATH_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/math)
set(NANOVDB_INSTALL_TOOLS_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/tools)
set(NANOVDB_INSTALL_ROOT_DIR ${NANOVDB_INSTALL_INCLUDEDIR}/nanovdb)
set(NANOVDB_INSTALL_CUDA_DIR ${NANOVDB_INSTALL_ROOT_DIR}/cuda)
set(NANOVDB_INSTALL_IO_DIR ${NANOVDB_INSTALL_ROOT_DIR}/io)
set(NANOVDB_INSTALL_MATH_DIR ${NANOVDB_INSTALL_ROOT_DIR}/math)
set(NANOVDB_INSTALL_TOOLS_DIR ${NANOVDB_INSTALL_ROOT_DIR}/tools)
set(NANOVDB_INSTALL_TOOLS_CUDA_DIR ${NANOVDB_INSTALL_TOOLS_DIR}/cuda)
set(NANOVDB_INSTALL_UTIL_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/util)
set(NANOVDB_INSTALL_UTIL_DIR ${NANOVDB_INSTALL_ROOT_DIR}/util)
set(NANOVDB_INSTALL_UTIL_CUDA_DIR ${NANOVDB_INSTALL_UTIL_DIR}/cuda)

install(FILES ${NANOVDB_INCLUDE_FILES} DESTINATION ${NANOVDB_INSTALL_INCLUDE_DIR})
install(FILES ${NANOVDB_INCLUDE_FILES} DESTINATION ${NANOVDB_INSTALL_ROOT_DIR})
install(FILES ${NANOVDB_INCLUDE_CUDA_FILES} DESTINATION ${NANOVDB_INSTALL_CUDA_DIR})
install(FILES ${NANOVDB_INCLUDE_IO_FILES} DESTINATION ${NANOVDB_INSTALL_IO_DIR})
install(FILES ${NANOVDB_INCLUDE_MATH_FILES} DESTINATION ${NANOVDB_INSTALL_MATH_DIR})
Expand Down
6 changes: 0 additions & 6 deletions nanovdb/nanovdb/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ endif()

# -----------------------------------------------------------------------------

if(SKBUILD)
set(NANOVDB_INSTALL_BINDIR nanovdb/${CMAKE_INSTALL_BINDIR})
else()
set(NANOVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
endif()

if(NOT NANOVDB_USE_OPENVDB)
message(WARNING " - OpenVDB required to build nanovdb_convert. Skipping.")
else()
Expand Down
6 changes: 1 addition & 5 deletions nanovdb/nanovdb/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ function(NANOVDB_EXAMPLE)
target_include_directories(${EXAMPLE_NAME} PUBLIC ex_util)
target_link_libraries(${EXAMPLE_NAME} PRIVATE nanovdb)

if(SKBUILD)
install(TARGETS ${EXAMPLE_NAME} DESTINATION nanovdb/${CMAKE_INSTALL_DOCDIR}/examples)
else()
install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
endif()
install(TARGETS ${EXAMPLE_NAME} DESTINATION ${NANOVDB_INSTALL_DOCDIR}/examples)
endfunction()

# -----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion nanovdb/nanovdb/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ target_compile_definitions(nanovdb_python PRIVATE ${NANOVDB_USE_CUDA_FLAG} ${NAN
set_target_properties(nanovdb_python PROPERTIES OUTPUT_NAME "nanovdb")
if(SKBUILD)
set_target_properties(nanovdb_python PROPERTIES INSTALL_RPATH "$ORIGIN/../../openvdb/lib")
install(TARGETS nanovdb_python DESTINATION nanovdb/${CMAKE_INSTALL_LIBDIR})
install(TARGETS nanovdb_python DESTINATION ${NANOVDB_INSTALL_LIBDIR})
install(FILES __init__.py DESTINATION nanovdb)
else()
install(TARGETS nanovdb_python DESTINATION ${VDB_PYTHON_INSTALL_DIRECTORY})
Expand Down
77 changes: 24 additions & 53 deletions openvdb/openvdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -718,58 +718,29 @@ endif()

# Installation

if(SKBUILD)
if(OPENVDB_CORE_STATIC)
install(TARGETS openvdb_static
RUNTIME DESTINATION openvdb/${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
)
endif()

if(OPENVDB_CORE_SHARED)
install(TARGETS openvdb_shared
RUNTIME DESTINATION openvdb/${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
)
endif()

install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/io)
install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/math)
install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points)
install(FILES ${OPENVDB_LIBRARY_POINTS_IMPL_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points/impl)
install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tools)
install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tree)
install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/util)
install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb/thread)
else()
if(OPENVDB_CORE_STATIC)
install(TARGETS openvdb_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()

if(OPENVDB_CORE_SHARED)
install(TARGETS openvdb_shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
if(OPENVDB_CORE_STATIC)
install(TARGETS openvdb_static
RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}
LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR}
)
endif()

install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/io)
install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/math)
install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points)
install(FILES ${OPENVDB_LIBRARY_POINTS_IMPL_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points/impl)
install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tools)
install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tree)
install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/util)
install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/thread)
if(OPENVDB_CORE_SHARED)
install(TARGETS openvdb_shared
RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}
LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR}
)
endif()

install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/io)
install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/math)
install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/points)
install(FILES ${OPENVDB_LIBRARY_POINTS_IMPL_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/points/impl)
install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/tools)
install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/tree)
install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/util)
install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/thread)
2 changes: 1 addition & 1 deletion openvdb/openvdb/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif()
set_target_properties(openvdb_python PROPERTIES OUTPUT_NAME "openvdb")
if(SKBUILD)
set_target_properties(openvdb_python PROPERTIES INSTALL_RPATH "$ORIGIN")
install(TARGETS openvdb_python DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR})
install(TARGETS openvdb_python DESTINATION ${OPENVDB_INSTALL_LIBDIR})
install(FILES __init__.py DESTINATION openvdb)
else()
install(TARGETS openvdb_python DESTINATION ${VDB_PYTHON_INSTALL_DIRECTORY})
Expand Down
57 changes: 17 additions & 40 deletions openvdb_ax/openvdb_ax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,46 +354,23 @@ if(OPENVDB_AX_SHARED)
endif()
endif()

if(SKBUILD)
install(FILES ax.h Exceptions.h DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/)
install(FILES ${OPENVDB_AX_AST_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/ast)
install(FILES ${OPENVDB_AX_CODEGEN_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/codegen)
install(FILES ${OPENVDB_AX_COMPILER_INCLUDE_FILES} DESTINATION openvdb/${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/compiler)

if(OPENVDB_AX_STATIC)
install(TARGETS openvdb_ax_static
RUNTIME DESTINATION openvdb/${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
)
endif()
install(FILES ax.h Exceptions.h DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/)
install(FILES ${OPENVDB_AX_AST_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/ast)
install(FILES ${OPENVDB_AX_CODEGEN_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/codegen)
install(FILES ${OPENVDB_AX_COMPILER_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/compiler)

if(OPENVDB_AX_SHARED)
install(TARGETS openvdb_ax_shared
RUNTIME DESTINATION openvdb/${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION openvdb/${CMAKE_INSTALL_LIBDIR}
)
endif()
else()
install(FILES ax.h Exceptions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/)
install(FILES ${OPENVDB_AX_AST_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/ast)
install(FILES ${OPENVDB_AX_CODEGEN_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/codegen)
install(FILES ${OPENVDB_AX_COMPILER_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/compiler)

if(OPENVDB_AX_STATIC)
install(TARGETS openvdb_ax_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
if(OPENVDB_AX_STATIC)
install(TARGETS openvdb_ax_static
RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}
LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR}
)
endif()

if(OPENVDB_AX_SHARED)
install(TARGETS openvdb_ax_shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
if(OPENVDB_AX_SHARED)
install(TARGETS openvdb_ax_shared
RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}
LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR}
)
endif()
6 changes: 0 additions & 6 deletions openvdb_cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ endif()

##########################################################################

if(SKBUILD)
set(OPENVDB_INSTALL_BINDIR openvdb/${CMAKE_INSTALL_BINDIR})
else()
set(OPENVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
endif()

if (OPENVDB_BUILD_VDB_PRINT)
add_subdirectory(vdb_print)
endif()
Expand Down

0 comments on commit 18ad210

Please sign in to comment.