MantisBT - CMake
View Issue Details
0015359CMakeCMakepublic2015-01-19 16:392016-06-10 14:31
Laurent Demailly 
Kitware Robot 
normalfeaturealways
closedmoved 
Apple MacOS X10.4.10
CMake 3.1 
 
0015359: __attribute__((weak)) support/detection (weak symbols)
it would be great if some built in recipe would set some variable depending on whether the
compiler/linker support __attribute__((weak))


this is done in autoconf the following way for instance:

AC_CACHE_CHECK(
  [for weak symbol support],
  [folly_cv_prog_cc_weak_symbols],
  [AC_LINK_IFELSE(
    [AC_LANG_SOURCE[
      extern "C" void configure_link_extern_weak_test()
__attribute__((weak));
      int main(int argc, char** argv) {
          return configure_link_extern_weak_test == nullptr;
      }]],
    [folly_cv_prog_cc_weak_symbols="yes"],
    [folly_cv_prog_cc_weak_symbols="no"])])

if test "$folly_cv_prog_cc_weak_symbols" = yes; then
  AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
            [Define to 1 if the linker supports weak symbols.])
fi


ps: sent similar request (more of a question on how to do it pending built in support by cmake base) to the cmake@cmake.org mailing list - hope it's ok to have some amount of duplicate
No tags attached.
related to 0015361closed Kitware Robot CHECK_CXX_SOURCE_COMPILES doesn't use c++11 flags specified 
Issue History
2015-01-19 16:39Laurent DemaillyNew Issue
2015-01-19 16:43Brad KingNote Added: 0037749
2015-01-19 18:30Laurent DemaillyNote Added: 0037752
2015-01-20 08:31Brad KingRelationship addedrelated to 0015361
2016-06-10 14:29Kitware RobotNote Added: 0042700
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0037749)
Brad King   
2015-01-19 16:43   
Link to mailing list thread mentioned in description:

 detecting __attribute__((weak)) support
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.user/51503 [^]
(0037752)
Laurent Demailly   
2015-01-19 18:30   
so I tried to use
CHECK_CXX_SOURCE_COMPILES to do the above
and stepped on
http://public.kitware.com/Bug/view.php?id=15361 [^]

(2 different issues though - one would for cmake to know about weak symbol support and the other is how to test compile with the same flags as requested)
(0042700)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.