Honor CMAKE_TRY_COMPILE_CONFIGURATION in Makefile generators (#10809)
Previously this was used only in multi-configuration generators to choose the configuration of try_compile and try_run at their build time. Teach CMake to honor the variable in single-configuration generators as the CMAKE_BUILD_TYPE.
This commit is contained in:
parent
28a0403c34
commit
56efc60fa0
|
@ -2717,6 +2717,18 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
|
||||||
cm.SetStartOutputDirectory(bindir);
|
cm.SetStartOutputDirectory(bindir);
|
||||||
cm.SetCMakeCommand(cmakeCommand.c_str());
|
cm.SetCMakeCommand(cmakeCommand.c_str());
|
||||||
cm.LoadCache();
|
cm.LoadCache();
|
||||||
|
if(!gg->IsMultiConfig())
|
||||||
|
{
|
||||||
|
if(const char* config =
|
||||||
|
this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"))
|
||||||
|
{
|
||||||
|
// Tell the single-configuration generator which one to use.
|
||||||
|
// Add this before the user-provided CMake arguments in case
|
||||||
|
// one of the arguments is -DCMAKE_BUILD_TYPE=...
|
||||||
|
cm.AddCacheEntry("CMAKE_BUILD_TYPE", config,
|
||||||
|
"Build configuration", cmCacheManager::STRING);
|
||||||
|
}
|
||||||
|
}
|
||||||
// if cmake args were provided then pass them in
|
// if cmake args were provided then pass them in
|
||||||
if (cmakeArgs)
|
if (cmakeArgs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue