Merge topic 'ios-app-bundle-layout'
744e6c49
Fix iOS Bundle layouts (#15669)
This commit is contained in:
commit
58043880b9
|
@ -973,9 +973,13 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
|
||||||
bool contentOnly) const
|
bool contentOnly) const
|
||||||
{
|
{
|
||||||
std::string fpath = this->GetFullName(config, false);
|
std::string fpath = this->GetFullName(config, false);
|
||||||
fpath += ".app/Contents";
|
fpath += ".app";
|
||||||
if(!contentOnly)
|
if(!this->Makefile->PlatformIsAppleIos())
|
||||||
fpath += "/MacOS";
|
{
|
||||||
|
fpath += "/Contents";
|
||||||
|
if(!contentOnly)
|
||||||
|
fpath += "/MacOS";
|
||||||
|
}
|
||||||
return fpath;
|
return fpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,9 +1011,12 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fpath += ext;
|
fpath += ext;
|
||||||
fpath += "/Contents";
|
if(!this->Makefile->PlatformIsAppleIos())
|
||||||
if(!contentOnly)
|
{
|
||||||
fpath += "/MacOS";
|
fpath += "/Contents";
|
||||||
|
if(!contentOnly)
|
||||||
|
fpath += "/MacOS";
|
||||||
|
}
|
||||||
return fpath;
|
return fpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1028,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
|
||||||
std::string fpath;
|
std::string fpath;
|
||||||
fpath += this->GetOutputName(config, false);
|
fpath += this->GetOutputName(config, false);
|
||||||
fpath += ".framework";
|
fpath += ".framework";
|
||||||
if(!rootDir)
|
if(!rootDir && !this->Makefile->PlatformIsAppleIos())
|
||||||
{
|
{
|
||||||
fpath += "/Versions/";
|
fpath += "/Versions/";
|
||||||
fpath += this->Target->GetFrameworkVersion();
|
fpath += this->Target->GetFrameworkVersion();
|
||||||
|
@ -2168,9 +2175,12 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
|
||||||
if(this->Target->IsFrameworkOnApple())
|
if(this->Target->IsFrameworkOnApple())
|
||||||
{
|
{
|
||||||
realName = prefix;
|
realName = prefix;
|
||||||
realName += "Versions/";
|
if(!this->Makefile->PlatformIsAppleIos())
|
||||||
realName += this->Target->GetFrameworkVersion();
|
{
|
||||||
realName += "/";
|
realName += "Versions/";
|
||||||
|
realName += this->Target->GetFrameworkVersion();
|
||||||
|
realName += "/";
|
||||||
|
}
|
||||||
realName += base;
|
realName += base;
|
||||||
soName = realName;
|
soName = realName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2529,6 +2529,18 @@ bool cmMakefile::PlatformIs64Bit() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmMakefile::PlatformIsAppleIos() const
|
||||||
|
{
|
||||||
|
std::string sdkRoot;
|
||||||
|
sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT");
|
||||||
|
sdkRoot = cmSystemTools::LowerCase(sdkRoot);
|
||||||
|
|
||||||
|
return sdkRoot.find("iphoneos") == 0 ||
|
||||||
|
sdkRoot.find("/iphoneos") != std::string::npos ||
|
||||||
|
sdkRoot.find("iphonesimulator") == 0 ||
|
||||||
|
sdkRoot.find("/iphonesimulator") != std::string::npos;
|
||||||
|
}
|
||||||
|
|
||||||
const char* cmMakefile::GetSONameFlag(const std::string& language) const
|
const char* cmMakefile::GetSONameFlag(const std::string& language) const
|
||||||
{
|
{
|
||||||
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
|
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
|
||||||
|
|
|
@ -490,6 +490,9 @@ public:
|
||||||
/** Return whether the target platform is 64-bit. */
|
/** Return whether the target platform is 64-bit. */
|
||||||
bool PlatformIs64Bit() const;
|
bool PlatformIs64Bit() const;
|
||||||
|
|
||||||
|
/** Return whether the target platform is Apple iOS. */
|
||||||
|
bool PlatformIsAppleIos() const;
|
||||||
|
|
||||||
/** Retrieve soname flag for the specified language if supported */
|
/** Retrieve soname flag for the specified language if supported */
|
||||||
const char* GetSONameFlag(const std::string& language) const;
|
const char* GetSONameFlag(const std::string& language) const;
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,35 @@ run_cmake(XcodeObjectNeedsQuote)
|
||||||
if (NOT XCODE_VERSION VERSION_LESS 6)
|
if (NOT XCODE_VERSION VERSION_LESS 6)
|
||||||
run_cmake(XcodePlatformFrameworks)
|
run_cmake(XcodePlatformFrameworks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Use a single build tree for a few tests without cleaning.
|
||||||
|
|
||||||
|
if(NOT XCODE_VERSION VERSION_LESS 5)
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build)
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
set(RunCMake_TEST_OPTIONS "-DTEST_IOS=OFF")
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
|
||||||
|
run_cmake(XcodeBundles)
|
||||||
|
run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .)
|
||||||
|
|
||||||
|
unset(RunCMake_TEST_BINARY_DIR)
|
||||||
|
unset(RunCMake_TEST_NO_CLEAN)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
|
||||||
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build)
|
||||||
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
|
set(RunCMake_TEST_OPTIONS "-DTEST_IOS=ON")
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||||
|
|
||||||
|
run_cmake(XcodeBundles)
|
||||||
|
run_cmake_command(XcodeBundles-build ${CMAKE_COMMAND} --build .)
|
||||||
|
|
||||||
|
unset(RunCMake_TEST_BINARY_DIR)
|
||||||
|
unset(RunCMake_TEST_NO_CLEAN)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
# check if Xcode and CMake have the same understanding of Bundle layout
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
if(TEST_IOS)
|
||||||
|
set(CMAKE_OSX_SYSROOT iphoneos)
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES "armv7")
|
||||||
|
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
|
||||||
|
endif(TEST_IOS)
|
||||||
|
|
||||||
|
# App Bundle
|
||||||
|
|
||||||
|
add_executable(AppBundle MACOSX_BUNDLE main.m)
|
||||||
|
|
||||||
|
add_custom_target(AppBundleTest ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
"$<TARGET_FILE:AppBundle>" "$<TARGET_FILE:AppBundle>.old")
|
||||||
|
|
||||||
|
add_dependencies(AppBundleTest AppBundle)
|
||||||
|
|
||||||
|
# Framework (not supported for iOS on Xcode < 6)
|
||||||
|
|
||||||
|
if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6)
|
||||||
|
add_library(Framework SHARED main.c)
|
||||||
|
set_target_properties(Framework PROPERTIES FRAMEWORK TRUE)
|
||||||
|
|
||||||
|
add_custom_target(FrameworkTest ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
"$<TARGET_FILE:Framework>" "$<TARGET_FILE:Framework>.old")
|
||||||
|
|
||||||
|
add_dependencies(FrameworkTest Framework)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Bundle
|
||||||
|
|
||||||
|
add_library(Bundle MODULE main.c)
|
||||||
|
set_target_properties(Bundle PROPERTIES BUNDLE TRUE)
|
||||||
|
|
||||||
|
add_custom_target(BundleTest ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
"$<TARGET_FILE:Bundle>" "$<TARGET_FILE:Bundle>.old")
|
||||||
|
|
||||||
|
add_dependencies(BundleTest Bundle)
|
|
@ -0,0 +1,3 @@
|
||||||
|
int main(int argc, const char * argv[]) {
|
||||||
|
return 1;
|
||||||
|
}
|
Loading…
Reference in New Issue