[CMake] setting LINKER_LANGUAGE still adds -lstdc++

James Bigler jamesbigler at gmail.com
Tue Oct 9 00:40:38 EDT 2012


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:

cmake_minimum_required(VERSION 2.8)
project(linking_fun)

add_library(a SHARED a.cpp)
set_target_properties(a PROPERTIES LINKER_LANGUAGE "C")

add_library(b SHARED b.c)

a.cpp and b.c both simply have 'int foo() { return 3;}'


And here's the compiler output which has the -lstdc++ on the link line for
library a, but not for library b.

Linking C shared library liba.dylib
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/a.dir/link.txt
--verbose=1
/usr/bin/gcc   -dynamiclib -Wl,-headerpad_max_install_names   -o liba.dylib
-install_name /Users/jbigler/code/temp/cmake/static-libstdcpp/liba.dylib
CMakeFiles/a.dir/a.cpp.o
-lstdc++/usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.osx.a
/opt/local/bin/cmake -E cmake_progress_report
/Users/jbigler/code/temp/cmake/static-libstdcpp/CMakeFiles  1
[ 50%] Built target a
make -f CMakeFiles/b.dir/build.make CMakeFiles/b.dir/depend
cd /Users/jbigler/code/temp/cmake/static-libstdcpp && /opt/local/bin/cmake
-E cmake_depends "Unix Makefiles"
/Users/jbigler/code/temp/cmake/static-libstdcpp
/Users/jbigler/code/temp/cmake/static-libstdcpp
/Users/jbigler/code/temp/cmake/static-libstdcpp
/Users/jbigler/code/temp/cmake/static-libstdcpp
/Users/jbigler/code/temp/cmake/static-libstdcpp/CMakeFiles/b.dir/DependInfo.cmake
--color=
make -f CMakeFiles/b.dir/build.make CMakeFiles/b.dir/build
Linking C shared library libb.dylib
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/b.dir/link.txt
--verbose=1
/usr/bin/gcc   -dynamiclib -Wl,-headerpad_max_install_names   -o libb.dylib
-install_name /Users/jbigler/code/temp/cmake/static-libstdcpp/libb.dylib
CMakeFiles/b.dir/b.c.o

Is this a bug or a "feature"?

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121008/2778dc3e/attachment-0001.htm>


More information about the CMake mailing list