ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] configure fails with cmake on macosx

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Thu, 23 Sep 2010 16:05:24 -0700
On Sep 23, 2010, at 2:58 PM, H.sivank wrote:

> Hello Joerg
> 
> Le 23 sept. 2010 à 23:19, Joerg Mayer a écrit :
> 
>>> -apple_gcc.diff : fix for apple gcc
>> This fix is not correct in style. Can you please explain what is going wrong
>> here, maybe provide a log? If there is a problem, we need to fix the check in
>> cmake/modules/CheckCLinkerFlag.cmake.
>> Not applied.
> 
> configure:17893: checking whether we can add -Wl,--as-needed to LDFLAGS
> configure:17905: gcc -o conftest -g -O2 -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wpointer-arith -Wno-pointer-sign -Wcast-align -Wformat-security   -Wl,--as-needed conftest.c  >&5
> conftest.c:29: warning: return type defaults to 'int'
> conftest.c: In function 'main':
> conftest.c:29: warning: 'return' with no value, in function returning non-void
> ld: unknown option: --as-needed
> collect2: ld returned 1 exit status
> configure:17905: $? = 1
> configure: failed program was:

That's "the autoconf configure script is finding that, on OS X, you cannot add -Wl,--as-needed to LDFLAGS, because -Wl passes flags directly on to the linker, and the OS X linker (which isn't the GNU linker, just as the SunOS 5.x linker is not the GNU linker, and the linker on some other UN*Xes is not the GNU linker) does not support --as-needed".

1) That's not the configure *failing*, it's the configure finding that you can't use -Wl,--as-needed when linking, and setting up the Makefile not to use it.

2) I was under the impression that CMake was an *alternative* to autoconf, so that the configure script isn't even *used* with CMake.  If that's the case, then CMake needs to do the same things that autoconf does here, so that, on platforms where the linker supports --as-needed, we use it, and, on platforms where the linker doesn't support it (OS X isn't the only platform where the linker doesn't support it, so the check should be "does the linker support this flag?", not "is this OS X?"), we don't use it.