Limit visibility of symbols for internal libraries

Also remove `SPIRV/doc.cpp` from the `SPVRemapper` target as this
is part of `SPIRV`, causing ODR violations. Instead have
`SPVRemapper` link against `SPIRV`.

Fixes ODR violations.
This commit is contained in:
Ben Clayton
2020-07-14 18:36:08 +01:00
parent 11fa4d0d56
commit 33585c871d
4 changed files with 19 additions and 11 deletions

View File

@@ -279,17 +279,23 @@ function(glslang_add_build_info_dependency target)
add_dependencies(${target} glslang-build-info)
endfunction()
# glslang_default_to_hidden_visibility() makes the symbol visibility hidden by
# default for <target>.
function(glslang_default_to_hidden_visibility target)
if(NOT WIN32)
target_compile_options(${target} PRIVATE "-fvisibility=hidden")
endif()
endfunction()
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
# default for <target> when building shared libraries, and sets the
# GLSLANG_IS_SHARED_LIBRARY define, and GLSLANG_EXPORTING to 1 when specifically
# building <target>.
# default for <target>, and sets the GLSLANG_IS_SHARED_LIBRARY define, and
# GLSLANG_EXPORTING to 1 when specifically building <target>.
function(glslang_only_export_explicit_symbols target)
glslang_default_to_hidden_visibility(${target})
if(BUILD_SHARED_LIBS)
target_compile_definitions(${target} PUBLIC "GLSLANG_IS_SHARED_LIBRARY=1")
if(WIN32)
target_compile_definitions(${target} PRIVATE "GLSLANG_EXPORTING=1")
else()
target_compile_options(${target} PRIVATE "-fvisibility=hidden")
endif()
endif()
endfunction()