From 33be57faac0edb39192fe3b78d543edefc219a27 Mon Sep 17 00:00:00 2001 From: "Steve J. Cai" Date: Fri, 22 Sep 2023 03:47:50 +0000 Subject: [PATCH] Build for emscripten --- Hydrogent/CMakeLists.txt | 64 ++++++++++++++++++------- Hydrogent/{readme.md => README.md} | 0 Hydrogent/include/HnMaterialNetwork.hpp | 2 +- Hydrogent/include/HnMesh.hpp | 2 +- Hydrogent/include/HnRendererImpl.hpp | 2 + 5 files changed, 50 insertions(+), 20 deletions(-) rename Hydrogent/{readme.md => README.md} (100%) diff --git a/Hydrogent/CMakeLists.txt b/Hydrogent/CMakeLists.txt index 1a8f4c52..e8680106 100644 --- a/Hydrogent/CMakeLists.txt +++ b/Hydrogent/CMakeLists.txt @@ -35,11 +35,19 @@ add_library(Diligent-Hydrogent STATIC README.md ${SOURCE} ${INCLUDE} ${INTERFACE set_common_target_properties(Diligent-Hydrogent) -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(NOT PLATFORM_EMSCRIPTEN) + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +endif() add_library(USD_LIBS INTERFACE) -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +if(pxr_FOUND) + # PXR is already loaded, so we can use its variables. + target_include_directories(USD_LIBS + INTERFACE + ${PXR_INCLUDE_DIRS} + ) +elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio") # Boost version depends on Visual Studio version. Since we can't use wildcards in # generator expressions, we have to find boost directory for each configuration file(GLOB BOOST_INCLUDE_DEBUG "${DILIGENT_USD_PATH}/Debug/include/boost-*") @@ -82,21 +90,39 @@ if(MSVC) target_compile_options(USD_LIBS INTERFACE /wd4244 /wd4305 /wd4127 /wd4267) endif() -target_link_libraries(USD_LIBS -INTERFACE - usd_gf - usd_ar - usd_sdf - usd_tf - usd_usd - usd_plug - usd_hd - usd_usdImaging - usd_vt - usd_hio - usd_sdr - usd_ndr -) +if(pxr_FOUND) + target_link_libraries(USD_LIBS + INTERFACE + gf + ar + sdf + tf + usd + plug + hd + usdImaging + vt + hio + sdr + ndr + ) +else() + target_link_libraries(USD_LIBS + INTERFACE + usd_gf + usd_ar + usd_sdf + usd_tf + usd_usd + usd_plug + usd_hd + usd_usdImaging + usd_vt + usd_hio + usd_sdr + usd_ndr + ) +endif() target_include_directories(Diligent-Hydrogent PUBLIC @@ -112,7 +138,9 @@ PUBLIC # We need to enable RTTI for USD add_library(EnableRTTI INTERFACE) -target_compile_options(EnableRTTI INTERFACE /GR) +if(MSVC) + target_compile_options(EnableRTTI INTERFACE /GR) +endif() target_link_libraries(Diligent-Hydrogent PRIVATE diff --git a/Hydrogent/readme.md b/Hydrogent/README.md similarity index 100% rename from Hydrogent/readme.md rename to Hydrogent/README.md diff --git a/Hydrogent/include/HnMaterialNetwork.hpp b/Hydrogent/include/HnMaterialNetwork.hpp index 2d1d18e7..9f383c67 100644 --- a/Hydrogent/include/HnMaterialNetwork.hpp +++ b/Hydrogent/include/HnMaterialNetwork.hpp @@ -27,7 +27,7 @@ #pragma once // NoteL tbb.h must be included first to avoid compilation errors in tbb headers. -#include "tbb/tbb.h" +// #include "tbb/tbb.h" #include "pxr/base/vt/dictionary.h" #include "pxr/usd/sdf/path.h" diff --git a/Hydrogent/include/HnMesh.hpp b/Hydrogent/include/HnMesh.hpp index c457ad75..6f79f7c9 100644 --- a/Hydrogent/include/HnMesh.hpp +++ b/Hydrogent/include/HnMesh.hpp @@ -30,7 +30,7 @@ #include // NoteL tbb.h must be included before mesh.h to avoid compilation errors in tbb headers. -#include "tbb/tbb.h" +// #include "tbb/tbb.h" #include "pxr/imaging/hd/mesh.h" #include "pxr/base/tf/token.h" diff --git a/Hydrogent/include/HnRendererImpl.hpp b/Hydrogent/include/HnRendererImpl.hpp index 88b0b053..b89db9f9 100644 --- a/Hydrogent/include/HnRendererImpl.hpp +++ b/Hydrogent/include/HnRendererImpl.hpp @@ -111,6 +111,8 @@ class HnRendererImpl final : public ObjectBase GPUCompletionAwaitQueue> m_MeshIdReadBackQueue; }; +constexpr INTERFACE_ID HnRendererImpl::IID_Impl; // Needed only for C++ 14 + } // namespace USD } // namespace Diligent