Wireshark-dev: Re: [Wireshark-dev] Mac Build Error
From: Roland Knall <[email protected]>
Date: Fri, 22 Jan 2016 08:42:27 +0100
On Fri, Jan 22, 2016 at 8:26 AM, Guy Harris <[email protected]> wrote:
On Jan 21, 2016, at 9:36 PM, Roland Knall <[email protected]> wrote:

> FYI, the only sure-fire way in CMAKE to set specific only linker flags is using the target properties.

So what's the best way to, within a .cmake file, create a temporary target, with those properties, and with a particular small piece of source code, build it, and note whether it succeeded or failed, so that we can check whether a given linker flag is supported by the linker we're using and, if and only if it is, adding it to the properties for our targets?

That's what we're trying to do here - the equivalent of what our AC_WIRESHARK_LDFLAGS_CHECK does with autotools.

That is the only really working method in my opinion. The issue with CheckCLinkerFlag.cmake is just, that it uses CMAKE_REQUIRED_FLAGS which is not working on XCode. And so far I cannot find anything else, then trying to build and link a test executable with EXECUTE_COMMAND ourselves just on XCode. 

> This works in 9 out of 10 cases on all 3 major plattforms. In my experience it depends on what is called, and when, and most likely fails with MSVC.

...and it needs to, at a minimum, work on all platforms where we're using the UN*X Makefile generator; extra credit if it also works with all the Visual Studio generators (where it would be useful if we want to use a flag supported by some, but not all, versions of VS's linker), the Xcode generator (where it would be useful if we want to use a flag supported by some, but not all, versions of OS X's ld), and the NMake generator (and there may be people who'd like it to work with the MinGW Makefile generator).

(Or have we found something that autotools can do that CMake just *can't* do?)

Sorry to disappoint ;-), but it can be done, just not in a convenient way. And the 9oo10 mostly is fixed by using a newer version then 2.8.12 for CMake. There are some issues already with the RC compiler and the NMake Generator (does not get the correct Include paths set), but the Visual Studio generator works just fine.

kind regards