Skip to content

Commit

Permalink
Hydrogent: fixed Emscripten CMake configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 27, 2023
1 parent 2709931 commit bfa3e6c
Showing 1 changed file with 56 additions and 44 deletions.
100 changes: 56 additions & 44 deletions Hydrogent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,98 +60,102 @@ set(SHADER_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shaders_inc)
set(SHADERS_LIST_FILE ${SHADER_OUTPUT_DIR}/shaders_list.h)
convert_shaders_to_headers("${SHADERS}" ${SHADER_OUTPUT_DIR} ${SHADERS_LIST_FILE} SHADERS_INC_LIST)

set(HYDROGENT_SOURCE ${SOURCE} ${INCLUDE} ${INTERFACE} ${SHADERS} ${SHADERS_LIST_FILE} ${SHADERS_INC_LIST} README.md)
set(HYDROGENT_SOURCE ${SOURCE} ${INCLUDE} ${INTERFACE} ${SHADERS} ${SHADERS_LIST_FILE} ${SHADERS_INC_LIST} readme.md)
add_library(Diligent-Hydrogent STATIC ${HYDROGENT_SOURCE})

set_common_target_properties(Diligent-Hydrogent)

find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
add_library(USD-Libraries INTERFACE)

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-Libraries 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-*")
file(GLOB BOOST_INCLUDE_RELEASE "${DILIGENT_USD_PATH}/Release/include/boost-*")
file(GLOB BOOST_INCLUDE_RELWITHDEBINFO "${DILIGENT_USD_PATH}/RelWithDebInfo/include/boost-*")

target_include_directories(USD_LIBS
target_include_directories(USD-Libraries
INTERFACE
${DILIGENT_USD_PATH}/$<CONFIG>/include
$<$<CONFIG:DEBUG>:${BOOST_INCLUDE_DEBUG}>
$<$<CONFIG:RELEASE>:${BOOST_INCLUDE_RELEASE}>
$<$<CONFIG:RELWITHDEBINFO>:${BOOST_INCLUDE_RELWITHDEBINFO}>
)

target_link_directories(USD_LIBS
target_link_directories(USD-Libraries
INTERFACE
${DILIGENT_USD_PATH}/$<CONFIG>/lib
)
else()
file(GLOB BOOST_INCLUDE_DEBUG "${DILIGENT_USD_PATH}/Debug/boost-*")
target_include_directories(USD_LIBS
target_include_directories(USD-Libraries
INTERFACE
${DILIGENT_USD_PATH}/include
${BOOST_INCLUDE_DEBUG}
)

target_link_directories(USD_LIBS
target_link_directories(USD-Libraries
INTERFACE
${DILIGENT_USD_PATH}/lib
)
endif()

target_include_directories(USD_LIBS
INTERFACE
${Python3_INCLUDE_DIRS}
)

if(MSVC)
target_compile_definitions(USD_LIBS INTERFACE NOMINMAX)
target_compile_options(USD_LIBS INTERFACE /wd4244 /wd4305 /wd4127 /wd4267)
target_compile_definitions(USD-Libraries INTERFACE NOMINMAX)
target_compile_options(USD-Libraries INTERFACE /wd4244 /wd4305 /wd4127 /wd4267)
target_compile_options(Diligent-Hydrogent PRIVATE /permissive-)
else()
target_compile_options(USD-Libraries INTERFACE -Wno-deprecated-builtins -Wno-deprecated-declarations)
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
usd_trace
usd_cameraUtil
set(USD_LIBS
gf
ar
sdf
tf
usd
plug
hd
usdImaging
vt
hio
sdr
ndr
trace
cameraUtil
)

if (NOT pxr_FOUND)
# Add usd_ prefix to all USD libraries
set(_USD_LIBS "")
foreach(lib ${USD_LIBS})
list(APPEND _USD_LIBS "usd_${lib}")
endforeach()
set(USD_LIBS ${_USD_LIBS})

# Add python library
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)

target_include_directories(USD-Libraries INTERFACE ${Python3_INCLUDE_DIRS})
target_link_directories(USD-Libraries INTERFACE ${Python3_LIBRARY_DIRS})
endif()

target_link_libraries(USD-Libraries INTERFACE ${USD_LIBS})

target_include_directories(Diligent-Hydrogent
PUBLIC
interface
PRIVATE
include
)

target_link_directories(Diligent-Hydrogent
PUBLIC
${Python3_LIBRARY_DIRS}
)

# We need to enable RTTI for USD
add_library(EnableRTTI INTERFACE)
target_compile_options(EnableRTTI INTERFACE /GR)

target_link_libraries(Diligent-Hydrogent
PRIVATE
USD_LIBS
USD-Libraries
NO_WERROR
EnableRTTI # USD requires RTTI
Diligent-GraphicsEngine
Diligent-BasicPlatform
Diligent-GraphicsTools
Expand All @@ -160,8 +164,16 @@ PRIVATE
DiligentFX
)

if(MSVC)
# USD requires RTTI
add_library(EnableRTTI INTERFACE)
target_compile_options(EnableRTTI INTERFACE /GR)
target_link_libraries(Diligent-Hydrogent PRIVATE EnableRTTI)
endif()


set_target_properties(Diligent-Hydrogent PROPERTIES
FOLDER DiligentFX
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HYDROGENT_SOURCE})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HYDROGENT_SOURCE})

0 comments on commit bfa3e6c

Please sign in to comment.