Skip to content

Commit 3e5a82f

Browse files
authored
Refactor LibToOSO tool (#2691)
* Localize the compileOSL() code, this removes the dependency on MaterialXRender * Add optional dependency on liboslcomp, which allows compiling of the osos without using std::system. This significantly speeds up compilation time, on my machine dropping from about a minute for the entire data library to about 15 seconds. * With liboslcomp, we can avoid writing the OSL source to disk - saving space. This is controlled by a command line argument * Add command line arguments to specify data library location * Add argument to avoid writing the MaterialX document for the implementation elements, this may be helpful for those not using MaterialX shader generation.
1 parent 04e5071 commit 3e5a82f

File tree

2 files changed

+252
-72
lines changed

2 files changed

+252
-72
lines changed

source/MaterialXGenOsl/CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,26 @@ mx_add_library(MaterialXGenOsl
1414
EXPORT_DEFINE
1515
MATERIALX_GENOSL_EXPORTS)
1616

17-
# FIXME: LibsToOso has a dependency on the OslRenderer.
18-
if (MATERIALX_BUILD_OSOS AND MATERIALX_BUILD_RENDER)
17+
if (MATERIALX_BUILD_OSOS)
1918
file(GLOB GenNodes_SRC "${CMAKE_CURRENT_SOURCE_DIR}/LibsToOso.cpp")
2019

21-
set(MATERIALX_LIBRARIES
22-
MaterialXCore
23-
MaterialXFormat
24-
MaterialXGenShader
25-
MaterialXGenOsl
26-
MaterialXRenderOsl)
27-
2820
add_executable(MaterialXGenOsl_LibsToOso ${GenNodes_SRC})
2921

30-
target_link_libraries(
31-
MaterialXGenOsl_LibsToOso
32-
${MATERIALX_LIBRARIES})
22+
target_link_libraries(MaterialXGenOsl_LibsToOso
23+
PRIVATE
24+
MaterialXCore
25+
MaterialXFormat
26+
MaterialXGenShader
27+
MaterialXGenOsl)
28+
29+
if (OSL_FOUND)
30+
target_link_libraries(MaterialXGenOsl_LibsToOso
31+
PRIVATE
32+
OSL::oslcomp)
33+
target_compile_definitions(MaterialXGenOsl_LibsToOso
34+
PRIVATE
35+
USE_OSLCOMP)
36+
endif()
3337

3438
set_target_properties(
3539
MaterialXGenOsl_LibsToOso PROPERTIES

0 commit comments

Comments
 (0)