From 295b5b60df5d9427fdb891fd51333c12089ee129 Mon Sep 17 00:00:00 2001 From: David Genest Date: Tue, 29 Jun 2010 08:28:47 -0400 Subject: [PATCH 1/2] Honor CMAKE_USER_MAKE_RULES_OVERRIDE in try_compile (#10902) --- Source/cmCoreTryCompile.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index dab0c0d1d..fcec3e902 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -175,6 +175,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { fprintf(fout, "SET(CMAKE_MODULE_PATH %s)\n", def); } + + const char* rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; + std::string rulesOverrideLang = + rulesOverrideBase + (lang ? std::string("_") + lang : ""); + if(const char* rulesOverridePath = + this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideLang.c_str(), rulesOverridePath); + } + else if(const char* rulesOverridePath2 = + this->Makefile->GetDefinition(rulesOverrideBase)) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideBase, rulesOverridePath2); + } + if(lang) { fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang); From c8ea2705a7115208f59839828a82b42a58293576 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Jun 2010 10:01:59 -0400 Subject: [PATCH 2/2] Use same type in both cases of '?:' operator Both possible result values need to be convertible to the same type. Some compilers fail to recognize that they can construct std::string from the empty string literal, so state it explicitly. --- Source/cmCoreTryCompile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index fcec3e902..b8a0c95b1 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -178,7 +178,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) const char* rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; std::string rulesOverrideLang = - rulesOverrideBase + (lang ? std::string("_") + lang : ""); + rulesOverrideBase + (lang ? std::string("_") + lang : std::string("")); if(const char* rulesOverridePath = this->Makefile->GetDefinition(rulesOverrideLang.c_str())) {