On 26-Aug-15 22:53, Gregor Jasny wrote:
Hallo,
On 13/08/15 12:56, Ruslan Baratov wrote:
On 13-Aug-15 08:46, Gregor Jasny wrote:
On 13/08/15 01:44, Ruslan Baratov via cmake-developers wrote:
Sending patches with fix. Now it's possible to install simulator
libraries by:
> cmake --build _builds --config Release --target install -- -sdk
iphonesimulator
and device libraries by:
> cmake --build _builds --config Release --target install -- -sdk
iphoneos
or from Xcode IDE (build target install).
However this commands will install both libraries to the same location.
This behaviour can be improved by adding some code that will do lipo of
all libraries before install (i.e. universal libraries will be
installed). This can be achieved by using ONLY_ACTIVE_ARCHS=NO while
running Xcode build. The only question is about making install target
depends on two type of builds (-sdk iphonesimulator and -sdk iphoneos).
This was my preliminary work:
https://github.com/gjasny/CMake/commit/978dca25ac387bdec894a1ba2c934317f5f6169f
This looks great! I've spent several hours trying to figure out how
'$(EFFECTIVE_PLATFORM_NAME)' can be set to Xcode and some CMake friendly
string to cmake_install.cmake script. I didn't know Xcode understand
`${VAR}` syntax (probably it didn't, it's just expanded as an
environment variable). I've tested your fix and it works fine for me.
Since we don't need to replace string with path manually I think your
solution is neater. I've added description to commit and rebased it, see
attachment.
I just pushed the fix-ios-install topic including a test. Basically the
patch changes the invocation line of the script from
cmake -DBUILD_TYPE=Release-iphoneos -P cmake_install.cmake
to
cmake -DBUILD_TYPE=Release -DEFFECTIVE_PLATFORM_NAME=-iphoneos -P
cmake_install.cmake
and within the install script
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE
STATIC_LIBRARY FILES ".../Release/libfoo.a")
to
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE
STATIC_LIBRARY FILES ".../Release${EFFECTIVE_PLATFORM_NAME}/libfoo.a")
By keeping the ${EFFECTIVE_PLATFORM_NAME} a variable one is able to use
the same install script for iphoneos and iphonesimulator SDKs.
Please review and merge.
Thanks,
Gregor
Works fine for me with rebased version. Though some tests failed:
The following tests FAILED:
14 - kwsys.testDynamicLoader (Failed)
372 - RunCMake.FindPkgConfig (Failed)
392 - FindPackageModeMakefileTest (Failed)
I've tried version without patches (81ad562) and see this failures too,
so I guess it's not because of iOS fixes.
From my experience changes expected to be in format of `git
format-patch` command, so attaching them.
Thanks, Ruslo
>From daa92aa633809c196380ef544b8a193cfcd15d27 Mon Sep 17 00:00:00 2001
From: Gregor Jasny <[email protected]>
Date: Thu, 20 Aug 2015 22:29:49 +0200
Subject: [PATCH 1/3] Replace CMAKE_XCODE_EFFECTIVE_PLATFORMS with call to
PlatformIsAppleIos
Currently the CMAKE_XCODE_EFFECTIVE_PLATFORMS property acts only as
a kind of toggle switch to enable iOS project layout features.
But instead of relying on this undocumented property, better detect
the presence of an iOS SDK directly.
---
Source/cmTarget.cxx | 5 ++---
Tests/RunCMake/XcodeProject/XcodeBundles.cmake | 1 -
Tests/iOSNavApp/CMakeLists.txt | 1 -
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 49b3239..da314a6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3566,10 +3566,9 @@ bool cmTarget::ComputeOutputDir(const std::string& config,
// The generator may add the configuration's subdirectory.
if(!conf.empty())
{
- const char *platforms = this->Makefile->GetDefinition(
- "CMAKE_XCODE_EFFECTIVE_PLATFORMS");
+ bool iosPlatform = this->Makefile->PlatformIsAppleIos();
std::string suffix =
- usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
+ usesDefaultOutputDir && iosPlatform ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
this->Makefile->GetGlobalGenerator()->
AppendDirectoryForConfig("/", conf, suffix, out);
}
diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
index d5cb51f..2cbccfa 100644
--- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
@@ -6,7 +6,6 @@ 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)
diff --git a/Tests/iOSNavApp/CMakeLists.txt b/Tests/iOSNavApp/CMakeLists.txt
index 12c3ada..1fc33e0 100644
--- a/Tests/iOSNavApp/CMakeLists.txt
+++ b/Tests/iOSNavApp/CMakeLists.txt
@@ -3,7 +3,6 @@ project(NavApp3)
set(CMAKE_OSX_SYSROOT iphoneos4.3)
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
-set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
--
1.9.3 (Apple Git-50)
>From 514207ba050f57a737cc307146dc07d53aa30faf Mon Sep 17 00:00:00 2001
From: Gregor Jasny <[email protected]>
Date: Thu, 13 Aug 2015 13:03:02 +0300
Subject: [PATCH 2/3] Fix installation of iOS targets (#12506)
Since cmTarget::ComputeOutputDir results can be used in CMake code of script
cmake_install.cmake and in Xcode internals, string ${EFFECTIVE_PLATFORM_NAME}
should be used instead of $(EFFECTIVE_PLATFORM_NAME) because it works for both.
Value of CMAKE_CFG_INTDIR can't be used in BUILD_TYPE argument of install
command since it contains $(EFFECTIVE_PLATFORM_NAME) (e.g. equals to
`Release-iphoneos`, `Debug-iphoneos`, etc.).
---
Source/cmGlobalGenerator.cxx | 12 +++++++++++-
Source/cmTarget.cxx | 2 +-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 503c455..40f1fcf 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2427,7 +2427,17 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
{
std::string cfgArg = "-DBUILD_TYPE=";
- cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
+ bool iosPlatform = mf->PlatformIsAppleIos();
+ if(iosPlatform)
+ {
+ cfgArg += "$(CONFIGURATION)";
+ singleLine.push_back(cfgArg);
+ cfgArg = "-DEFFECTIVE_PLATFORM_NAME=$(EFFECTIVE_PLATFORM_NAME)";
+ }
+ else
+ {
+ cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
+ }
singleLine.push_back(cfgArg);
}
singleLine.push_back("-P");
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index da314a6..d6d509c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3568,7 +3568,7 @@ bool cmTarget::ComputeOutputDir(const std::string& config,
{
bool iosPlatform = this->Makefile->PlatformIsAppleIos();
std::string suffix =
- usesDefaultOutputDir && iosPlatform ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
+ usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : "";
this->Makefile->GetGlobalGenerator()->
AppendDirectoryForConfig("/", conf, suffix, out);
}
--
1.9.3 (Apple Git-50)
>From a02782939922500e4aa22976bb644acda2bfa415 Mon Sep 17 00:00:00 2001
From: Gregor Jasny <[email protected]>
Date: Sat, 15 Aug 2015 22:37:35 +0200
Subject: [PATCH 3/3] Xcode: Add unit test for iOS project install (#12506)
---
Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 14 ++++++++++++++
.../XcodeProject/XcodeInstallIOS-install-stdout.txt | 2 ++
Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake | 11 +++++++++++
Tests/RunCMake/XcodeProject/foo.cpp | 1 +
4 files changed, 28 insertions(+)
create mode 100644 Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt
create mode 100644 Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
create mode 100644 Tests/RunCMake/XcodeProject/foo.cpp
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index ef81739..382c990 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -11,6 +11,20 @@ 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}/XcodeInstallIOS-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(XcodeInstallIOS)
+ run_cmake_command(XcodeInstallIOS-install ${CMAKE_COMMAND} --build . --target install)
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(RunCMake_TEST_OPTIONS)
+
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS "-DTEST_IOS=OFF")
diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt
new file mode 100644
index 0000000..f2478be
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS-install-stdout.txt
@@ -0,0 +1,2 @@
+-- Install configuration: .*
+-- Installing: .*/ios_install/lib/libfoo.a
diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
new file mode 100644
index 0000000..e9accb6
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 2.8.5)
+
+project(XcodeInstallIOS)
+
+set(CMAKE_OSX_SYSROOT iphoneos)
+set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+
+set(CMAKE_OSX_ARCHITECTURES "armv7;i386")
+
+add_library(foo STATIC foo.cpp)
+install(TARGETS foo ARCHIVE DESTINATION lib)
diff --git a/Tests/RunCMake/XcodeProject/foo.cpp b/Tests/RunCMake/XcodeProject/foo.cpp
new file mode 100644
index 0000000..2fb55ee
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/foo.cpp
@@ -0,0 +1 @@
+void foo() { }
--
1.9.3 (Apple Git-50)
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers