mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
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
This commit is contained in:
@@ -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 "
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user