cmake - make USD_SUPPORT build succeed

This commit is contained in:
Andrej730
2025-12-05 20:16:33 +05:00
parent 2213c3773d
commit d174ecf760
3 changed files with 54 additions and 6 deletions
+2 -2
View File
@@ -222,8 +222,10 @@ if(GLTF_SUPPORT)
endif()
# Add USD support to serializers
set(USD_LIBRARIES "")
if(USD_SUPPORT)
find_package(USD REQUIRED)
set(USD_LIBRARIES USD::USD)
endif(USD_SUPPORT)
if (WITH_ROCKSDB)
@@ -432,8 +434,6 @@ endif(MSVC)
include_directories(${OPENCOLLADA_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR}
${USD_INCLUDE_DIR}
${TBB_INCLUDE_DIR}
)
if(NOT SCHEMA_VERSIONS)
+47 -4
View File
@@ -2,17 +2,21 @@
# Input variables:
# - `USD_INCLUDE_DIR`
# - `USD_LIBRARY_DIR`
# - `TBB_INCLUDE_DIR`
# - `TBB_LIBRARY_DIR`
# Input variables could also be provided as environment variables.
# TODO: Try to find USD config if varibales are not provided.
# TODO: does usd have a config file?
#
# Output variables:
# - `USD_LIBRARIES`
# Output targets:
# - `USD::USD`
UNIFY_ENVVARS_AND_CACHE(USD_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(USD_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(TBB_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(TBB_LIBRARY_DIR)
if("${USD_INCLUDE_DIR}" STREQUAL "")
if(NOT USD_INCLUDE_DIR)
find_path(USD_INCLUDE_DIR pxr.h
PATHS
/usr/include/pxr
@@ -38,6 +42,17 @@ set(USD_LIBRARIES
usd_sdf
usd_tf
usd_gf
usd_kind
usd_pcp
usd_arch
usd_ar
usd_plug
usd_js
usd_sdr
usd_work
usd_trace
usd_ndr
usd_ts
)
find_library(USD_LIBRARY
@@ -50,5 +65,33 @@ else()
message(FATAL_ERROR "Unable to find USD libraries in: ${USD_LIBRARY_DIR}")
endif()
add_definitions(-DWITH_USD)
add_library(USD::USD INTERFACE IMPORTED)
target_link_directories(USD::USD
INTERFACE
${USD_LIBRARY_DIR} ${TBB_LIBRARY_DIR}
)
target_include_directories(USD::USD
INTERFACE
${USD_INCLUDE_DIR} ${TBB_INCLUDE_DIR}
)
# We don't link TBB libraries - on Windows they're provided using `pragma(lib)`.
# On Unix there's no `pragma(lib)`, so in theory it will break.
target_link_libraries(USD::USD
INTERFACE
${USD_LIBRARIES}
)
if(MSVC)
target_link_libraries(USD::USD
INTERFACE
debug DbgHelp.lib
)
endif()
target_compile_definitions(USD::USD
INTERFACE
PXR_STATIC WITH_USD
)
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_USD)
+5
View File
@@ -30,6 +30,8 @@
#include "../ifcparse/utils.h"
// undefine opencascade Handle macro, because it conflicts with USD
// Macro source code lives in Standard_Handle.hxx.
#pragma push_macro("Handle")
#undef Handle
#include "pxr/pxr.h"
@@ -38,6 +40,9 @@
#include "pxr/usd/usdGeom/mesh.h"
#include "pxr/usd/usdShade/material.h"
// redefine Handle macro.
#pragma pop_macro("Handle")
#include <vector>
#include <string>
#include <algorithm>