summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-07-29 15:06:27 -0400
committerBrad King <brad.king@kitware.com>2019-07-29 15:24:29 -0400
commit601fe84bd175507b164d9a4a5ad938ed8ec3f7ec (patch)
treedcdb20b675adc1d0cf34296399f616cc9dcae220
parentf43a7d76c737c5bb9b903a2b1be5186c081ec21e (diff)
downloadcmake-601fe84bd175507b164d9a4a5ad938ed8ec3f7ec.tar.gz
Swift: Restore support for enabling with INTERFACE libraries
The check added in commit b06f4c8a74 (Swift: disallow WIN32_EXECUTABLE properties, 2019-05-31, v3.15.0-rc1~9^2) makes sense only for executables because the `WIN32_EXECUTABLE` property is defined only for them. Running the check on other target types, particularly those that do not link such as INTERFACE libraries, violates internal assumptions. In particular, `GetLinkerLanguage` should not be called on such targets. Fixes: #19528
-rw-r--r--Source/cmGlobalGenerator.cxx17
-rw-r--r--Tests/SwiftOnly/CMakeLists.txt3
2 files changed, 12 insertions, 8 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 4eba4ff93f..9afc15a6d9 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -339,15 +339,16 @@ bool cmGlobalGenerator::CheckTargetsForType() const
bool failed = false;
for (cmLocalGenerator* generator : this->LocalGenerators) {
for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
- std::vector<std::string> configs;
- target->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.emplace_back();
- }
+ if (target->GetType() == cmStateEnums::EXECUTABLE &&
+ target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ std::vector<std::string> configs;
+ target->Makefile->GetConfigurations(configs);
+ if (configs.empty()) {
+ configs.emplace_back();
+ }
- for (std::string const& config : configs) {
- if (target->GetLinkerLanguage(config) == "Swift") {
- if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ for (std::string const& config : configs) {
+ if (target->GetLinkerLanguage(config) == "Swift") {
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"WIN32_EXECUTABLE property is not supported on Swift "
diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt
index e5f858803e..f4cbac2123 100644
--- a/Tests/SwiftOnly/CMakeLists.txt
+++ b/Tests/SwiftOnly/CMakeLists.txt
@@ -8,3 +8,6 @@ elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
endif()
add_executable(SwiftOnly main.swift)
+
+# Dummy to make sure generation works with such targets.
+add_library(SwiftIface INTERFACE)