[CMake] CMAKE_<LANG>_FLAGS added to link rule

Michael Hertling mhertling at online.de
Mon Jul 12 16:16:40 EDT 2010


On 07/12/2010 07: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 :)

In GCC's documentation, one can read:

"-shared
    Produce a shared object which can then be linked with other objects
    to form an executable. Not all systems support this option. For
    predictable results, you must also specify the same set of options
    that were used to generate code (-fpic, -fPIC, or model suboptions)
    when you specify this option.[1]"

"[1] On some systems, `gcc -shared' needs to build supplementary stub
     code for constructors to work. On multi-libbed systems, `gcc
     -shared' must select the correct support libraries to link
     against. Failing to supply the correct flags may lead to subtle
     defects. Supplying them in cases where they are not necessary is
     innocuous."

Apparently, there may be - at least with GCC and shared libraries - a
need to specify flags on the link line if they have been specified on
the compile line before. Though, I don't know an example of a damaged
binary due to different sets of flags for compiling and linking.

Regards,

Michael


More information about the CMake mailing list