Caveat: I am not a MaterialX user, I'm coming at this from the perspective of packaging MaterialX for the aswf-docker project.
The installation location of resources is defined in two places. In resources/CMakeLists.txt used at build time:
if(NOT SKBUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "resources" MESSAGE_NEVER)
endif()
and in cmake/modules/MaterialXConfig.cmake.in used by clients of MaterialX:
if(NOT SKBUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION "resources" MESSAGE_NEVER)
endif()
So if you want to relocate the resources directory somewhere else like share/MaterialX/resources you need to change both locations.
Similarly for libraries, in the top level CMakeLists.txt:
set(MATERIALX_INSTALL_STDLIB_PATH "libraries" CACHE STRING "Install path for mtlx std libs (e.g. 'libraries').")
libraries/CMakeLists.txt used at build time correctly uses the variable from the top level CMakeLists.txt:
install(DIRECTORY ${DATA_LIBRARY_DIR}/
DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}"
PATTERN "CMakeLists.txt" EXCLUDE)
but in cmake/modules/MaterialXConfig.cmake.in:
set_and_check(MATERIALX_STDLIB_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/libraries")
The following patch addresses these issues and should allow overriding both those locations at CMake configuration time. If this seems like a reasonable approach I can submit this as a PR.
Note that this does not address issues related to Python module installation, which I will report separately.
cmake \
-DMATERIALX_INSTALL_STDLIB_PATH="share/MaterialX/libraries" \
-DMATERIALX_INSTALL_RESOURCES_PATH="share/MaterialX/resources" \
..
--- cmake/modules/MaterialXConfig.cmake.in
+++ cmake/modules/MaterialXConfig.cmake.in
@@ -20,7 +20,7 @@
# MATERIALX_RESOURCES_DIR Path to MaterialX Resources (sample data, mtlx etc)
set_and_check(MATERIALX_BASE_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@")
-set_and_check(MATERIALX_STDLIB_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/libraries")
+set_and_check(MATERIALX_STDLIB_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/@MATERIALX_INSTALL_STDLIB_PATH@")
if(@MATERIALX_BUILD_PYTHON@ AND @MATERIALX_INSTALL_PYTHON@)
set_and_check(MATERIALX_PYTHON_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/python")
endif()
@@ -36,7 +36,7 @@
endif()
if(@MATERIALX_BUILD_RENDER@ AND @MATERIALX_INSTALL_RESOURCES@)
- set_and_check(MATERIALX_RESOURCES_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/resources")
+ set_and_check(MATERIALX_RESOURCES_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/@MATERIALX_INSTALL_RESOURCES_PATH@")
endif()
check_required_components(@CMAKE_PROJECT_NAME@)
--- resources/CMakeLists.txt
+++ resources/CMakeLists.txt
@@ -1,4 +1,4 @@
if(NOT SKBUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
- DESTINATION "resources" MESSAGE_NEVER)
+ DESTINATION "${MATERIALX_INSTALL_RESOURCES_PATH}" MESSAGE_NEVER)
endif()
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -124,6 +124,7 @@
set(MATERIALX_INSTALL_BIN_PATH "bin" CACHE STRING "Install bin path (e.g. 'bin').")
set(MATERIALX_INSTALL_LIB_PATH "lib" CACHE STRING "Install lib path (e.g. 'libs', 'lib').")
set(MATERIALX_INSTALL_STDLIB_PATH "libraries" CACHE STRING "Install path for mtlx std libs (e.g. 'libraries').")
+set(MATERIALX_INSTALL_RESOURCES_PATH "resources" CACHE STRING "Install path for mtlx resources / test files (e.g. 'resources').")
# Helpers for OSL validation
set(MATERIALX_OSL_BINARY_OSLC "" CACHE FILEPATH "Full path to the OSL compiler binary.")
Caveat: I am not a MaterialX user, I'm coming at this from the perspective of packaging MaterialX for the aswf-docker project.
The installation location of
resourcesis defined in two places. Inresources/CMakeLists.txtused at build time:and in
cmake/modules/MaterialXConfig.cmake.inused by clients of MaterialX:So if you want to relocate the resources directory somewhere else like
share/MaterialX/resourcesyou need to change both locations.Similarly for
libraries, in the top levelCMakeLists.txt:libraries/CMakeLists.txtused at build time correctly uses the variable from the top levelCMakeLists.txt:but in
cmake/modules/MaterialXConfig.cmake.in:The following patch addresses these issues and should allow overriding both those locations at CMake configuration time. If this seems like a reasonable approach I can submit this as a PR.
Note that this does not address issues related to Python module installation, which I will report separately.