From e17b1791843b473d0d57ccdbe98689d1be8228e2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Apr 2017 14:45:11 -0400 Subject: Features: On SunPro link with language standard compiler flag When C++ feature requirements or `CXX_STANDARD` cause us to compile on SunPro with the `-std=c++11` option, link with the option too. This is needed to make the compiler use the matching standard library. --- Modules/Compiler/SunPro-CXX.cmake | 1 + Source/cmLocalGenerator.cxx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index f4345b8..b4183db 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -36,6 +36,7 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dd1b86f..8ce158b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1321,6 +1321,15 @@ void cmLocalGenerator::AddLanguageFlagsForLinking( std::string& flags, cmGeneratorTarget const* target, const std::string& lang, const std::string& config) { + if (this->Makefile->IsOn("CMAKE_" + lang + + "_LINK_WITH_STANDARD_COMPILE_OPTION")) { + // This toolchain requires use of the language standard flag + // when linking in order to use the matching standard library. + // FIXME: If CMake gains an abstraction for standard library + // selection, this will have to be reconciled with it. + this->AddCompilerRequirementFlag(flags, target, lang); + } + this->AddLanguageFlags(flags, target, lang, config); } -- cgit v0.12