Implement generator toolset selection (cmake -T) for Xcode > 2.0 by adding the GCC_VERSION build setting to project files.
This commit is contained in:
parent
650c647160
commit
f980a80495
|
@ -177,6 +177,11 @@ Id flags: ${testflags}
|
|||
set(id_type ${CMAKE_${lang}_COMPILER_XCODE_TYPE})
|
||||
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
|
||||
get_filename_component(id_src "${src}" NAME)
|
||||
if(CMAKE_XCODE_PLATFORM_TOOLSET)
|
||||
set(id_toolset "GCC_VERSION = ${CMAKE_XCODE_PLATFORM_TOOLSET};")
|
||||
else()
|
||||
set(id_toolset "")
|
||||
endif()
|
||||
if(NOT ${XCODE_VERSION} VERSION_LESS 3)
|
||||
set(v 3)
|
||||
set(ext xcodeproj)
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
ONLY_ACTIVE_ARCH = YES;
|
||||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
|
||||
SYMROOT = .;
|
||||
@id_toolset@
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
|
@ -302,6 +302,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
|
|||
"CMake provides the name of the chosen toolset in this variable."
|
||||
,false,
|
||||
"Variables that Provide Information");
|
||||
cm->DefineProperty
|
||||
("CMAKE_XCODE_PLATFORM_TOOLSET", cmProperty::VARIABLE,
|
||||
"Xcode compiler selection.",
|
||||
"Xcode supports selection of a compiler from one of the installed "
|
||||
"toolsets. "
|
||||
"CMake provides the name of the chosen toolset in this variable, "
|
||||
"if any is explicitly selected (e.g. via the cmake -T option)."
|
||||
,false,
|
||||
"Variables that Provide Information");
|
||||
cm->DefineProperty
|
||||
("CMAKE_MINOR_VERSION", cmProperty::VARIABLE,
|
||||
"The Minor version of cmake (i.e. the 4 in X.4.X).",
|
||||
|
|
|
@ -200,6 +200,20 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
|
|||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts)
|
||||
{
|
||||
if(this->XcodeVersion >= 30)
|
||||
{
|
||||
this->PlatformToolset = ts;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cmGlobalGenerator::SetGeneratorToolset(ts);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
|
||||
lang,
|
||||
|
@ -226,6 +240,11 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
|
|||
mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc");
|
||||
mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++");
|
||||
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
|
||||
if(!this->PlatformToolset.empty())
|
||||
{
|
||||
mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
|
||||
this->PlatformToolset.c_str());
|
||||
}
|
||||
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
|
||||
const char* osxArch =
|
||||
mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
||||
|
@ -3163,6 +3182,11 @@ void cmGlobalXCodeGenerator
|
|||
buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
|
||||
this->CreateString(deploymentTarget));
|
||||
}
|
||||
if(!this->PlatformToolset.empty())
|
||||
{
|
||||
buildSettings->AddAttribute("GCC_VERSION",
|
||||
this->CreateString(this->PlatformToolset.c_str()));
|
||||
}
|
||||
|
||||
// Put this last so it can override existing settings
|
||||
// Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
i.e. "Can I build Debug and Release in the same tree?" */
|
||||
virtual bool IsMultiConfig();
|
||||
|
||||
virtual bool SetGeneratorToolset(std::string const& ts);
|
||||
private:
|
||||
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
|
||||
cmSourceGroup* sg);
|
||||
|
@ -236,6 +237,7 @@ private:
|
|||
std::map<cmStdString, cmXCodeObject* > TargetGroup;
|
||||
std::map<cmStdString, cmXCodeObject* > FileRefs;
|
||||
std::vector<std::string> Architectures;
|
||||
std::string PlatformToolset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -542,6 +542,7 @@ private:
|
|||
"native build system to choose a compiler. " \
|
||||
"This is supported only on specific generators:\n" \
|
||||
" Visual Studio >= 10\n" \
|
||||
" Xcode >= 3.0\n" \
|
||||
"See native build system documentation for allowed toolset names."}, \
|
||||
{"-Wno-dev", "Suppress developer warnings.",\
|
||||
"Suppress warnings that are meant for the author"\
|
||||
|
|
|
@ -41,10 +41,15 @@ macro(add_RunCMake_test test)
|
|||
-DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR}
|
||||
-DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test}
|
||||
-DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
|
||||
${${test}_ARGS}
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3)
|
||||
set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1)
|
||||
endif()
|
||||
|
||||
add_RunCMake_test(CMP0019)
|
||||
add_RunCMake_test(GeneratorExpression)
|
||||
add_RunCMake_test(GeneratorToolset)
|
||||
|
|
|
@ -2,7 +2,7 @@ include(RunCMake)
|
|||
|
||||
run_cmake(NoToolset)
|
||||
|
||||
if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01]")
|
||||
if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01]|Xcode" AND NOT XCODE_BELOW_3)
|
||||
set(RunCMake_TEST_OPTIONS -T "Test Toolset")
|
||||
run_cmake(TestToolset)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
|
Loading…
Reference in New Issue