MantisBT - CMake
View Issue Details
0012506CMakeCMakepublic2011-10-09 18:012016-02-01 09:10
Geoff Beier 
Gregor Jasny 
normalminoralways
closedfixed 
Apple MacOS X10.7.1
CMake 2.8.6 
CMake 3.4 
0012506: install( TARGET ) does not work for iOS targets
As of CMake 2.8.6, build products are generated into Release-iphoneos, Debug-iphoneos, etc. When using install(TARGET ...) cmake_install.cmake contains blocks that test for

"${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$"

and the like, then attempt to find the files in
cmake-build/Release$(EFFECTIVE_PLATFORM_NAME)...

There is no way (with 2.8.6) to have the test for CMAKE_INSTALL_CONFIG_NAME match and have the source path be correct. Whether or not CMAKE_XCODE_EFFECTIVE_PLATFORMS is set, build products land in directories containing the platform name. If CMAKE_XCODE_EFFECTIVE_PLATFORMS is set, the CMAKE_INSTALL_CONFIG_NAME test never matches, and the file copy is never attempted.

This is mostly a problem when building iOS libraries, but can be easily reproduced using the iOSNavApp from the Tests shipped with cmake 2.8.6.
1. Append the line
INSTALL( TARGETS NavApp3 BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime )
to Tests/iOSNavApp/CMakeLists.txt

2. Generate xcode build files using
cmake -G Xcode -DCMAKE_INSTALL_PREFIX=/Users/Shared/ios-staging ..

3. xcodebuild -target install -configuration Release

Expected Result: NavApp3.app copied to ${CMAKE_INSTALL_PREFIX}
Actual Result: No copy occurs
The main reason we want to get the install feature working is so that we can install development libraries. This was working in 2.8.4, but I think that was just luck because we weren't setting CMAKE_XCODE_EFFECTIVE_PLATFORMS and cmake wasn't automatically putting the build products into a "-iphoneos" location.

I've attached the modified CMakeLists.txt for iOSNavApp that demonstrates this issue.
No tags attached.
txt CMakeLists.txt (1,387) 2011-10-09 18:01
https://public.kitware.com/Bug/file/4072/CMakeLists.txt
Issue History
2011-10-09 18:01Geoff BeierNew Issue
2011-10-09 18:01Geoff BeierFile Added: CMakeLists.txt
2011-10-11 13:04David ColeAssigned To => David Cole
2011-10-11 13:04David ColeStatusnew => assigned
2011-12-21 18:35AndrewFNote Added: 0028031
2012-01-07 09:59David ColeTarget Version => CMake 2.8.8
2012-04-19 08:48David ColeTarget VersionCMake 2.8.8 => CMake 2.8.9
2012-07-09 07:13David ColeNote Added: 0029991
2012-07-09 07:20David ColeTarget VersionCMake 2.8.9 =>
2012-11-21 14:57David ColeNote Added: 0031659
2012-11-21 14:59David ColeAssigned ToDavid Cole =>
2012-11-21 15:11David ColeStatusassigned => new
2012-11-21 15:11David ColeNote Added: 0031668
2013-07-25 09:51Clodéric MarsNote Added: 0033609
2014-01-22 05:18Ruslan BaratovNote Added: 0034985
2014-01-23 09:24Ruslan BaratovNote Added: 0034991
2015-05-07 10:22bagageNote Added: 0038727
2015-05-07 10:43bagageNote Edited: 0038727bug_revision_view_page.php?bugnote_id=38727#r1777
2015-08-07 04:26Gregor JasnyNote Added: 0039249
2015-08-26 15:56Gregor JasnyNote Added: 0039332
2015-08-26 15:56Gregor JasnyAssigned To => Gregor Jasny
2015-08-26 15:56Gregor JasnyStatusnew => assigned
2015-09-14 16:40Gregor JasnyStatusassigned => resolved
2015-09-14 16:40Gregor JasnyFixed in Version => CMake 3.4
2015-09-14 16:40Gregor JasnyResolutionopen => fixed
2016-02-01 09:10Robert MaynardNote Added: 0040404
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0028031)
AndrewF   
2011-12-21 18:35   
We just ran across this same bug. It took me some time to figure out what was happening, since everything worked fine in cmake 2.8.4 as indicated. Huge thanks for this bug report. Hope it is fixed in the next release.

I put together a simple hack-ish way to get the target installed until this is fixed. Nothing very clever, but it gets the job done. It uses the environment variables xcode defines to locate the correct target location.

Example code is below:


if (IOS)
   install (FILES ${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}\$ENV{EFFECTIVE_PLATFORM_NAME}/mytargetfilename DESTINATION mydestination)
endif (IOS)
(0029991)
David Cole   
2012-07-09 07:13   
Unset target version field; too late for a fix to go into 2.8.9; deferred until a future version.
(0031659)
David Cole   
2012-11-21 14:57   
Un-assigning bugs that are not on the active roadmap, which no developers are actively working on for the CMake 2.8.11 release.

If one gets put back on the roadmap, re-assign it appropriately at that time.
(0031668)
David Cole   
2012-11-21 15:11   
Re-setting status back to "new" for bugs that are "assigned" but not assigned to a specific developer. When/if these bugs go back on the roadmap for a specific version, assignment to an appropriate developer should take place then...
(0033609)
Clodéric Mars   
2013-07-25 09:51   
As of CMake 2.8.11, the bug is still here and it is still a pain.

I've found another workaround for the issue which, contrary to the first one still rely on the INSTALL(TARGET).

It is this call 'cmake -DBUILD_TYPE=Debug-iphoneos -P cmake_install.cmake' (or 'cmake -DBUILD_TYPE=Debug-iphonesimulator -P cmake_install.cmake') that fails to install the target, for a very simple reason the target that is asked to be installed doesn't know 'Debug-iphoneos' as a configuration.

Hence my workaround is the following, e.g. for **Debug**:
1. Build the install target as before, everything gets installed fine except the build artifacts;
2. Execute, in your cmake binary dir, 'cmake -DBUILD_TYPE=Debug -P cmake_install.cmake', your build artifacts should be install fine;
3. **Unless** if you didn't change their output directory, which, for Xcode uses '$(EFFECTIVE_PLATFORM_NAME)' which can't be set from the command line in the previous call.

Would be easier with a bug fix :)
(0034985)
Ruslan Baratov   
2014-01-22 05:18   
Hi! I've made a hacky patch to fix this issue:

* https://github.com/ruslo/CMake/commit/324cb49e088d204e81f6a3632d4bc35fb53e015b [^]
* https://github.com/ruslo/CMake/releases/tag/bug12506 [^]

Can be used as a workaround (:
(0034991)
Ruslan Baratov   
2014-01-23 09:24   
This patch based on previous one and install universal (iphoneos + iphonesimulator) iOS static library:

* https://github.com/ruslo/CMake/commit/a2a5a592be275a44efb1c8e6215f5048d4e714da [^]
* https://github.com/ruslo/CMake/releases/tag/ios.universal [^]
(0038727)
bagage   
2015-05-07 10:22   
(edited on: 2015-05-07 10:43)
This issue is still open, what can I do to close/solve it?

(0039249)
Gregor Jasny   
2015-08-07 04:26   
I looked into this some months ago. Will try to put my stashs and notes here.
(0039332)
Gregor Jasny   
2015-08-26 15:56   
I just pushed the fix-ios-install topic. For more discussion of this bug please see the "Fixing bug 0012506 (iOS install)" mailing list thread:
http://public.kitware.com/pipermail/cmake-developers/2015-August/025934.html [^]
(0040404)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.