[CMake] setting LINKER_LANGUAGE still adds -lstdc++

Eric Noulard eric.noulard at gmail.com
Tue Oct 9 04:56:52 EDT 2012


2012/10/9 James Bigler <jamesbigler at gmail.com>:
> On Tue, Oct 9, 2012 at 12:07 AM, Eric Noulard <eric.noulard at gmail.com>
> wrote:
>>
>> 2012/10/9 James Bigler <jamesbigler at gmail.com>:
>> > In my project I need to manually link against a special version of
>> > libstdc++, so I manually set the target link language to C and then add
>> > my
>> > special library to the link line.  On Linux this seems to work just
>> > fine,
>> > but on OSX it still add -lstdc++ to the link like.  Here's my cmake
>> > code:
>>
>> This doesn't seem to work on Linux either on my side, stdc++ gets in the
>> link
>> line as well:
>>
>> /usr/bin/cc  -fPIC    -shared -Wl,-soname,liba.so -o liba.so
>> CMakeFiles/a.dir/a.cpp.o -lstdc++ -lm
>>
>> Did you try to fiddle with CMAKE_CXX_IMPLICIT_LINK_LIBRARIES ?
>>
>> --
>> Erk
>> Le gouvernement représentatif n'est pas la démocratie --
>> http://www.le-message.org
>
>
> I can manually remove the library thusly:
>
>    list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES stdc++)
>
> This "works around" the issue, but it is rather ugly (directory scoped
> rather than target scoped) and non-intuitive (there's no documentation for
> this flag - I had to dig it out of emails and source).

There is documentation:

$ cmake --help-variable "CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES"
cmake version 2.8.9.20121008-g63baa
  CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES
       Implicit link libraries and flags detected for language <LANG>.

       Compilers typically pass language runtime library names and other
       flags when they invoke a linker.  These flags are implicit link
       options for the compiler's language.  CMake automatically detects
       these libraries and flags for each language and reports the results in
       this variable.


Did you try "CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES" as well ?

Whatever the solution I agree this should be target specific.

-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list