Skip to content

Commit

Permalink
Fix pugixml symbols missing in monolithic static build. (AcademySoftw…
Browse files Browse the repository at this point in the history
…areFoundation#1989)

* Fix bug reported by Kai Rohmer on Slack, regarding pugixml symbols being missing when linking MaterialX monolithic static library to other downstream applications.  pugixml library was missing from the build.  Renaming LIBRARIES to MTLX_MODULES in mx_add_library() to make it clearer its only to declare dependencies between MaterialX modules.  Any other library dependencies should be set on the ${TARGET_NAME} target after mx_add_library() has been called, as this will be the correct target regardless of if the build is monolithic or not.
  • Loading branch information
ld-kerley authored Aug 23, 2024
1 parent 38bdda7 commit e33b282
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
python: 3.11
build_javascript: ON

- name: Linux_GCC_12_Python311_Static_Monolithic
os: ubuntu-22.04
compiler: gcc
compiler_version: "12"
python: 3.11
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON -DMATERIALX_BUILD_MONOLITHIC=ON

- name: Linux_GCC_14_Python312
os: ubuntu-24.04
compiler: gcc
Expand Down
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ function(mx_add_library MATERIALX_MODULE_NAME)
SOURCE_FILES
HEADER_FILES
INLINED_FILES
LIBRARIES
PRIVATE_LIBRARIES)
MTLX_MODULES)
cmake_parse_arguments(args
"${options}"
"${oneValueArgs}"
Expand Down Expand Up @@ -331,13 +330,9 @@ function(mx_add_library MATERIALX_MODULE_NAME)

target_link_libraries(${TARGET_NAME}
PUBLIC
${args_LIBRARIES}
${args_MTLX_MODULES}
${CMAKE_DL_LIBS})

target_link_libraries(${TARGET_NAME}
PRIVATE
${args_PRIVATE_LIBRARIES})

target_include_directories(${TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
Expand Down
7 changes: 3 additions & 4 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ if (MATERIALX_BUILD_MONOLITHIC)
target_sources(${MATERIALX_MODULE_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

set_target_properties(
${MATERIALX_MODULE_NAME} PROPERTIES
set_target_properties(${MATERIALX_MODULE_NAME} PROPERTIES
OUTPUT_NAME ${MATERIALX_MODULE_NAME}${MATERIALX_LIBNAME_SUFFIX}
COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}"
LINK_FLAGS "${EXTERNAL_LINK_FLAGS}"
INSTALL_RPATH "${MATERIALX_SAME_DIR_RPATH}"
VERSION "${MATERIALX_LIBRARY_VERSION}"
SOVERSION "${MATERIALX_MAJOR_VERSION}")

target_link_libraries(
${MATERIALX_MODULE_NAME}
target_link_libraries(${MATERIALX_MODULE_NAME}
PUBLIC
${CMAKE_DL_LIBS})

target_include_directories(${MATERIALX_MODULE_NAME}
Expand Down
8 changes: 5 additions & 3 deletions source/MaterialXFormat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ mx_add_library(MaterialXFormat
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXCore
PRIVATE_LIBRARIES
"$<BUILD_INTERFACE:pugixml::pugixml>"
EXPORT_DEFINE
MATERIALX_FORMAT_EXPORTS)

# we need to use BUILD_INTERFACE here to hide the use of pugixml from the cmake export when we're building
# MaterialX as a static library - feels like maybe a cmake bug?

target_link_libraries(${TARGET_NAME}
PRIVATE
"$<BUILD_INTERFACE:pugixml::pugixml>")
2 changes: 1 addition & 1 deletion source/MaterialXGenGlsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXGenGlsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXGenShader
MaterialXCore
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXGenMdl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXGenShader
MaterialXCore
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXGenMsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXGenShader
MaterialXCore
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenOsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXGenOsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXGenShader
MaterialXCore
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenShader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXGenShader
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXFormat
MaterialXCore
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mx_add_library(MaterialXRender
${materialx_inlined}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXGenShader
EXPORT_DEFINE
MATERIALX_RENDER_EXPORTS)
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderGlsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mx_add_library(MaterialXRenderGlsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXRenderHw
MaterialXGenGlsl
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderHw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mx_add_library(MaterialXRenderHw
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXRender
EXPORT_DEFINE
MATERIALX_RENDERHW_EXPORTS
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderMsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mx_add_library(MaterialXRenderMsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXRenderHw
MaterialXGenMsl
EXPORT_DEFINE
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderOsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mx_add_library(MaterialXRenderOsl
${materialx_source}
HEADER_FILES
${materialx_headers}
LIBRARIES
MTLX_MODULES
MaterialXRender
EXPORT_DEFINE
MATERIALX_RENDEROSL_EXPORTS)

0 comments on commit e33b282

Please sign in to comment.