diff options
author | Chuck Atkins <chuck.atkins@kitware.com> | 2015-08-24 18:33:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-21 14:12:13 (GMT) |
commit | 9784af1b50a142c0160058734c7e12cee5f2a15e (patch) | |
tree | 864a958bf6accb58c6d9de434e1675f4addd38b7 /Source/cmLocalGenerator.cxx | |
parent | 402bf096ec4aac75af096c3708ce51efaf4589d0 (diff) | |
download | CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.zip CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.tar.gz CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.tar.bz2 |
CMP0065: Restrict the use of CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS
This new policy restricts the addition of the shared library link flags
to executables only when the ENABLE_EXPORTS property is set to True.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4418ead..6c7b194 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1540,13 +1540,47 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. - std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; - linkFlagsVar += linkLanguage; - linkFlagsVar += "_FLAGS"; if( tgt.GetType() == cmTarget::EXECUTABLE ) { - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); - linkLibs += " "; + bool add_shlib_flags = false; + switch(tgt.Target->GetPolicyStatusCMP0065()) + { + case cmPolicies::WARN: + if(!tgt.GetPropertyAsBool("ENABLE_EXPORTS") && + this->Makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0065")) + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n" + "For compatibility with older versions of CMake, " + "additional flags may be added to export symbols on all " + "executables regardless of thier ENABLE_EXPORTS property."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to always add the flags + add_shlib_flags = true; + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) + ); + case cmPolicies::NEW: + // NEW behavior is to only add the flags if ENABLE_EXPORTS is on + add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS"); + break; + } + + if(add_shlib_flags) + { + std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; + linkFlagsVar += linkLanguage; + linkFlagsVar += "_FLAGS"; + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); + linkLibs += " "; + } } // Append the framework search path flags. |