[CMake] CMAKE_<LANG>_FLAGS added to link rule
Bill Hoffman
bill.hoffman at kitware.com
Mon Jul 12 13:33:35 EDT 2010
On 7/12/2010 1:20 PM, Brad King wrote:
> On 07/12/2010 01:12 PM, Verweij, Arjen wrote:
>> As a follow-up: redefining CMAKE_Fortran_LINK_EXECUTABLE to not include
>> <FLAGS> gets rid of the CMAKE_Fortran_FLAGS.. but perhaps other (useful)
>> stuff as well? As a sidetrack I’m starting to wonder what the purpose of
>> CMAKE_<LANG>_FLAGS is. The book lists it as cmake’s counterpart of the
>> environment variable, e.g. CMAKE_CXX_FLAGS and CXXFLAGS from the shell,
>> which means it doesn’t make sense to include it when linking. Am I
>> overlooking something here J
>
> AFAIK no one designed it this way, it "just happened" over time during
> development. My guess is that people wanted compile flags like "-m64"
> to be passed when the compiler is used as a front-end to the linker.
> Since it's been in the default rules for years we cannot change it
> without breaking compatibility.
>
> All of this was developed before CMake supported Fortran. I've seen
> very few C and C++ compilers that do not accept/ignore all of their
> compiler flags even when used as a linking front-end. That's likely
> why this wasn't caught at the beginning.
>
It also came from template instantiating C++ compilers. They have a
habit of compiling C++ code during the link, and if the flags are not
there things did not compile. Also, some flags like -fPIC where needed
with both.
-Bill
More information about the CMake
mailing list