For shared libraries you can use the GetPrerequisites standard module to test if the library depends on libstc++ or libc++.
For example, the following code test if boost's program_options
library has been compiled against libstc++ or libc++:
set (_library "/usr/local/lib/libboost_program_options.dylib")
set (_prequesites "")
set (_exclude_system FALSE)
set (_recurse FALSE)
set (_exePath "")
set (_searchDirs "")
get_prerequisites(${_library} _prequesites ${_exclude_system} ${_recurse} "${_exePath}" "${_searchDirs}")
if (_prequesites MATCHES "/libstdc\\+\\+")
message("using libstc++")
elseif (_prequesites MATCHES "/libc\\+\\+")
message("using libc++")
else()
message("using neither libstc++ nor libc++")
endif()
For static libraries you probably have to resort to running nm
on the library file to determine external symbols and then search for characteristic strings like __gnu_
in the output.