From e65ef08bf2719ffd1cc4226f9594ff7127ad8b5e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 24 May 2013 16:27:31 -0400 Subject: [PATCH 1/2] try_compile: Fix quoting of libraries in generated CMakeLists.txt Since commit 236133e7 (Handle targets in the LINK_LIBRARIES of try_compile, 2013-02-09) libraries passed to the new LINK_LIBRARIES option of try_compile are not quoted inside the generated CMakeLists.txt file. Quote the library names so they re-parse correctly when loaded by CMake to configure and generate the test project. Reported-by: Bogdan Cristea --- Source/cmCoreTryCompile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 9f38b2529..ebfcae0cb 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -111,7 +111,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) ++i) { extraArgs++; - libsToLink += argv[i] + " "; + libsToLink += "\"" + argv[i] + "\" "; cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str()); if (!tgt) { From e5375442ff20fde45e70de318c5aa2f1e4bb190a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 30 May 2013 13:42:47 +0200 Subject: [PATCH 2/2] try_compile: Trim whitespace from LINK_LIBRARIES entries Commit e65ef08b (try_compile: Fix quoting of libraries in generated CMakeLists.txt, 2013-05-24) added quoting to entries specified in the LINK_LIBRARIES. However, if the input entries contain whitespace padding, that quoted whitespace causes an error in the generated CMakeLists.txt at target_link_libraries. Strictly, it is an error to have space separated entries in the CMAKE_REQUIRED_LIBRARIES, as it was never properly handled by CMakeExpandImportedTargets even prior to commit 236133e7 (Handle targets in the LINK_LIBRARIES of try_compile., 2013-02-09). However, it is causing a regression in KDE code which tests the next branch. --- Source/cmCoreTryCompile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ebfcae0cb..85e49a928 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -111,7 +111,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) ++i) { extraArgs++; - libsToLink += "\"" + argv[i] + "\" "; + libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str()); if (!tgt) {