Use cmake configs to find USD

Also renamed `USD::` namespace to `pxr::` to match packaage name.
This commit is contained in:
Andrej730
2025-12-08 12:15:46 +05:00
parent 7a62f65af0
commit 9d828852c0
4 changed files with 31 additions and 22 deletions
+1 -1
View File
@@ -224,7 +224,7 @@ endif()
set(USD_LIBRARIES "")
if(USD_SUPPORT)
find_package(USD REQUIRED)
set(USD_LIBRARIES USD::USD)
set(USD_LIBRARIES pxr::USD)
endif(USD_SUPPORT)
if (WITH_ROCKSDB)
+21 -9
View File
@@ -5,17 +5,29 @@
# - `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?
# If `USD_INCLUDE_DIR` and `USD_LIBRARY_DIR` are not provided,
# try to find USD by locating its config file.
#
# Output targets:
# - `USD::USD`
# - `pxr::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(NOT USD_LIBRARY_DIR AND NOT USD_INCLUDE_DIR)
find_package(pxr CONFIG)
if(pxr_FOUND)
add_library(pxr::USD INTERFACE IMPORTED)
target_link_libraries(pxr::USD INTERFACE ${PXR_LIBRARIES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(USD REQUIRED_VARS pxr_DIR)
return()
endif()
endif()
if(NOT USD_INCLUDE_DIR)
find_path(USD_INCLUDE_DIR pxr.h
PATHS
@@ -65,31 +77,31 @@ else()
message(FATAL_ERROR "Unable to find USD libraries in: ${USD_LIBRARY_DIR}")
endif()
add_library(USD::USD INTERFACE IMPORTED)
target_link_directories(USD::USD
add_library(pxr::USD INTERFACE IMPORTED)
target_link_directories(pxr::USD
INTERFACE
${USD_LIBRARY_DIR} ${TBB_LIBRARY_DIR}
)
target_include_directories(USD::USD
target_include_directories(pxr::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
target_link_libraries(pxr::USD
INTERFACE
${USD_LIBRARIES}
)
if(MSVC)
target_link_libraries(USD::USD
target_link_libraries(pxr::USD
INTERFACE
debug DbgHelp.lib
)
endif()
target_compile_definitions(USD::USD
target_compile_definitions(pxr::USD
INTERFACE
PXR_STATIC WITH_USD
)
+4 -4
View File
@@ -1407,11 +1407,11 @@ else:
cmake_args.append("-DHDF5_SUPPORT=Off")
if "usd" in targets:
cmake_args.extend(
cmake_args.append("-DUSD_SUPPORT=ON")
cmake_args_prefix_path.extend(
[
f"-DUSD_SUPPORT=" "On",
f"-DUSD_INCLUDE_DIR={DEPS_DIR}/install/usd-{USD_VERSION}/include",
f"-DUSD_LIBRARY_DIR={DEPS_DIR}/install/usd-{USD_VERSION}/lib",
f"{DEPS_DIR}/install/tbb-{TBB_VERSION}",
f"{DEPS_DIR}/install/usd-{USD_VERSION}",
]
)
+5 -8
View File
@@ -118,10 +118,8 @@ set MPFR_LIBRARY_DIR=%INSTALL_DIR%\mpfr
:: We don't install Eigen currently,
:: so there's no Eigen3config.cmake and therefore we provide path explicitly.
set EIGEN_DIR=%INSTALL_DIR%\Eigen
set USD_INCLUDE_DIR=%INSTALL_DIR%\usd\include
set USD_LIBRARY_DIR=%INSTALL_DIR%\usd\lib
set TBB_INCLUDE_DIR=%INSTALL_DIR%\tbb\include
set TBB_LIBRARY_DIR=%INSTALL_DIR%\tbb\lib
set TBB_INSTALL_DIR=%INSTALL_DIR%\tbb
set USD_INSTALL_DIR=%INSTALL_DIR%\usd
set ROCKSDB_INSTALL_DIR=%INSTALL_DIR%\rocksdb
set ZSTD_INSTALL_DIR=%INSTALL_DIR%\zstd
@@ -155,10 +153,8 @@ echo GMP_LIBRARY_DIR = %GMP_LIBRARY_DIR%
echo MPFR_INCLUDE_DIR = %MPFR_INCLUDE_DIR%
echo MPFR_LIBRARY_DIR = %MPFR_LIBRARY_DIR%
echo EIGEN_DIR = %EIGEN_DIR%
echo USD_INCLUDE_DIR = %USD_INCLUDE_DIR%
echo USD_LIBRARY_DIR = %USD_LIBRARY_DIR%
echo TBB_INCLUDE_DIR = %TBB_INCLUDE_DIR%
echo TBB_LIBRARY_DIR = %TBB_LIBRARY_DIR%
echo TBB_INSTALL_DIR = %TBB_INSTALL_DIR%
echo USD_INSTALL_DIR = %USD_INSTALL_DIR%
echo ROCKSDB_INSTALL_DIR = %ROCKSDB_INSTALL_DIR%
echo ZSTD_INSTALL_DIR = %ZSTD_INSTALL_DIR%
echo CCACHE_INSTALL_DIR = %CCACHE_INSTALL_DIR%
@@ -174,6 +170,7 @@ echo "Running CMake for %PROJECT_NAME%."
set CMAKE_PREFIX_PATH=%HDF5_INSTALL_DIR%;%OPENCOLLADA_INSTALL_DIR%;%SWIG_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROCKSDB_INSTALL_DIR%;%ZSTD_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%BOOST_INSTALL_DIR%;%CCACHE_INSTALL_DIR%
set CMake_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%USD_INSTALL_DIR%;%TBB_INSTALL_DIR%
:: Not fully supported - not available from install-ifcopenshell
:: and some logs are still showing Visual Studio generators.