mirror of
https://github.com/reactos/CMake.git
synced 2024-11-28 05:50:42 +00:00
Swift: disallow WIN32_EXECUTABLE properties
Currently, the compiler does not synthesize the correct entry point for the application and passing the subsystem flag does not work the same way with the Swift linker language. Add a check to prevent the application of `WIN32_EXECUTABLE` to Swift executables until they can be properly supported. This will prevent the need for a future policy change. Closes: #19325
This commit is contained in:
parent
73472408c5
commit
b06f4c8a74
@ -331,6 +331,37 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
|
||||
return failed;
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::CheckTargetsForType() const
|
||||
{
|
||||
if (!this->GetLanguageEnabled("Swift")) {
|
||||
return false;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
for (std::string const& config : configs) {
|
||||
if (target->GetLinkerLanguage(config) == "Swift") {
|
||||
if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
|
||||
this->GetCMakeInstance()->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"WIN32_EXECUTABLE property is not supported on Swift "
|
||||
"executables",
|
||||
target->GetBacktrace());
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::IsExportedTargetsFile(
|
||||
const std::string& filename) const
|
||||
{
|
||||
@ -1414,6 +1445,10 @@ bool cmGlobalGenerator::Compute()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->CheckTargetsForType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (cmLocalGenerator* localGen : this->LocalGenerators) {
|
||||
localGen->ComputeHomeRelativeOutputPath();
|
||||
}
|
||||
|
@ -609,6 +609,7 @@ private:
|
||||
virtual void ForceLinkerLanguages();
|
||||
|
||||
bool CheckTargetsForMissingSources() const;
|
||||
bool CheckTargetsForType() const;
|
||||
|
||||
void CreateLocalGenerators();
|
||||
|
||||
|
2
Tests/RunCMake/Swift/E.swift
Normal file
2
Tests/RunCMake/Swift/E.swift
Normal file
@ -0,0 +1,2 @@
|
||||
func f() {
|
||||
}
|
@ -6,7 +6,7 @@ if(RunCMake_GENERATOR STREQUAL Xcode)
|
||||
endif()
|
||||
elseif(RunCMake_GENERATOR STREQUAL Ninja)
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
# Add Ninja-specific Swift tests here.
|
||||
run_cmake(Win32ExecutableDisallowed)
|
||||
endif()
|
||||
else()
|
||||
run_cmake(NotSupported)
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,4 @@
|
||||
^CMake Error at Win32ExecutableDisallowed.cmake:[0-9]+ \(add_executable\):
|
||||
WIN32_EXECUTABLE property is not supported on Swift executables
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
4
Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake
Normal file
4
Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
enable_language(Swift)
|
||||
add_executable(E E.swift)
|
||||
set_target_properties(E PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE)
|
Loading…
Reference in New Issue
Block a user