Skip to content

Commit

Permalink
Update CMake for Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve J. Cai committed Sep 19, 2023
1 parent e71b23a commit 16e04f1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 23 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else()
set(DILIGENT_INSTALL_FX OFF)
endif()

target_link_libraries(DiligentFX
target_link_libraries(DiligentFX
PRIVATE
Diligent-BuildSettings
PUBLIC
Expand All @@ -36,7 +36,7 @@ add_subdirectory(Components)
add_subdirectory(PostProcess)
add_subdirectory(PBR)

if(DILIGENT_USD_PATH)
if(DILIGENT_USD_PATH OR pxr_FOUND)
add_subdirectory(Hydrogent)
endif()

Expand All @@ -46,7 +46,7 @@ endif()

get_target_property(SOURCE DiligentFX SOURCES)

foreach(FILE ${SOURCE})
foreach(FILE ${SOURCE})
# Get the directory of the source file
get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)

Expand Down Expand Up @@ -112,8 +112,8 @@ set_source_files_properties(
PROPERTIES GENERATED TRUE
)
target_sources(DiligentFX PRIVATE
# A target created in the same directory (CMakeLists.txt file) that specifies any output of the
# custom command as a source file is given a rule to generate the file using the command at build time.
# A target created in the same directory (CMakeLists.txt file) that specifies any output of the
# custom command as a source file is given a rule to generate the file using the command at build time.
${SHADERS_INC_LIST}
)
source_group("generated" FILES
Expand Down
64 changes: 48 additions & 16 deletions Hydrogent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ 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()

if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
if(pxr_FOUND)
# PXR is already loaded, so we can use its variables.
target_include_directories(Diligent-Hydrogent
PRIVATE
${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-*")
Expand Down Expand Up @@ -85,22 +93,11 @@ PUBLIC

# We need to enable RTTI for USD
add_library(EnableRTTI INTERFACE)
target_compile_options(EnableRTTI INTERFACE /GR)
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
target_compile_options(EnableRTTI INTERFACE /GR)
endif()

target_link_libraries(Diligent-Hydrogent
PUBLIC
usd_gf
usd_ar
usd_sdf
usd_tf
usd_usd
usd_plug
usd_hd
usd_usdImaging
usd_vt
usd_hio
usd_sdr
usd_ndr
PRIVATE
NO_WERROR
EnableRTTI # USD requires RTTI
Expand All @@ -112,6 +109,41 @@ PRIVATE
DiligentFX
)

if(pxr_FOUND)
target_link_libraries(Diligent-Hydrogent
PUBLIC
gf
ar
sdf
tf
usd
plug
hd
usdImaging
vt
hio
sdr
ndr
)
else()
target_link_libraries(Diligent-Hydrogent
PUBLIC
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()


if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS)
target_compile_definitions(Diligent-Hydrogent PRIVATE NOMINMAX)
endif()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Hydrogent/include/HnMaterialNetwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Hydrogent/include/HnMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <array>

// 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"

Expand Down
2 changes: 2 additions & 0 deletions Hydrogent/include/HnRendererImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class HnRendererImpl final : public ObjectBase<IHnRenderer>
pxr::HdRenderPassSharedPtr m_GeometryPass;
};

constexpr INTERFACE_ID HnRendererImpl::IID_Impl; // Needed only for C++ 14

} // namespace USD

} // namespace Diligent

0 comments on commit 16e04f1

Please sign in to comment.