summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-08-19 20:41:24 (GMT)
committerBrad King <brad.king@kitware.com>2020-08-21 13:17:27 (GMT)
commit3ef0c40962312a97d5a083c79ec563045fe28de3 (patch)
tree1b6231bd299e24a59ab83e8af875d77a1e287ba3 /Source
parent8de3a25ec34c4b2d3cd7e519d3c3607e81de34c4 (diff)
downloadCMake-3ef0c40962312a97d5a083c79ec563045fe28de3.zip
CMake-3ef0c40962312a97d5a083c79ec563045fe28de3.tar.gz
CMake-3ef0c40962312a97d5a083c79ec563045fe28de3.tar.bz2
WIN32_EXECUTABLE: Add support for generator expressions
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx3
-rw-r--r--Source/cmGeneratorTarget.cxx6
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmGlobalGenerator.cxx6
-rw-r--r--Source/cmLocalGenerator.cxx2
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx20
8 files changed, 33 insertions, 12 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 511168b..df68033 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -689,7 +689,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
{
switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
- if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) ||
+ if ((target->IsWin32Executable(
+ target->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))) ||
(target->GetPropertyAsBool("MACOSX_BUNDLE"))) {
return 0;
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 9611e14..7c526a0 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2266,6 +2266,12 @@ bool cmGeneratorTarget::IsBundleOnApple() const
this->IsCFBundleOnApple();
}
+bool cmGeneratorTarget::IsWin32Executable(const std::string& config) const
+{
+ return cmIsOn(cmGeneratorExpression::Evaluate(
+ this->GetSafeProperty("WIN32_EXECUTABLE"), this->LocalGenerator, config));
+}
+
std::string cmGeneratorTarget::GetCFBundleDirectory(
const std::string& config, BundleDirectoryLevel level) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 69c5faf..544b27a 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -284,6 +284,9 @@ public:
or CFBundle on Apple. */
bool IsBundleOnApple() const;
+ /** Return whether this target is a Win32 executable */
+ bool IsWin32Executable(const std::string& config) const;
+
/** Get the full name of the target according to the settings in its
makefile. */
std::string GetFullName(const std::string& config,
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index cad5d1f..a192ffd 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -335,13 +335,13 @@ bool cmGlobalGenerator::CheckTargetsForType() const
bool failed = false;
for (const auto& generator : this->LocalGenerators) {
for (const auto& target : generator->GetGeneratorTargets()) {
- if (target->GetType() == cmStateEnums::EXECUTABLE &&
- target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ if (target->GetType() == cmStateEnums::EXECUTABLE) {
std::vector<std::string> const& configs =
target->Makefile->GetGeneratorConfigs(
cmMakefile::IncludeEmptyConfig);
for (std::string const& config : configs) {
- if (target->GetLinkerLanguage(config) == "Swift") {
+ if (target->IsWin32Executable(config) &&
+ target->GetLinkerLanguage(config) == "Swift") {
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"WIN32_EXECUTABLE property is not supported on Swift "
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 2380cce..3cbc8ac 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1520,7 +1520,7 @@ void cmLocalGenerator::GetTargetFlags(
return;
}
- if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ if (target->IsWin32Executable(config)) {
exeFlags +=
this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
exeFlags += " ";
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 50ffe8d..ee7f74c 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1113,7 +1113,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
cmComputeLinkInformation& cli = *pcli;
std::string linkLanguage = cli.GetLinkLanguage();
- bool isWin32Executable = target->GetPropertyAsBool("WIN32_EXECUTABLE");
+ bool isWin32Executable = target->IsWin32Executable(configName);
// Compute the variable name to lookup standard libraries for this
// language.
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index bc288ac..9b5c6e6 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -371,7 +371,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->AddConfigVariableFlags(
linkFlags, "CMAKE_EXE_LINKER_FLAGS", this->GetConfigName());
- if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ if (this->GeneratorTarget->IsWin32Executable(
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))) {
this->LocalGenerator->AppendFlags(
linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"));
} else {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index db9dc53..fa6ad47 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -595,14 +595,24 @@ void cmVisualStudio10TargetGenerator::Generate()
case cmStateEnums::MODULE_LIBRARY:
outputType = "Module";
break;
- case cmStateEnums::EXECUTABLE:
- if (this->GeneratorTarget->Target->GetPropertyAsBool(
- "WIN32_EXECUTABLE")) {
+ case cmStateEnums::EXECUTABLE: {
+ auto const win32 =
+ this->GeneratorTarget->GetSafeProperty("WIN32_EXECUTABLE");
+ if (win32.find("$<") != std::string::npos) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Target \"", this->GeneratorTarget->GetName(),
+ "\" has a generator expression in its WIN32_EXECUTABLE "
+ "property. This is not supported on managed executables."));
+ return;
+ }
+ if (cmIsOn(win32)) {
outputType = "WinExe";
} else {
outputType = "Exe";
}
- break;
+ } break;
case cmStateEnums::UTILITY:
case cmStateEnums::INTERFACE_LIBRARY:
case cmStateEnums::GLOBAL_TARGET:
@@ -3731,7 +3741,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
if (this->MSTools) {
- if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ if (this->GeneratorTarget->IsWin32Executable(config)) {
if (this->GlobalGenerator->TargetsWindowsCE()) {
linkOptions.AddFlag("SubSystem", "WindowsCE");
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {