Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-1692 - Adds LookdevXUsd Extension #4040

Merged
merged 8 commits into from
Dec 17, 2024
36 changes: 29 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ project(maya-usd)
#------------------------------------------------------------------------------
option(BUILD_MAYAUSD_LIBRARY "Build Core USD libraries." ON)
option(BUILD_MAYAUSDAPI_LIBRARY "Build the mayaUsdAPI subset library that provides a stable versioned interface to mayaUsd for external plugins." ON)
option(BUILD_LOOKDEVXUSD_LIBRARY "Build LookdevXUsd library using LookdevXUfe." ON)
option(BUILD_ADSK_PLUGIN "Build Autodesk USD plugin." ON)
option(BUILD_PXR_PLUGIN "Build the Pixar USD plugin and libraries." ON)
option(BUILD_AL_PLUGIN "Build the Animal Logic USD plugin and libraries." ON)
Expand Down Expand Up @@ -128,6 +129,11 @@ if (BUILD_MAYAUSDAPI_LIBRARY)
set(MAYAUSDAPI_VERSION "${MAYAUSDAPI_MAJOR_VERSION}.${MAYAUSDAPI_MINOR_VERSION}.${MAYAUSDAPI_PATCH_LEVEL}")
endif()

if (BUILD_MAYAUSDAPI_LIBRARY)
if (NOT BUILD_MAYAUSD_LIBRARY)
message(FATAL_ERROR "Building mayaUsdAPI library requires MayaUsd core libraries to be built, please enable BUILD_MAYAUSD_LIBRARY.")
endif()
endif()

if (DEFINED PYTHON_INCLUDE_DIR AND DEFINED PYTHON_LIBRARIES AND DEFINED Python_EXECUTABLE)
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
Expand Down Expand Up @@ -226,6 +232,28 @@ if(BUILD_MAYAUSD_LIBRARY)
endif()
endif()

# Need LookdevXUfe/MayaUsdAPI when building LookdevXUsd.
if(BUILD_LOOKDEVXUSD_LIBRARY)
if(NOT BUILD_MAYAUSDAPI_LIBRARY)
message(FATAL_ERROR "Building LookdevXUsd requires MayaUsdAPI.")
endif()

if(MAYA_APP_VERSION VERSION_GREATER 2025)
find_package(LookdevXUfe) # Optional component - if not found, disable LookdevXUsd.
else()
set(BUILD_LOOKDEVXUSD_LIBRARY OFF)
message(WARNING "Disabling LookdevXUsd: it is not supported by Maya ${MAYA_APP_VERSION}.")
endif()
if (LookdevXUfe_FOUND)
message(STATUS "Build LookdevXUsd with LookdevXUfe version: ${LookdevXUfe_VERSION}")
message(STATUS " LookdevXUfe include dir: ${LookdevXUfe_INCLUDE_DIR}")
message(STATUS " LookdevXUfe library : ${LookdevXUfe_LIBRARY}")
else()
set(BUILD_LOOKDEVXUSD_LIBRARY OFF)
message(WARNING "Disabling LookdevXUsd as LookdevXUfe was not found (in Maya devkit).")
endif()
endif()

if(BUILD_MAYAUSD_LIBRARY AND (USD_VERSION VERSION_GREATER_EQUAL "0.24.11"))
# In USD v24.11 Pixar USD has completely removed Boost.
# However MayaUsd is still using a few of the Boost components, so
Expand Down Expand Up @@ -299,12 +327,6 @@ if (BUILD_PXR_PLUGIN OR BUILD_AL_PLUGIN OR BUILD_ADSK_PLUGIN)
endif()
endif()

if (BUILD_MAYAUSDAPI_LIBRARY)
if (NOT BUILD_MAYAUSD_LIBRARY)
message(FATAL_ERROR "Building mayaUsdAPI library requires MayaUsd core libraries to be built, please enable BUILD_MAYAUSD_LIBRARY.")
endif()
endif()

if (BUILD_PXR_PLUGIN)
add_subdirectory(plugin/pxr)
endif()
Expand Down Expand Up @@ -371,6 +393,6 @@ endif()
# Special file for handling boost vs pxr::boost
#------------------------------------------------------------------------------
mayaUsd_promoteHeaderList(HEADERS pxr_python.h BASEDIR "NONE")
install(FILES ${CMAKE_BINARY_DIR}/include//pxr_python.h
install(FILES ${CMAKE_BINARY_DIR}/include/pxr_python.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
79 changes: 79 additions & 0 deletions cmake/modules/FindLookdevXUfe.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Simple module to find LookdevXUfe.
#
# This module searches for a valid LookdevXUfe installation in the Maya devkit.
# It searches for LookdevXUfe's libraries and include files.
#
# Variables that will be defined:
# LookdevXUfe_FOUND Defined if a LookdevXUfe installation has been detected
# LookdevXUfe_LIBRARY Path to LookdevXUfe library
# LookdevXUfe_INCLUDE_DIR Path to the LookdevXUfe include directory
# LookdevXUfe_VERSION LookdevXUfe version (major.minor.patch) from LookdevXUfe.h
#

find_path(LookdevXUfe_INCLUDE_DIR
LookdevXUfe/LookdevXUfe.h
HINTS
$ENV{LOOKDEVXUFE_INCLUDE_ROOT}
${LOOKDEVXUFE_INCLUDE_ROOT}
${MAYA_DEVKIT_LOCATION}
$ENV{MAYA_DEVKIT_LOCATION}
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
PATH_SUFFIXES
devkit/ufe/extensions/lookdevXUfe/include
include/
DOC
"LookdevXUfe header path"
)

# Get the LookdevXUfe_VERSION from LookdevXUfe.h
if(LookdevXUfe_INCLUDE_DIR AND EXISTS "${LookdevXUfe_INCLUDE_DIR}/LookdevXUfe/LookdevXUfe.h")
# Parse the file and get the three lines that have the version info.
file(STRINGS
"${LookdevXUfe_INCLUDE_DIR}/LookdevXUfe/LookdevXUfe.h"
_ldx_vers
REGEX "#define[ ]+(LOOKDEVXUFE_MAJOR_VERSION|LOOKDEVXUFE_MINOR_VERSION|LOOKDEVXUFE_PATCH_LEVEL)[ ]+[0-9]+$")

# Then extract the number from each one.
foreach(_ldxufe_tmp ${_ldx_vers})
if(_ldxufe_tmp MATCHES "#define[ ]+(LOOKDEVXUFE_MAJOR_VERSION|LOOKDEVXUFE_MINOR_VERSION|LOOKDEVXUFE_PATCH_LEVEL)[ ]+([0-9]+)$")
set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endif()
endforeach()
set(LookdevXUfe_VERSION ${LOOKDEVXUFE_MAJOR_VERSION}.${LOOKDEVXUFE_MINOR_VERSION}.${LOOKDEVXUFE_PATCH_LEVEL})
endif()

find_library(LookdevXUfe_LIBRARY
NAMES
lookdevXUfe_${LOOKDEVXUFE_MAJOR_VERSION}_${LOOKDEVXUFE_MINOR_VERSION}
HINTS
$ENV{LOOKDEVXUFE_LIB_ROOT}
${LOOKDEVXUFE_LIB_ROOT}
${MAYA_DEVKIT_LOCATION}
$ENV{MAYA_DEVKIT_LOCATION}
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
${MAYA_BASE_DIR}
PATHS
${UFE_LIBRARY_DIR}
PATH_SUFFIXES
devkit/ufe/extensions/lookdevXUfe/lib
lib/
DOC
"LookdevXUfe library"
NO_DEFAULT_PATH
)

# Handle the QUIETLY and REQUIRED arguments and set LookdevXUfe_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(LookdevXUfe
REQUIRED_VARS
LookdevXUfe_INCLUDE_DIR
LookdevXUfe_LIBRARY
VERSION_VAR
LookdevXUfe_VERSION
)
2 changes: 2 additions & 0 deletions doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ c:\maya-usd> python build.py --maya-location "C:\Program Files\Autodesk\Maya2025
Name | Description | Default
--- | --- | ---
BUILD_MAYAUSD_LIBRARY | builds Core USD libraries. | ON
BUILD_MAYAUSDAPI_LIBRARY | Build the mayaUsdAPI subset library that provides a stable versioned interface to mayaUsd for external plugins. | ON
BUILD_LOOKDEVXUSD_LIBRARY | Build LookdevXUsd library using LookdevXUfe. | ON
BUILD_ADSK_PLUGIN | builds Autodesk USD plugin. | ON
BUILD_PXR_PLUGIN | builds the Pixar USD plugin and libraries. | ON
BUILD_AL_PLUGIN | builds the Animal Logic USD plugin and libraries. | ON
Expand Down
3 changes: 3 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ endif()
if (BUILD_MAYAUSDAPI_LIBRARY)
add_subdirectory(mayaUsdAPI)
endif()
if (BUILD_LOOKDEVXUSD_LIBRARY)
add_subdirectory(lookdevXUsd)
endif()
177 changes: 177 additions & 0 deletions lib/lookdevXUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#
# Copyright 2024 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

project(lookdevXUsd)

add_library(${PROJECT_NAME} SHARED)

# -----------------------------------------------------------------------------
# sources
# -----------------------------------------------------------------------------
target_sources(${PROJECT_NAME}
PRIVATE
LookdevXUsd.cpp
UsdCapabilityHandler.cpp
UsdClipboardHandler.cpp
UsdComponentConnections.cpp
UsdConnectionCommands.cpp
UsdDebugHandler.cpp
UsdDeleteCommand.cpp
UsdExtendedAttributeHandler.cpp
UsdExtendedConnectionHandler.cpp
UsdFileHandler.cpp
UsdHierarchy.cpp
UsdHierarchyHandler.cpp
UsdLookdevHandler.cpp
UsdMaterial.cpp
UsdMaterialCommands.cpp
UsdMaterialHandler.cpp
UsdMaterialValidator.cpp
UsdSceneItemOps.cpp
UsdSceneItemOpsHandler.cpp
UsdSceneItemUI.cpp
UsdSceneItemUIHandler.cpp
UsdSoloingHandler.cpp
UsdUINodeGraphNode.cpp
UsdUINodeGraphNodeHandler.cpp
Utils.cpp
)

set(HEADERS
Export.h
LookdevXUsd.h
UsdCapabilityHandler.h
UsdClipboardHandler.h
UsdComponentConnections.h
UsdConnectionCommands.h
UsdDebugHandler.h
UsdDeleteCommand.h
UsdExtendedAttributeHandler.h
UsdExtendedConnectionHandler.h
UsdFileHandler.h
UsdHierarchy.h
UsdHierarchyHandler.h
UsdLookdevHandler.h
UsdMaterial.h
UsdMaterialCommands.h
UsdMaterialHandler.h
UsdMaterialValidator.h
UsdSceneItemOps.h
UsdSceneItemOpsHandler.h
UsdSceneItemUI.h
UsdSceneItemUIHandler.h
UsdSoloingHandler.h
UsdUINodeGraphNode.h
UsdUINodeGraphNodeHandler.h
Utils.h
)

# -----------------------------------------------------------------------------
# Compiler configuration
# -----------------------------------------------------------------------------
target_compile_definitions(${PROJECT_NAME}
PRIVATE
LOOKDEVX_USD_SHARED
PXR_VERSION=${PXR_VERSION}
MFB_PACKAGE_NAME="${PROJECT_NAME}"
MFB_ALT_PACKAGE_NAME="${PROJECT_NAME}"
MFB_PACKAGE_MODULE="${PROJECT_NAME}"
$<$<BOOL:${IS_MACOSX}>:OSMac_>
$<$<BOOL:${IS_LINUX}>:LINUX>
# this flag is needed when building for Maya
$<$<BOOL:${IS_WINDOWS}>:WIN32>
)

mayaUsd_compile_config(${PROJECT_NAME})

mayaUsd_promoteHeaderList(
HEADERS
${HEADERS}
BASEDIR
${PROJECT_NAME}
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME}
PUBLIC
${PXR_INCLUDE_DIRS}
${UFE_INCLUDE_DIR}
${LookdevXUfe_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/include
)

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME}
PUBLIC
sdf
sdr
mayaUsdAPI
PRIVATE
usd
usdShade
usdUtils
usdUI
${UFE_LIBRARY}
${LookdevXUfe_LIBRARY}
)

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib")
if(DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib")
elseif(DEFINED PXR_USD_LOCATION)
mayaUsd_add_rpath(rpath "${PXR_USD_LOCATION}/lib")
endif()
if (IS_LINUX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib64")
endif()
if(IS_MACOSX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../../../Maya.app/Contents/MacOS")
endif()
mayaUsd_install_rpath(rpath ${PROJECT_NAME})
endif()

# -----------------------------------------------------------------------------
# install
# -----------------------------------------------------------------------------

# TODO - do we need to install the headers?
#install(FILES ${HEADERS}
# DESTINATION
# ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}
#)

install(TARGETS ${PROJECT_NAME}
LIBRARY
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
RUNTIME
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL
)
endif()
27 changes: 27 additions & 0 deletions lib/lookdevXUsd/Export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//*****************************************************************************
// Copyright (c) 2024 Autodesk, Inc.
// All rights reserved.
//
// These coded instructions, statements, and computer programs contain
// unpublished proprietary information written by Autodesk, Inc. and are
// protected by Federal copyright law. They may not be disclosed to third
// parties or copied or duplicated in any form, in whole or in part, without
// the prior written consent of Autodesk, Inc.
//*****************************************************************************

#ifndef LOOKDEVX_USD_EXPORT_H_
#define LOOKDEVX_USD_EXPORT_H_

#if defined(_WIN32)
#if defined(LOOKDEVX_USD_SHARED)
#define LOOKDEVX_USD_EXPORT __declspec(dllexport)
#else
#define LOOKDEVX_USD_EXPORT __declspec(dllimport)
#endif
#elif defined(__GNUC__)
#define LOOKDEVX_USD_EXPORT __attribute__((visibility("default")))
#else
#error "Unsupported platform."
#endif

#endif
Loading