From 049f8b3b6c2dd09d1ba34c9aeb1e530c1690bfe4 Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Thu, 12 Dec 2019 11:31:48 -0500 Subject: [PATCH 1/3] Allow using a debug Python interpreter --- source/MaterialXContrib/MaterialXMaya/CMakeLists.txt | 11 +++++++++-- source/MaterialXContrib/MaterialXMaya/Plugin.cpp | 1 + .../MaterialXMaya/ShadingNodeOverrides.cpp | 12 +++++++++--- source/PyMaterialX/CMakeLists.txt | 8 ++++++++ .../PyBind11/include/pybind11/detail/common.h | 2 +- source/PyMaterialX/PyMaterialXCore/CMakeLists.txt | 2 +- source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt | 2 +- .../PyMaterialX/PyMaterialXGenArnold/CMakeLists.txt | 2 +- source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt | 2 +- .../PyMaterialX/PyMaterialXGenOgsFx/CMakeLists.txt | 2 +- source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt | 2 +- .../PyMaterialX/PyMaterialXGenShader/CMakeLists.txt | 2 +- source/PyMaterialX/PyMaterialXRender/CMakeLists.txt | 2 +- .../PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt | 3 ++- .../PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt | 2 +- 15 files changed, 39 insertions(+), 16 deletions(-) diff --git a/source/MaterialXContrib/MaterialXMaya/CMakeLists.txt b/source/MaterialXContrib/MaterialXMaya/CMakeLists.txt index 32f874ede5..a2b569c450 100644 --- a/source/MaterialXContrib/MaterialXMaya/CMakeLists.txt +++ b/source/MaterialXContrib/MaterialXMaya/CMakeLists.txt @@ -84,6 +84,14 @@ if (EXISTS "${MAYA_DEBUG_DIR}" OR EXISTS "${MAYA_RELEASE_DIR}") ${_headers} ) + if (${APPLE}) + set(MAYA_PLUGIN_EXT ".bundle") + elseif(MSVC) + set(MAYA_PLUGIN_EXT ".mll") + else() + set(MAYA_PLUGIN_EXT ".so") + endif() + set_target_properties( ${PROJECT_NAME} PROPERTIES @@ -93,7 +101,7 @@ if (EXISTS "${MAYA_DEBUG_DIR}" OR EXISTS "${MAYA_RELEASE_DIR}") VERSION ${MATERIALX_NODE_VERSION} SOVERSION ${MATERIALX_NODE_VERSION} PREFIX "" - SUFFIX ".mll" + SUFFIX ${MAYA_PLUGIN_EXT} DEBUG_POSTFIX "" ) @@ -120,6 +128,5 @@ if (EXISTS "${MAYA_DEBUG_DIR}" OR EXISTS "${MAYA_RELEASE_DIR}") install(FILES ${_scripts} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/scripts) install(FILES ${_AEtemplate} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/AEtemplate) install(FILES ${_mods} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}) - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}") install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../../resources DESTINATION "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}") endif() diff --git a/source/MaterialXContrib/MaterialXMaya/Plugin.cpp b/source/MaterialXContrib/MaterialXMaya/Plugin.cpp index 34f6ee1ffb..d5a2d77f86 100644 --- a/source/MaterialXContrib/MaterialXMaya/Plugin.cpp +++ b/source/MaterialXContrib/MaterialXMaya/Plugin.cpp @@ -119,6 +119,7 @@ mx::FileSearchPath Plugin::getResourceSearchPath() const builder.append(_pluginLoadPath); builder.append(_pluginLoadPath / mx::FilePath("../../resources")); builder.append(_pluginLoadPath / mx::FilePath("../resources")); + builder.append(_pluginLoadPath / mx::FilePath("..")); builder.appendFromOptionVar("materialXResourceSearchPaths"); return searchPath; diff --git a/source/MaterialXContrib/MaterialXMaya/ShadingNodeOverrides.cpp b/source/MaterialXContrib/MaterialXMaya/ShadingNodeOverrides.cpp index 0be6a3bd50..bce2420f92 100644 --- a/source/MaterialXContrib/MaterialXMaya/ShadingNodeOverrides.cpp +++ b/source/MaterialXContrib/MaterialXMaya/ShadingNodeOverrides.cpp @@ -5,6 +5,7 @@ #include "MayaUtil.h" #include +#include #include #include #include @@ -121,13 +122,18 @@ MStatus bindFileTexture(MHWRender::MShaderInstance& shaderInstance, } else { - std::cerr << "*Unable to find image file: " << fileName << " in search paths: " - << searchPath.asString() << std::endl; + MString message("*Unable to find image file: "); + message += fileName.c_str(); + message += " in search paths: "; + message += searchPath.asString().c_str(); + MGlobal::displayError(message); } status = shaderInstance.setParameter(parameterName.c_str(), textureAssignment); if (!status) { - std::cerr << "*Unable to bind image file: " << fileName << std::endl; + MString message("*Unable to bind image file: "); + message += fileName.c_str(); + MGlobal::displayError(message); } } diff --git a/source/PyMaterialX/CMakeLists.txt b/source/PyMaterialX/CMakeLists.txt index 2e51724fa3..2d1bc94e8b 100644 --- a/source/PyMaterialX/CMakeLists.txt +++ b/source/PyMaterialX/CMakeLists.txt @@ -38,6 +38,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang) add_compile_options(-Wno-undefined-var-template) endif() endif() + +# Postfix rules for Python modules are strict and depend on the presence of a +# debug interpreter: +if(PYTHON_IS_DEBUG) + set(MATERIALX_PYTHON_DEBUG_POSTFIX "_d") +else() + set(MATERIALX_PYTHON_DEBUG_POSTFIX "") +endif() add_subdirectory(PyMaterialXCore) add_subdirectory(PyMaterialXFormat) diff --git a/source/PyMaterialX/PyBind11/include/pybind11/detail/common.h b/source/PyMaterialX/PyBind11/include/pybind11/detail/common.h index 892de0f8fd..4c58e7429c 100644 --- a/source/PyMaterialX/PyBind11/include/pybind11/detail/common.h +++ b/source/PyMaterialX/PyBind11/include/pybind11/detail/common.h @@ -103,7 +103,7 @@ # endif # pragma warning(push) # pragma warning(disable: 4510 4610 4512 4005) -# if defined(_DEBUG) +# if defined(_DEBUG) && !defined(Py_DEBUG) # define PYBIND11_DEBUG_MARKER # undef _DEBUG # endif diff --git a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt index 07cc8f02a8..7171849679 100644 --- a/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXCore/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXCore diff --git a/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt b/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt index e362e2f4dd..9b6f0110b8 100644 --- a/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXFormat diff --git a/source/PyMaterialX/PyMaterialXGenArnold/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenArnold/CMakeLists.txt index 9798b4aad5..12484bd2c6 100644 --- a/source/PyMaterialX/PyMaterialXGenArnold/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenArnold/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXGenArnold diff --git a/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt index 5504129bd9..8ddb5e9a17 100644 --- a/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXGenGlsl diff --git a/source/PyMaterialX/PyMaterialXGenOgsFx/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenOgsFx/CMakeLists.txt index 3403ff3914..f97e550e8c 100644 --- a/source/PyMaterialX/PyMaterialXGenOgsFx/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenOgsFx/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXGenOgsFx diff --git a/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt index cb880523bb..5ff4e0f6fd 100644 --- a/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenOsl/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXGenOsl diff --git a/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt b/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt index f5ceb43f5c..4c07353022 100644 --- a/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXGenShader/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXGenShader diff --git a/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt index ae9396e69f..1f68e4ac79 100644 --- a/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRender/CMakeLists.txt @@ -21,7 +21,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") if(NOT MATERIALX_BUILD_CONTRIB) target_link_libraries( diff --git a/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt index 234cd101c9..3507d132e4 100644 --- a/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRenderGlsl/CMakeLists.txt @@ -14,7 +14,8 @@ set_target_properties( COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" - SOVERSION "${MATERIALX_MAJOR_VERSION}") + SOVERSION "${MATERIALX_MAJOR_VERSION}" + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXRenderGlsl diff --git a/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt b/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt index 64156d876f..fa89e28335 100644 --- a/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt +++ b/source/PyMaterialX/PyMaterialXRenderOsl/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties( LINK_FLAGS "${EXTERNAL_LINK_FLAGS}" VERSION "${MATERIALX_LIBRARY_VERSION}" SOVERSION "${MATERIALX_MAJOR_VERSION}" - DEBUG_POSTFIX "${MATERIALX_DEBUG_POSTFIX}") + DEBUG_POSTFIX "${MATERIALX_PYTHON_DEBUG_POSTFIX}") target_link_libraries( PyMaterialXRenderOsl From cc6331fdd0c382b9433fc5db88b06c55e06f704f Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Fri, 13 Dec 2019 10:26:14 -0500 Subject: [PATCH 2/3] Fixed incorrect debug suffix on Linux/Mac --- source/PyMaterialX/CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/PyMaterialX/CMakeLists.txt b/source/PyMaterialX/CMakeLists.txt index 2d1bc94e8b..f7342373a0 100644 --- a/source/PyMaterialX/CMakeLists.txt +++ b/source/PyMaterialX/CMakeLists.txt @@ -39,14 +39,19 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang) endif() endif() -# Postfix rules for Python modules are strict and depend on the presence of a -# debug interpreter: -if(PYTHON_IS_DEBUG) - set(MATERIALX_PYTHON_DEBUG_POSTFIX "_d") -else() - set(MATERIALX_PYTHON_DEBUG_POSTFIX "") +# Postfix rules for Python modules are strict on the Windows platform: we must +# add a "_d" postfix when using a Debug interpreter. +# Future work for Python3: +# On Linux: implement the full postfix requirements from PEP 3149 +# On Windows: tag with the python version (_37.pyd and _37d.pyd for Python 3.7) +if(MSVC) + if(PYTHON_IS_DEBUG) + set(MATERIALX_PYTHON_DEBUG_POSTFIX "_d") + else() + set(MATERIALX_PYTHON_DEBUG_POSTFIX "") + endif() endif() - + add_subdirectory(PyMaterialXCore) add_subdirectory(PyMaterialXFormat) add_subdirectory(PyMaterialXGenShader) From 5c40dcdb198f38a16627a241e289d8fd9fbcb26b Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Fri, 13 Dec 2019 22:49:59 -0500 Subject: [PATCH 3/3] Reduce scope of fix to the only configuration that needs it --- source/PyMaterialX/CMakeLists.txt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/PyMaterialX/CMakeLists.txt b/source/PyMaterialX/CMakeLists.txt index f7342373a0..c80d17a391 100644 --- a/source/PyMaterialX/CMakeLists.txt +++ b/source/PyMaterialX/CMakeLists.txt @@ -39,17 +39,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang) endif() endif() -# Postfix rules for Python modules are strict on the Windows platform: we must -# add a "_d" postfix when using a Debug interpreter. -# Future work for Python3: -# On Linux: implement the full postfix requirements from PEP 3149 -# On Windows: tag with the python version (_37.pyd and _37d.pyd for Python 3.7) -if(MSVC) - if(PYTHON_IS_DEBUG) - set(MATERIALX_PYTHON_DEBUG_POSTFIX "_d") - else() - set(MATERIALX_PYTHON_DEBUG_POSTFIX "") - endif() +# Add proper postfix for Python 2.7 on Windows when using a Debug interpreter: +set(MATERIALX_PYTHON_DEBUG_POSTFIX "") +if(MSVC AND PYTHON_IS_DEBUG AND (PYBIND11_PYTHON_VERSION VERSION_LESS 3.0)) + set(MATERIALX_PYTHON_DEBUG_POSTFIX "_d") endif() add_subdirectory(PyMaterialXCore)