[cmake-developers] [CMake 0013841]: XCode post-build shell scripts fail

Mantis Bug Tracker mantis at public.kitware.com
Wed Jan 9 04:28:02 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13841 
====================================================================== 
Reported By:                David Rosen
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13841
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   immediate
Status:                     new
====================================================================== 
Date Submitted:             2013-01-09 04:28 EST
Last Modified:              2013-01-09 04:28 EST
====================================================================== 
Summary:                    XCode post-build shell scripts fail
Description: 
When opening any XCode project that is built out-of-source, an error like this
immediately appears, and the project cannot build:

PhaseScriptExecution "CMake Rules"
/Users/david/Documents/OvergrowthSVN/TempBuild/Overgrowth.build/Debug/ZERO_CHECK.build/Script-57C6D205AA0E4C069EB19117.sh
    cd /Users/david/Documents/OvergrowthSVN/Projects
    /bin/sh -c
/Users/david/Documents/OvergrowthSVN/TempBuild/Overgrowth.build/Debug/ZERO_CHECK.build/Script-57C6D205AA0E4C069EB19117.sh

make: CMakeScripts/ZERO_CHECK_cmakeRulesBuildPhase.makeDebug: No such file or
directory
make: *** No rule to make target
`CMakeScripts/ZERO_CHECK_cmakeRulesBuildPhase.makeDebug'.  Stop.

I believe this error occurs because it is searching for the relative path
"CMakeScripts/ZERO_CHECK_cmakeRulesBuildPhase.makeDebug", and expecting the
working directory to be ${CMAKE_BINARY_DIR}. It is failing because immediately
before running the script, XCode is calling "cd ${CMAKE_SOURCE_DIR}".

This seems to be because XCode calls "cd ${projectDirPath}" before calling any
post-build shell scripts, and when CMake builds an XCode project, it sets the
XCode "projectDirPath" value to ${CMAKE_SOURCE_DIR}. This can be observed by
opening the pbxproj file and searching for "projectDirPath".

Steps to Reproduce: 
Use CMake 2.8.10.2 to generate an XCode project with a different source and
binary directory. Open the project with XCode 4.5.2. You should immediately see
the error quoted in the description.

I have attached my project's CMakeLists.txt and subdirectories which have
exhibited this problem on three computers, in case it does not occur on every
CMake-created out-of-source XCode project.

Additional Information: 
There are three paths that I see to solve this problem. First, the shell scripts
could be given an absolute path, so it doesn't matter what the working directory
is set to. Second, the projectDirPath could be set to ${CMAKE_BINARY_DIR}
instead of ${CMAKE_SOURCE_DIR}. Third, and most preferable I think, the
projectDirPath could just be left as "". That way the XCode project would not
break if it is moved.

I have tested these approaches by manually changing the pbxproj file, and they
all seem to solve the problem.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-01-09 04:28 David Rosen    New Issue                                    
2013-01-09 04:28 David Rosen    File Added: xcode_break_example.zip             
      
======================================================================




More information about the cmake-developers mailing list