From kde-buildsystem Fri Feb 17 17:31:58 2012 From: Alexander Neundorf Date: Fri, 17 Feb 2012 17:31:58 +0000 To: kde-buildsystem Subject: Re: hidden visibility Message-Id: <201202171831.59139.neundorf () kde ! org> X-MARC-Message: https://marc.info/?l=kde-buildsystem&m=132950003830692 On Friday 17 February 2012, Stephen Kelly wrote: > Alexander Neundorf wrote: > > Hi Stephen, > > > > with your export header stuff you did for cmake 2.8.7, you must have done > > a lot with the symbol visibility stuff. > > > > Is there now a cmake module which I can use to check whether visibility > > is supported by the current compiler ? > > The current implementation is there since 2.8.6 in > Modules/GenerateExportHeader.cmake. > > COMPILER_HAS_HIDDEN_VISIBILITY > > is true if it has visibility. > > USE_COMPILER_HIDDEN_VISIBILITY > > is an option the user can set to disable using it (default ON). In FindKDE4Internal.cmake we also have checks for visibility support: set(_GCC_COMPILED_WITH_BAD_ALLOCATOR FALSE) exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} -v OUTPUT_VARIABLE _gcc_alloc_info) string(REGEX MATCH "(--enable-libstdcxx-allocator=mt)" _GCC_COMPILED_WITH_BAD_ALLOCATOR "${_gcc_alloc_info}") if (__KDE_HAVE_GCC_VISIBILITY AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") set (KDE4_C_FLAGS "-fvisibility=hidden") ...some Qt related check set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -fvisibility-inlines-hidden") else() ... It would be nice if we could get rid of this code, and use what is in GenerateExportHeader.cmake instead. Can you maybe refactor GenerateExportHeader.cmake a bit so that I could do something like check_visibility_support(success_var flag_var) which returns TRUE/FALSE in success_var and the flag for the current compiler in flag_var ? I'm not quite sure in the code above in which cases there is a "bad allocator", and whether "-Werror=return-type -fvisibility-inlines-hidden" is something everybody should do or not. Alex _______________________________________________ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem