[CMake] Checking whether particular *linker* flags are supported
Guy Harris
guy at alum.mit.edu
Fri Jan 22 15:24:59 EST 2016
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.)
More information about the CMake
mailing list