Wireshark-dev: Re: [Wireshark-dev] Mac Build Error
From: Guy Harris <[email protected]>
Date: Thu, 21 Jan 2016 12:28:01 -0800
On Jan 21, 2016, at 12:10 PM, David Morsberger <[email protected]> wrote:

> I think this is a bug in cmake because:
>  
> 1. the 'and run' in "CheckCSourceRuns: Check if the given C source code compiles and runs" should imply linking and executing the software.

Yes, and it *does* imply that.

The problem is that it doesn't let you cleanly specify which linker flags to use when doing the linking.

I think the underlying problem here is that CMake treats *compiler* flags as first-class citizens but somewhat neglected *linker* flags.

At minimum, CHECK_C_SOURCE_RUNS should have a CMAKE_REQUIRED_LDFLAGS variable, which is a string of *linker* command line flags, and should do whatever is appropriate to pass those flags to the linker.  If the linker is run from the compiler driver program (cc, gcc, clang, whatever), then it should prepend the "pass this through to the linker" option ("-Wl," or whatever) and provide that to the compiler during the *link* phase but *not* during the compile phase; if it's run directly, it should do whatever is necessary to pass the flag to the linker.