diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2016-07-11 18:52:05 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2017-03-16 19:11:03 (GMT) |
commit | 9eb05b48cd8e19988e5a579996598802e2bacdea (patch) | |
tree | d75c3af1ccb61939ea1cb16c591c17cbe750ad08 /Modules/GenerateExportHeader.cmake | |
parent | e781223c8887fa2602b40744c67cdc77f972a93b (diff) | |
download | CMake-9eb05b48cd8e19988e5a579996598802e2bacdea.zip CMake-9eb05b48cd8e19988e5a579996598802e2bacdea.tar.gz CMake-9eb05b48cd8e19988e5a579996598802e2bacdea.tar.bz2 |
GenerateExportHeader: always fill in _EXPORT macros
The `_EXPORT` and `_NO_EXPORT` macros should always be made properly
because the `<LANG>_VISIBILITY_PRESET` properties are controlled
independently of this module.
One case where this breaks compatibility is where a project was setting
`USE_COMPILER_HIDDEN_VISIBILITY=OFF` and then marking a symbol used
outside of the library with `_NO_EXPORT` which is a contridiction.
Diffstat (limited to 'Modules/GenerateExportHeader.cmake')
-rw-r--r-- | Modules/GenerateExportHeader.cmake | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 6d1b4ed..4573c2e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -215,9 +215,6 @@ macro(_test_compiler_hidden_visibility) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) - option(USE_COMPILER_HIDDEN_VISIBILITY - "Use HIDDEN visibility support if available." ON) - mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) endif() endmacro() @@ -267,7 +264,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) if(WIN32 OR CYGWIN) set(DEFINE_EXPORT "__declspec(dllexport)") set(DEFINE_IMPORT "__declspec(dllimport)") - elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + elseif(COMPILER_HAS_HIDDEN_VISIBILITY) set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") @@ -388,6 +385,9 @@ function(add_compiler_export_flags) _test_compiler_hidden_visibility() _test_compiler_has_deprecated() + option(USE_COMPILER_HIDDEN_VISIBILITY + "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) # Just return if there are no flags to add. return() |