[CMake] detecting __attribute__((weak)) support
Laurent Demailly
ldemailly at fb.com
Mon Jan 19 16:35:53 EST 2015
I searched and didn't find yet would it be reasonable to have built in
support in cmake for knowing if the platform/compiler supports weak
symbols ?
I'm porting the following autconf fragment:
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
And I'm not sure what's the best way to do such recipe in Cmake ?
(by hand for now pending possible support in 3.2+ maybe)
Laurent
More information about the CMake
mailing list