summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx44
-rw-r--r--Source/cmPolicies.h4
-rw-r--r--Source/cmTarget.cxx1
-rw-r--r--Source/cmTarget.h3
4 files changed, 46 insertions, 6 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.
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index b20c7a9..283f277 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -220,6 +220,10 @@ class cmPolicy;
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0064, \
"Support new TEST if() operator.", \
+ 3, 4, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0065, \
+ "Do not add flags to export symbols from executables without " \
+ "the ENABLE_EXPORTS target property.", \
3, 4, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 13e0d7e..bb44956 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -347,6 +347,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
this->SetPropertyDefault("ANDROID_GUI", 0);
this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", 0);
+ this->SetPropertyDefault("ENABLE_EXPORTS", 0);
}
if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY
|| this->TargetTypeValue == cmTarget::MODULE_LIBRARY)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index c86ec24..3e71dbd 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -41,7 +41,8 @@
F(CMP0046) \
F(CMP0052) \
F(CMP0060) \
- F(CMP0063)
+ F(CMP0063) \
+ F(CMP0065)
class cmake;
class cmMakefile;