[CMake] Checking whether particular *linker* flags are supported

Guy Harris guy at alum.mit.edu
Tue Jan 26 03:12:11 EST 2016


On Jan 22, 2016, at 12:24 PM, Guy Harris <guy at alum.mit.edu> wrote:

> CMake has the macros CHECK_C_COMPILER_FLAG and CHECK_CXX_COMPILER_FLAG, which allow checking for whether a given C or C++ compiler flag is supported by the compiler being used.
> 
> However, there's no CHECK_LINKER_FLAG macro, so that you can check whether a given *linker* flag is supported by the linker being used, so there doesn't seem to be a good way to use a flag, such as the --as-needed flag, if it's not *required*, but is "nice to have", but isn't available on all platforms.
> 
> So what's the best way to do such a check?
> 
> (I'm assuming here that, for all generators on UN*X platforms, linking is done by using the compiler driver, so that you don't have to worry about, for example, using -Wl,{linker flag} with some generators and just {linker flag} with other generators.)

Bug 0015934:

	https://public.kitware.com/Bug/view.php?id=15934

filed.




More information about the CMake mailing list