[CMake] LINK_FLAGS works incorrectly,

t m cmake at majchrowski.co.uk
Mon Apr 18 11:07:38 EDT 2011


>> I got a simple question,
>>
>> What is idea behind target property LINK_FLAGS?
>>
>> When I add linker flag e.g --no-undefined then cmake is not alligning
>> it to real linker that will be used during linking.
>>
>> for example --no-undefined is a valid ld switch, but when I specify it
>> LINK_FLAGS it will not reach linker since cmake is deciding to use g++
>> and is forgeting about adding -Wl, at the begining.
>>
>> In my opoinion it should be in a way:
>> 1. User is specyfing:
>> set_property(TARGET TEST property LINK_FLAGS "--no-undefined")
>> 2. cmake is coosing g++ as a linker, then variable CMAKE_SHARED_LINKING_FLAGS
>> should be extended with -Wl,--noundefined
>> 3. during make ld is called via g++ with passed flags --no-undefined.

>
> Thing is, with that property you can pass *everything* on the link-line,
> so it would be pretty bad if CMake just prefixed everything with -Wl,.
> Just do it yourself. And please, put it in a conditional
> block where you test for CMAKE_COMPILER_IS_GNUCXX).

Hi

Is it possible to prepare on-fly translation from g++ wrapped format
to the pure ld?. The following scenario would be useful:

 * common section will provide mapping. The common logic will be
include in all CMakeLists.txt files and in the body of all
CMakeLists.txt you will use
just flags as those are provided in the man of the linker. This will
separate the linker flags from the way howe those are finally passed
to the ld: directly or thrue the g++.

regards, T Majchrowski.


More information about the CMake mailing list