[kdelibs/frameworks] tier4/kde4support/src: Check for visibility support on gcc

David Faure faure at kde.org
Sun Dec 1 09:29:03 UTC 2013


On Thursday 28 November 2013 17:03:04 Aurélien Gâteau wrote:
> Git commit 3bc8af3ec4477b5ff7acedd74b27d0d359e8bd1f by Aurélien Gâteau.
> Committed on 28/11/2013 at 17:02.
> Pushed by gateau into branch 'frameworks'.
> 
> Check for visibility support on gcc
> 
> __KDE_HAVE_GCC_VISIBILITY was not defined in kdemacros.h.cmake, causing
> KDE_EXPORT and KDE_IMPORT to be no-ops, breaking builds of kde-runtime,
> kde-workspace and friends.
> 
> Don't know what to do for other compilers.

Looking at FindKDE4Internal.cmake in master, where this originally comes from,
you need two more things:
* setting it to TRUE for Clang.
* actually passing the flag (-fvisibility=hidden) to the compiler !

Interestingly tier1/kjs/src/kjs/CMakeLists.txt has another solution: running 
the test for all compilers. It also forgets to pass the flag to the compiler, 
though.

In fact, with the gcc version we require now, we might not even need to run 
this test, we could just set the flag? Then this can just become:

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  set(__KDE_HAVE_GCC_VISIBILITY TRUE)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()

An alternative is the more feature-based approach, to support any gcc-like 
compiler automatically (e.g. icc?)

check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
if ( __KDE_HAVE_GCC_VISIBILITY)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()

[in which case we could also replace GCC with COMPILER....]

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5



More information about the Kde-frameworks-devel mailing list