mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 11:18:40 +08:00
.xcframework: Check SupportedPlatformVariant
This commit is contained in:
@@ -2586,6 +2586,17 @@ bool cmMakefile::PlatformIsAppleEmbedded() const
|
||||
return this->GetAppleSDKType() != AppleSDK::MacOS;
|
||||
}
|
||||
|
||||
bool cmMakefile::PlatformIsAppleSimulator() const
|
||||
{
|
||||
return std::set<AppleSDK>{
|
||||
AppleSDK::AppleTVSimulator,
|
||||
AppleSDK::IPhoneSimulator,
|
||||
AppleSDK::WatchSimulator,
|
||||
AppleSDK::XRSimulator,
|
||||
}
|
||||
.count(this->GetAppleSDKType());
|
||||
}
|
||||
|
||||
bool cmMakefile::PlatformSupportsAppleTextStubs() const
|
||||
{
|
||||
return this->IsOn("APPLE") && this->IsSet("CMAKE_TAPI");
|
||||
|
@@ -573,6 +573,9 @@ public:
|
||||
/** Return whether the target platform is Apple iOS. */
|
||||
bool PlatformIsAppleEmbedded() const;
|
||||
|
||||
/** Return whether the target platform is an Apple simulator. */
|
||||
bool PlatformIsAppleSimulator() const;
|
||||
|
||||
/** Return whether the target platform supports generation of text base stubs
|
||||
(.tbd file) describing exports (Apple specific). */
|
||||
bool PlatformSupportsAppleTextStubs() const;
|
||||
|
@@ -68,6 +68,30 @@ bool PlistSupportedPlatformHelper(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlistSupportedPlatformVariantHelper(
|
||||
cmXcFrameworkPlistSupportedPlatformVariant& variant,
|
||||
const Json::Value* value, cmJSONState* /*state*/)
|
||||
{
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value->isString()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value->asString() == "catalyst"_s) {
|
||||
variant = cmXcFrameworkPlistSupportedPlatformVariant::catalyst;
|
||||
return true;
|
||||
}
|
||||
if (value->asString() == "simulator"_s) {
|
||||
variant = cmXcFrameworkPlistSupportedPlatformVariant::simulator;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto const PlistLibraryHelper =
|
||||
cmJSONHelperBuilder::Object<cmXcFrameworkPlistLibrary>{}
|
||||
.Bind("LibraryIdentifier"_s, &cmXcFrameworkPlistLibrary::LibraryIdentifier,
|
||||
@@ -81,7 +105,13 @@ auto const PlistLibraryHelper =
|
||||
cmJSONHelperBuilder::Vector<std::string>(
|
||||
JsonErrors::EXPECTED_TYPE("array"), cmJSONHelperBuilder::String()))
|
||||
.Bind("SupportedPlatform"_s, &cmXcFrameworkPlistLibrary::SupportedPlatform,
|
||||
PlistSupportedPlatformHelper);
|
||||
PlistSupportedPlatformHelper)
|
||||
.Bind("SupportedPlatformVariant"_s,
|
||||
&cmXcFrameworkPlistLibrary::SupportedPlatformVariant,
|
||||
cmJSONHelperBuilder::Optional<
|
||||
cmXcFrameworkPlistSupportedPlatformVariant>(
|
||||
PlistSupportedPlatformVariantHelper),
|
||||
false);
|
||||
|
||||
auto const PlistHelper =
|
||||
cmJSONHelperBuilder::Object<cmXcFrameworkPlist>{}.Bind(
|
||||
@@ -139,6 +169,10 @@ const cmXcFrameworkPlistLibrary* cmXcFrameworkPlist::SelectSuitableLibrary(
|
||||
const cmMakefile& mf, const cmListFileBacktrace& bt) const
|
||||
{
|
||||
auto systemName = mf.GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
||||
cm::optional<cmXcFrameworkPlistSupportedPlatformVariant> systemVariant;
|
||||
if (mf.PlatformIsAppleSimulator()) {
|
||||
systemVariant = cmXcFrameworkPlistSupportedPlatformVariant::simulator;
|
||||
}
|
||||
|
||||
for (auto const& lib : this->AvailableLibraries) {
|
||||
std::string supportedSystemName;
|
||||
@@ -160,7 +194,8 @@ const cmXcFrameworkPlistLibrary* cmXcFrameworkPlist::SelectSuitableLibrary(
|
||||
break;
|
||||
}
|
||||
|
||||
if (systemName == supportedSystemName) {
|
||||
if (systemName == supportedSystemName &&
|
||||
systemVariant == lib.SupportedPlatformVariant) {
|
||||
return &lib;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,12 @@ enum class cmXcFrameworkPlistSupportedPlatform
|
||||
visionOS,
|
||||
};
|
||||
|
||||
enum class cmXcFrameworkPlistSupportedPlatformVariant
|
||||
{
|
||||
catalyst,
|
||||
simulator,
|
||||
};
|
||||
|
||||
struct cmXcFrameworkPlistLibrary
|
||||
{
|
||||
std::string LibraryIdentifier;
|
||||
@@ -27,6 +33,8 @@ struct cmXcFrameworkPlistLibrary
|
||||
std::string HeadersPath;
|
||||
std::vector<std::string> SupportedArchitectures;
|
||||
cmXcFrameworkPlistSupportedPlatform SupportedPlatform;
|
||||
cm::optional<cmXcFrameworkPlistSupportedPlatformVariant>
|
||||
SupportedPlatformVariant;
|
||||
};
|
||||
|
||||
struct cmXcFrameworkPlist
|
||||
|
@@ -1,8 +1,8 @@
|
||||
include(RunCMake)
|
||||
|
||||
function(create_library type platform system_name archs)
|
||||
function(create_library type platform system_name archs sysroot)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-${type}-${platform}-build)
|
||||
run_cmake_with_options(create-${type}-${platform} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install)
|
||||
run_cmake_with_options(create-${type}-${platform} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DCMAKE_OSX_SYSROOT=${sysroot} -DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install)
|
||||
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_command(create-${type}-${platform}-build ${CMAKE_COMMAND} --build . --config Release)
|
||||
@@ -10,12 +10,18 @@ function(create_library type platform system_name archs)
|
||||
endfunction()
|
||||
|
||||
function(create_libraries type)
|
||||
create_library(${type} macos Darwin "${macos_archs_2}")
|
||||
create_library(${type} ios iOS "arm64")
|
||||
create_library(${type} tvos tvOS "arm64")
|
||||
create_library(${type} watchos watchOS "armv7k\\\\;arm64_32")
|
||||
create_library(${type} macos Darwin "${macos_archs_2}" macosx)
|
||||
create_library(${type} ios iOS "arm64" iphoneos)
|
||||
create_library(${type} tvos tvOS "arm64" appletvos)
|
||||
create_library(${type} watchos watchOS "armv7k\\\\;arm64_32" watchos)
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
||||
create_library(${type} visionos visionOS "arm64")
|
||||
create_library(${type} visionos visionOS "arm64" xros)
|
||||
endif()
|
||||
create_library(${type} ios-simulator iOS "${macos_archs_2}" iphonesimulator)
|
||||
create_library(${type} tvos-simulator tvOS "${macos_archs_2}" appletvsimulator)
|
||||
create_library(${type} watchos-simulator watchOS "${watch_sim_archs_2}" watchsimulator)
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
||||
create_library(${type} visionos-simulator visionOS "${macos_archs_2}" xrsimulator)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -32,34 +38,42 @@ function(create_xcframework name type platforms)
|
||||
run_cmake_command(create-xcframework-${name} xcodebuild -create-xcframework ${args} -output ${RunCMake_TEST_BINARY_DIR}/mylib.xcframework)
|
||||
endfunction()
|
||||
|
||||
function(create_executable name xcfname system_name archs)
|
||||
function(create_executable name xcfname system_name archs sysroot)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/create-executable-${name}-build)
|
||||
run_cmake_with_options(create-executable-${name} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-${xcfname}-build/mylib.xcframework)
|
||||
run_cmake_with_options(create-executable-${name} -DCMAKE_SYSTEM_NAME=${system_name} -DCMAKE_OSX_ARCHITECTURES=${archs} -DCMAKE_OSX_SYSROOT=${sysroot} -DMYLIB_LIBRARY=${RunCMake_BINARY_DIR}/create-xcframework-${xcfname}-build/mylib.xcframework)
|
||||
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_command(create-executable-${name}-build ${CMAKE_COMMAND} --build . --config Release)
|
||||
endfunction()
|
||||
|
||||
function(create_executables name type)
|
||||
create_executable(${name}-macos ${type} Darwin "${macos_archs_2}")
|
||||
create_executable(${name}-ios ${type} iOS "arm64")
|
||||
create_executable(${name}-tvos ${type} tvOS "arm64")
|
||||
create_executable(${name}-watchos ${type} watchOS "armv7k\\\\;arm64_32")
|
||||
create_executable(${name}-macos ${type} Darwin "${macos_archs_2}" macosx)
|
||||
create_executable(${name}-ios ${type} iOS "arm64" iphoneos)
|
||||
create_executable(${name}-tvos ${type} tvOS "arm64" appletvos)
|
||||
create_executable(${name}-watchos ${type} watchOS "armv7k\\\\;arm64_32" watchos)
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
||||
create_executable(${name}-visionos ${type} visionOS "arm64")
|
||||
create_executable(${name}-visionos ${type} visionOS "arm64" xros)
|
||||
endif()
|
||||
create_executable(${name}-ios-simulator ${type} iOS "${macos_archs_2}" iphonesimulator)
|
||||
create_executable(${name}-tvos-simulator ${type} tvOS "${macos_archs_2}" appletvsimulator)
|
||||
create_executable(${name}-watchos-simulator ${type} watchOS "${watch_sim_archs_2}" watchsimulator)
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
||||
create_executable(${name}-visionos-simulator ${type} visionOS "${macos_archs_2}" xrsimulator)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(xcframework_platforms macos ios tvos watchos)
|
||||
set(xcframework_platforms macos ios tvos watchos ios-simulator tvos-simulator watchos-simulator)
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
||||
list(APPEND xcframework_platforms visionos)
|
||||
list(APPEND xcframework_platforms visionos visionos-simulator)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
|
||||
set(macos_archs_1 "x86_64\\;arm64")
|
||||
set(macos_archs_2 "x86_64\\\\;arm64")
|
||||
set(watch_sim_archs_2 "x86_64")
|
||||
else()
|
||||
set(macos_archs_1 "x86_64")
|
||||
set(macos_archs_2 "x86_64")
|
||||
set(watch_sim_archs_2 "i386")
|
||||
endif()
|
||||
|
||||
create_libraries(library)
|
||||
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target-link-phase.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-executable-target.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-framework.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-framework.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-framework.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-framework.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-library.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-library.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-library.cmake)
|
@@ -0,0 +1 @@
|
||||
include(create-library.cmake)
|
Reference in New Issue
Block a user