diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2019-01-16 03:42:08 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2019-01-28 16:39:24 +0100 |
commit | 14520c762ca17b52c0b70c3e3cab866dfcba2dae (patch) | |
tree | 38c89a6d4d297be93f8377c075fe46f182786a9e /modules/TDEMacros.cmake | |
parent | 05ed76c79deed672e811663b068e8ce5d6bfcf3c (diff) | |
download | tde-cmake-14520c762ca17b52c0b70c3e3cab866dfcba2dae.tar.gz tde-cmake-14520c762ca17b52c0b70c3e3cab866dfcba2dae.zip |
Add tde_setup_gcc_visibility macro.
For the GCC visibility setting, a test is performed
whether the system is UNIX-type and also whether TQt
and tdelibs are built with GCC visibility support.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit b034c47597735608335f5da1e09adbd13ad5d6a5)
Diffstat (limited to 'modules/TDEMacros.cmake')
-rw-r--r-- | modules/TDEMacros.cmake | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 9c3de31..2e25486 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -1708,6 +1708,55 @@ macro( tde_setup_architecture_flags ) endmacro( ) +################################################# +##### +##### tde_setup_gcc_visibility + +macro( tde_setup_gcc_visibility ) + if( NOT DEFINED __KDE_HAVE_GCC_VISIBILITY ) + if( NOT UNIX ) + tde_message_fatal( "gcc visibility support was requested, but your system is not *NIX" ) + endif( NOT UNIX ) + + find_library( TQT_LIBFILE qt-mt HINTS "${TQT_LIBRARY_DIRS}" ) + if( NOT "${TQT_LIBFILE}" STREQUAL "TQT_LIBFILE-NOTFOUND" ) + message( STATUS "Performing Test HAVE_TQT_VISIBILITY" ) + execute_process( + COMMAND readelf --syms "${TQT_LIBFILE}" + OUTPUT_VARIABLE HAVE_TQT_VISIBILITY + ) + if( "${HAVE_TQT_VISIBILITY}" STREQUAL "" OR + "${HAVE_TQT_VISIBILITY}" MATCHES "DEFAULT[^\n]*QSettingsPrivate" ) + message( STATUS "Performing Test HAVE_TQT_VISIBILITY - Failed" ) + tde_message_fatal( "gcc visibility support was requested, but not supported in qt library" ) + endif( ) + message( STATUS "Performing Test HAVE_TQT_VISIBILITY - Success" ) + endif( ) + + find_file( TDEMACROS_H kdemacros.h HINTS "${TDE_INCLUDE_DIR}" ) + if( NOT "${TDEMACROS_H}" STREQUAL "TDEMACROS_H-NOTFOUND" ) + tde_save_and_set( CMAKE_REQUIRED_INCLUDES "${TDE_INCLUDE_DIR}" ) + check_cxx_source_compiles( " + #include <kdemacros.h> + #ifndef __KDE_HAVE_GCC_VISIBILITY + #error gcc visibility is not enabled in tdelibs + #endif + int main() { return 0; } " + HAVE_TDE_VISIBILITY + ) + tde_restore( CMAKE_REQUIRED_INCLUDES ) + if( NOT HAVE_TDE_VISIBILITY ) + tde_message_fatal( "gcc visibility support was requested, but not supported in tdelibs" ) + endif( NOT HAVE_TDE_VISIBILITY ) + endif( ) + + set( __KDE_HAVE_GCC_VISIBILITY 1 ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") + endif( ) +endmacro( ) + + ################################################ ##### ##### Restore CMP0026 policy |