From 7a7afb1f6c5e352cd08571843ba934339d2cdfd3 Mon Sep 17 00:00:00 2001 From: David Lanier Date: Fri, 26 Jan 2024 10:19:23 +0100 Subject: [PATCH] Fixes from code review from Sean. --- CMakeLists.txt | 2 +- cmake/modules/FindMayaUsd.cmake | 31 ++----------------- cmake/test.cmake | 10 ++++++ lib/mayaHydra/hydraExtensions/CMakeLists.txt | 6 ++-- .../mayaUsd/render/mayaToHydra/CMakeLists.txt | 6 ++-- 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07cd2557c7..50e09f0e1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ else() message(STATUS "UFE not found.") endif() -find_package(MayaUsd OPTIONAL_COMPONENTS) +find_package(MayaUsd) if(MayaUsd_FOUND) message(STATUS "Building with MayaUsd.") else() diff --git a/cmake/modules/FindMayaUsd.cmake b/cmake/modules/FindMayaUsd.cmake index 613184b425..aac9cac4a9 100644 --- a/cmake/modules/FindMayaUsd.cmake +++ b/cmake/modules/FindMayaUsd.cmake @@ -5,8 +5,7 @@ # It searches for MayaUsd's libraries and include header files. # # Variables that will be defined: -# MAYAUSD_FOUND Defined if a MayaUsd installation has been detected -# MAYAUSD_LIBRARY_DIR Path to MayaUsd libraries directory +# MayaUsd_FOUND Defined if a MayaUsd installation has been detected # MAYAUSD_INCLUDE_DIR Path to the MayaUsd include directory # MAYAUSDAPI_LIBRARY Path to MayaUsdAPI library # MAYAUSD_MOD_PATH Path to mayaUSD.mod file @@ -22,23 +21,11 @@ find_path(MAYAUSD_INCLUDE_DIR "MayaUsd header path" ) -find_path(MAYAUSD_LIBRARY_DIR - mayaUsd.lib - HINTS - ${MAYAUSD_LOCATION} - PATH_SUFFIXES - lib/ - DOC - "MayaUsd libraries path" -) - find_library(MAYAUSDAPI_LIBRARY NAMES mayaUsdAPI HINTS ${MAYAUSD_LOCATION} - PATHS - ${MAYAUSD_LIBRARY_DIR} PATH_SUFFIXES lib/ DOC @@ -62,26 +49,14 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(MAYAUSD REQUIRED_VARS MAYAUSD_INCLUDE_DIR - MAYAUSD_LIBRARY_DIR + MAYAUSDAPI_LIBRARY ) if(MAYAUSD_FOUND) message(STATUS "MayaUsd found : ${MAYAUSD_LOCATION}") message(STATUS "MayaUsd include dir: ${MAYAUSD_INCLUDE_DIR}") - message(STATUS "MayaUsd libraries dir: ${MAYAUSD_LIBRARY_DIR}") - message(STATUS "MayaUsdAPI.lib fullpath : ${MAYAUSDAPI_LIBRARY}") + message(STATUS "MayaUsdAPI library fullpath : ${MAYAUSDAPI_LIBRARY}") message(STATUS "MAYAUSD_MOD_PATH : ${MAYAUSD_MOD_PATH}") - - #Add MAYAUSD_MOD_PATH (the path where maya USD .mod file is) to the MAYA_MODULE_PATH - - # Get the current value of the environment variable - set(CURRENT_MAYA_MODULE_PATH $ENV{MAYA_MODULE_PATH}) - - # Append the new path to the current value - set(MAYA_MODULE_PATH "${CURRENT_MAYA_MODULE_PATH}:${MAYAUSD_MOD_PATH}") - - # Export the new value to the environment - set(ENV{MAYA_MODULE_PATH} ${MAYA_MODULE_PATH}) else() if(DEFINED MAYAUSD_LOCATION) message(WARNING "Could not find MayaUsd library and include directories in the folder provided : ${MAYAUSD_LOCATION}") diff --git a/cmake/test.cmake b/cmake/test.cmake index d9eed2cb85..40fd3eba2c 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -1,5 +1,15 @@ set(MAYA_USD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +if(MAYAUSD_FOUND) + #Add MAYAUSD_MOD_PATH (the path where maya USD .mod file is) to the MAYA_MODULE_PATH + # Get the current value of the environment variable + set(CURRENT_MAYA_MODULE_PATH $ENV{MAYA_MODULE_PATH}) + # Append the new path to the current value + set(MAYA_MODULE_PATH "${CURRENT_MAYA_MODULE_PATH}:${MAYAUSD_MOD_PATH}") + # Export the new value to the environment + set(ENV{MAYA_MODULE_PATH} ${MAYA_MODULE_PATH}) +endif() + function(mayaUsd_get_unittest_target unittest_target unittest_basename) get_filename_component(unittest_name ${unittest_basename} NAME_WE) set(${unittest_target} "${unittest_name}" PARENT_SCOPE) diff --git a/lib/mayaHydra/hydraExtensions/CMakeLists.txt b/lib/mayaHydra/hydraExtensions/CMakeLists.txt index 8a9f744a83..ebc69633d3 100644 --- a/lib/mayaHydra/hydraExtensions/CMakeLists.txt +++ b/lib/mayaHydra/hydraExtensions/CMakeLists.txt @@ -33,7 +33,7 @@ set(HEADERS target_compile_definitions(${TARGET_NAME} PRIVATE MAYAHYDRALIB_EXPORT - $<$:MAYAHYDRALIB_MAYAUSDAPI_ENABLED> + $<$:MAYAHYDRALIB_MAYAUSDAPI_ENABLED> $<$:OSMac_> # Copy-pasted from lib/mayaUsd/CMakeLists.txt ) @@ -52,7 +52,7 @@ target_include_directories(${TARGET_NAME} ${CMAKE_BINARY_DIR}/include PRIVATE $<$:${UFE_INCLUDE_DIR}> - $<$:${MAYAUSD_INCLUDE_DIR}> + $<$:${MAYAUSD_INCLUDE_DIR}> ) target_compile_definitions(${TARGET_NAME} @@ -123,7 +123,7 @@ target_link_libraries(${TARGET_NAME} $<$:hio> ${PYTHON_LIBRARIES} $<$:${UFE_LIBRARY}> - $<$:${MAYAUSDAPI_LIBRARY}> + $<$:${MAYAUSDAPI_LIBRARY}> ) # ----------------------------------------------------------------------------- diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index 0760200786..ae3d2a22ac 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -27,10 +27,10 @@ set(TEST_SCRIPT_FILES cpp/testFlowViewportAPIFilterPrims.py ) -#Add this test only if the MAYAUSDAPI_LIBRARY has been found during compile time. -if(MAYAUSDAPI_LIBRARY) +#Add this test only if the MayaUsd_FOUND (so also MAYAUSDAPI_LIBRARY) has been found during compile time. +if(MayaUsd_FOUND) list(APPEND TEST_SCRIPT_FILES testMayaUsdAPIUsage.py) -endif(MAYAUSDAPI_LIBRARY) +endif(MayaUsd_FOUND) # Test use of mesh adapter code for mesh support, using environment variable. # As of 13-Jun-2023, if a test in this list is identical to a test in