Hi, I noticed gcc is used to link a c++ library on SunOS due to Sun shipping GCC without a shared libstdc++ in the past (see discussion http://www.cmake.org/pipermail/cmake/2006-August/010535.html here). Since this does not seem to be the case anymore, changing the CMAKE_CXX_CREATE_SHARED_LIBRARY rule on new projects in vain becomes a nuisance as using gcc to invoke the linker has problems; missing options g++ tells the linker e.g. when profiling and maybe static initialization issues as well. So, could we check if libstdc++.so is present and if so, use the default rule from CMakeDefaultMakeRuleVariables.cmake file instead. I made a small patch to Modules/Platform/SunOS.cmake that does exatcly that:
--- SunOS.cmake.orig 2011-07-07 11:21:22.331321841 +0800 +++ SunOS.cmake 2011-07-07 11:21:27.149332933 +0800 @@ -5,12 +5,20 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*") +# Take the default c++ shared library creation rule from the +# CMakeDefaultMakeRuleVariables.cmake file unless using GCC and libstdc++.so +# does not exist, in which case fall back to the old implementation; +# using gcc to invoke the linker. IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") - ELSE(CMAKE_COMPILER_IS_GNUCC) - # Take default rule from CMakeDefaultMakeRuleVariables.cmake. + EXECUTE_PROCESS( + COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.so + OUTPUT_VARIABLE SHARED_LIBSTDCXX_FILENAME + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(NOT EXISTS "${SHARED_LIBSTDCXX_FILENAME}") + SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") + ENDIF(NOT EXISTS "${SHARED_LIBSTDCXX_FILENAME}") ENDIF(CMAKE_COMPILER_IS_GNUCC) ENDIF(CMAKE_COMPILER_IS_GNUCXX) INCLUDE(Platform/UnixPaths) Cheers, Pasi
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake