Skip to content

Commit

Permalink
Hide dependency symbol visibility (#1409) (#1416)
Browse files Browse the repository at this point in the history
When creating libOpenColorIO.so, we lacked the linker commands that
hide symbol visibility from the dependent libraries, which is
necessary to prevent OCIO from exporting the symbols from Expat and
the other dependencies that OCIO needs to use internally but is not
trying intentionally to expose via its API.

Failing to do this can result in symbol clashes and all sorts of
subtle errors if OCIO is used in an app that also uses and is linked
against a potentially different version of Expat (or any of the other
deps).

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Co-authored-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Patrick Hodoul <Patrick.Hodoul@autodesk.com>
  • Loading branch information
hodoulp and lgritz committed Jun 28, 2021
1 parent cab69af commit bcdff43
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/OpenColorIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ set_target_properties(OpenColorIO PROPERTIES
SOVERSION ${SOVERSION}
)

if (UNIX AND NOT APPLE)
# Also hide all the symbols of dependent libraries to prevent clashes if
# an app using this project is linked against other versions of our
# dependencies.
set_property (TARGET OpenColorIO
APPEND PROPERTY LINK_FLAGS "-Wl,--exclude-libs,ALL")
endif ()

if(MSVC AND BUILD_SHARED_LIBS)
# Install the pdb file if any.
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION bin OPTIONAL)
Expand Down

0 comments on commit bcdff43

Please sign in to comment.