diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-21 01:00:43 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-21 09:01:39 +0000 |
commit | 6c728d5abbe5b79ec9f099e9b5c80f700a66f80c (patch) | |
tree | b05a627b9a3da7b2b029a6ba8d051cf27d51f923 /CMakeLists.txt | |
parent | 2ee0ea0f1d1f41285a7e51d4484d3ae2f4127528 (diff) |
Support Sun^WOracle C's -xldscope=hidden for hiding externals.
Change-Id: Id9c852f384a4450b82c8d596f4628d1ccbcf95bc
Reviewed-on: https://code.wireshark.org/review/6707
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ac836e7de..417b6d58e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -404,13 +404,39 @@ foreach(THIS_FLAG ${CPP_FLAG_TESTS}) endforeach() set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") -check_c_compiler_flag(-fvisibility=hidden FVHIDDEN) -if(FVHIDDEN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") -else() # TODO add alternate compiler flags for hiding symbols - if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") - message(WARNING "Hiding shared library symbols is not supported by the compiler." - " All shared library symbols will be exported.") +# +# Try to have the compiler default to hiding symbols, so that only +# symbols explicitly exported with WS_DLL_PUBLIC will be visible +# outside (shared) libraries; that way, more UN*X builds will catch +# failures to export symbols, rather than having that fail only on +# Windows. +# +# We don't need that with MSVC, as that's the default. +# +if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") + # + # Try the GCC-and-copatible -fvisibility-hidden first. + # + check_c_compiler_flag(-fvisibility=hidden FVHIDDEN) + if(FVHIDDEN) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + else() + # + # OK, try the Sun^WOracle C -xldscope=hidden + # + check_c_compiler_flag(-xldscope=hidden XLDSCOPEHIDDEN) + if(XLDSCOPEHIDDEN) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xldscope=hidden") + else() + # + # Anything else? + # If there is anything else, we might want to + # make a list of options to try, and try them + # in a loop. + # + message(WARNING "Hiding shared library symbols is not supported by the compiler." + " All shared library symbols will be exported.") + endif() endif() endif() |