diff options
author | José Fonseca <jfonseca@vmware.com> | 2015-03-13 12:12:57 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2015-03-13 12:12:57 +0000 |
commit | 09531388e2aea19018ef03487d37a12547eb9325 (patch) | |
tree | f2e8a03a71bc2f228c91d2e8862b162514d82f93 /wrappers/CMakeLists.txt | |
parent | b132f86e0d2ae873f144de0bb3f39f4b7db674a4 (diff) |
cmake: Don't use -static-libstdc++ unless it was built with -fPIC.
Diffstat (limited to 'wrappers/CMakeLists.txt')
-rw-r--r-- | wrappers/CMakeLists.txt | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index 38b7e7c6..570f0a8a 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -6,7 +6,23 @@ if (ENABLE_STATIC_LIBGCC) add_linker_flags ("-static-libgcc") endif () if (ENABLE_STATIC_LIBSTDCXX) - add_linker_flags ("-static-libstdc++") + # Unfortunately for a long time static libstdcxx didn't built with -fPIC + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28811 + include (CheckCXXSourceCompiles) + set (CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) + set (CMAKE_REQUIRED_LIBRARIES -shared -static-libgcc -static-libstdc++) + check_cxx_source_compiles ( + " + #include <string> + std::string s; + " + STATIC_LIBSTDCXX_PIC + ) + unset (CMAKE_REQUIRED_LIBRARIES) + unset (CMAKE_REQUIRED_FLAGS) + if (STATIC_LIBSTDCXX_PIC) + add_linker_flags ("-static-libstdc++") + endif () endif () set (CMAKE_INCLUDE_CURRENT_DIR ON) |