Xcode: Switch to internal CMAKE_MAKE_PROGRAM lookup by generator (#15324)
The "cmakexbuild" wrapper is not needed for Xcode 4 and above, and the path to it may change when CMake moves. Avoid storing a specific path to a build program in CMakeCache.txt and instead compute the value for CMAKE_MAKE_PROGRAM on demand. However, if a user does set the value explicitly then honor it. This does for Xcode what commit v3.0.0-rc1~260^2~4 (VS: Switch to internal CMAKE_MAKE_PROGRAM lookup by generators, 2013-11-15) did for Visual Studio generators.
This commit is contained in:
parent
11e2e6cadf
commit
ab9fa54d48
|
@ -0,0 +1,6 @@
|
||||||
|
xcode-revise-make-program
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
* The :generator:`Xcode` generator no longer requires a value for
|
||||||
|
the :variable:`CMAKE_MAKE_PROGRAM` variable to be located up front.
|
||||||
|
It now locates ``xcodebuild`` when needed at build time.
|
|
@ -23,8 +23,15 @@ to configure the project:
|
||||||
otherwise undocumented ``cmakexbuild`` wrapper implementing some
|
otherwise undocumented ``cmakexbuild`` wrapper implementing some
|
||||||
workarounds).
|
workarounds).
|
||||||
|
|
||||||
This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache
|
This generator prefers to lookup the build tool at build time
|
||||||
so that it may be edited by the user.
|
rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
|
||||||
|
ahead of time. This is because ``xcodebuild`` is easy to find,
|
||||||
|
the ``cmakexbuild`` wrapper is needed only for older Xcode versions,
|
||||||
|
and the path to ``cmakexbuild`` may be outdated if CMake itself moves.
|
||||||
|
|
||||||
|
For compatibility with versions of CMake prior to 3.2, if
|
||||||
|
a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
|
||||||
|
the CMake cache then CMake will use the specified value.
|
||||||
|
|
||||||
* The Visual Studio generators set this to the full path to
|
* The Visual Studio generators set this to the full path to
|
||||||
``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9),
|
``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9),
|
||||||
|
|
|
@ -12,9 +12,5 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
find_program(CMAKE_MAKE_PROGRAM
|
# Empty placeholder for input dependencies in existing
|
||||||
NAMES xcodebuild
|
# build trees produced by older versions of CMake.
|
||||||
PATHS
|
|
||||||
/usr/bin
|
|
||||||
)
|
|
||||||
mark_as_advanced(CMAKE_MAKE_PROGRAM)
|
|
||||||
|
|
|
@ -315,25 +315,6 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
|
||||||
"make program",
|
"make program",
|
||||||
cmCacheManager::FILEPATH);
|
cmCacheManager::FILEPATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(makeProgram.find("xcodebuild") != makeProgram.npos)
|
|
||||||
{
|
|
||||||
// due to the text file busy /bin/sh problem with xcodebuild
|
|
||||||
// use the cmakexbuild wrapper instead. This program
|
|
||||||
// will run xcodebuild and if it sees the error text file busy
|
|
||||||
// it will stop forwarding output, and let the build finish.
|
|
||||||
// Then it will retry the build. It will continue this
|
|
||||||
// until no text file busy errors occur.
|
|
||||||
std::string cmakexbuild =
|
|
||||||
this->CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_COMMAND");
|
|
||||||
cmakexbuild = cmakexbuild.substr(0, cmakexbuild.length()-5);
|
|
||||||
cmakexbuild += "cmakexbuild";
|
|
||||||
|
|
||||||
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM",
|
|
||||||
cmakexbuild.c_str(),
|
|
||||||
"make program",
|
|
||||||
cmCacheManager::FILEPATH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable the given language
|
// enable the given language
|
||||||
|
|
|
@ -136,7 +136,6 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
|
||||||
sscanf(this->VersionString.c_str(), "%u.%u", &v[0], &v[1]);
|
sscanf(this->VersionString.c_str(), "%u.%u", &v[0], &v[1]);
|
||||||
this->XcodeVersion = 10*v[0] + v[1];
|
this->XcodeVersion = 10*v[0] + v[1];
|
||||||
|
|
||||||
this->FindMakeProgramFile = "CMakeFindXCode.cmake";
|
|
||||||
this->RootObject = 0;
|
this->RootObject = 0;
|
||||||
this->MainGroupChildren = 0;
|
this->MainGroupChildren = 0;
|
||||||
this->SourcesGroupChildren = 0;
|
this->SourcesGroupChildren = 0;
|
||||||
|
@ -202,6 +201,19 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
|
||||||
|
{
|
||||||
|
// The Xcode generator knows how to lookup its build tool
|
||||||
|
// directly instead of needing a helper module to do it, so we
|
||||||
|
// do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
|
||||||
|
if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
|
||||||
|
{
|
||||||
|
mf->AddDefinition("CMAKE_MAKE_PROGRAM",
|
||||||
|
this->GetXcodeBuildCommand().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
|
std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,8 @@ public:
|
||||||
const std::string& suffix,
|
const std::string& suffix,
|
||||||
std::string& dir);
|
std::string& dir);
|
||||||
|
|
||||||
|
virtual void FindMakeProgram(cmMakefile*);
|
||||||
|
|
||||||
///! What is the configurations directory variable called?
|
///! What is the configurations directory variable called?
|
||||||
virtual const char* GetCMakeCFGIntDir() const;
|
virtual const char* GetCMakeCFGIntDir() const;
|
||||||
///! expand CFGIntDir
|
///! expand CFGIntDir
|
||||||
|
|
|
@ -51,7 +51,7 @@ if(BUILD_TESTING)
|
||||||
set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
|
set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
|
||||||
set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
|
set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
|
||||||
else()
|
else()
|
||||||
set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
|
set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
|
||||||
|
|
Loading…
Reference in New Issue