I had a problem using a cmake ExternalProject build command when using the Xcode generator and then building from inside Xcode. If one of the shell variables being used contained a special character that required escaping i.e. ~ then the generated Xcode build command produced a shell script that would not run.
I have tried to reproduce the scenario down to a small reproduction project.
The command line used to generate the Xcode project is
cmake -H. -Bbuild-xcode -G Xcode
The CMakeLists.txt file (there is also a dummy “test.cpp” file to allow project generation to proceed).
cmake_minimum_required(VERSION 2.8.12)
project(Test)
add_executable(Test test.cpp)
# This builds from inside Xcode
set(TEST "/Users/jake/test")
# This fails to build from inside Xcode
set(TEST "~/test")
add_custom_command(TARGET Test
POST_BUILD
COMMAND JAKE=${TEST} echo "JAKE" > /dev/null 2>&1
)
The generated script in the Xcode project for the non-working scenario is:
set -e
if test "$CONFIGURATION" = "Debug"; then :
cd /Users/jake/Workspace/personal/cmakeBug/build-xcode
"JAKE=~/test" echo JAKE > /dev/null 2>&1
fi
and for the working scenario:
set -e
if test "$CONFIGURATION" = "Debug"; then :
cd /Users/jake/Workspace/personal/cmakeBug/build-xcode
JAKE=/Users/jake/test echo JAKE > /dev/null 2>&1
fi