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:<div>
<br></div><div><div>cmake_minimum_required(VERSION 2.8)</div><div>project(linking_fun)</div><div><br></div><div>add_library(a SHARED a.cpp)</div><div>set_target_properties(a PROPERTIES LINKER_LANGUAGE "C")</div>
<div><br></div><div>add_library(b SHARED b.c)</div></div><div><br></div><div>a.cpp and b.c both simply have 'int foo() { return 3;}'</div><div><br></div><div><br></div><div>And here's the compiler output which has the -lstdc++ on the link line for library a, but not for library b.</div>
<div><br></div><div><div><font color="#ff0000">Linking C shared library liba.dylib</font></div><div>/opt/local/bin/cmake -E cmake_link_script CMakeFiles/a.dir/link.txt --verbose=1</div><div>/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 <span style="background-color:rgb(255,255,0)">-lstdc++</span> /usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.osx.a </div>
<div>/opt/local/bin/cmake -E cmake_progress_report /Users/jbigler/code/temp/cmake/static-libstdcpp/CMakeFiles 1</div><div>[ 50%] Built target a</div><div>make -f CMakeFiles/b.dir/build.make CMakeFiles/b.dir/depend</div>
<div>
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=</div>
<div>make -f CMakeFiles/b.dir/build.make CMakeFiles/b.dir/build</div><div><font color="#ff0000">Linking C shared library libb.dylib</font></div><div>/opt/local/bin/cmake -E cmake_link_script CMakeFiles/b.dir/link.txt --verbose=1</div>
<div>/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 </div></div><div><br></div><div>Is this a bug or a "feature"?</div>
<div><br></div><div>James</div>