Swift: Ignore WIN32_EXECUTABLE property outside of Windows

Issue: #19877
This commit is contained in:
hotwatermorning
2021-10-24 03:54:20 +09:00
committed by Brad King
parent 46bd57d245
commit c782f140d4
4 changed files with 19 additions and 6 deletions

View File

@@ -337,6 +337,12 @@ bool cmGlobalGenerator::CheckTargetsForType() const
bool failed = false; bool failed = false;
for (const auto& generator : this->LocalGenerators) { for (const auto& generator : this->LocalGenerators) {
for (const auto& target : generator->GetGeneratorTargets()) { for (const auto& target : generator->GetGeneratorTargets()) {
std::string systemName =
target->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (systemName.find("Windows") == std::string::npos) {
continue;
}
if (target->GetType() == cmStateEnums::EXECUTABLE) { if (target->GetType() == cmStateEnums::EXECUTABLE) {
std::vector<std::string> const& configs = std::vector<std::string> const& configs =
target->Makefile->GetGeneratorConfigs( target->Makefile->GetGeneratorConfigs(

View File

@@ -345,7 +345,7 @@ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STRE
add_RunCMake_test(RuntimePath) add_RunCMake_test(RuntimePath)
endif() endif()
add_RunCMake_test(ScriptMode) add_RunCMake_test(ScriptMode)
add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}) add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetProperties) add_RunCMake_test(TargetProperties)
add_RunCMake_test(ToolchainFile) add_RunCMake_test(ToolchainFile)

View File

@@ -6,11 +6,14 @@ if(RunCMake_GENERATOR STREQUAL Xcode)
endif() endif()
elseif(RunCMake_GENERATOR STREQUAL Ninja) elseif(RunCMake_GENERATOR STREQUAL Ninja)
if(CMAKE_Swift_COMPILER) if(CMAKE_Swift_COMPILER)
run_cmake(Win32ExecutableDisallowed) if (CMAKE_SYSTEM_NAME MATCHES "Windows")
run_cmake_with_options(Win32ExecutableDisallowed)
set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin) else()
run_cmake(SwiftMultiArch) run_cmake_with_options(Win32ExecutableIgnored)
unset(RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin)
run_cmake(SwiftMultiArch)
unset(RunCMake_TEST_OPTIONS)
endif()
endif() endif()
elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config")
if(CMAKE_Swift_COMPILER) if(CMAKE_Swift_COMPILER)

View File

@@ -0,0 +1,4 @@
enable_language(Swift)
add_executable(E E.swift)
set_target_properties(E PROPERTIES
WIN32_EXECUTABLE TRUE)