[Cmake-commits] CMake branch, next, updated. v2.8.11.2-2927-g259f57d

Brad King brad.king at kitware.com
Wed Jul 3 16:22:12 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  259f57d2777f806640810460b28a861b532099c7 (commit)
       via  628be3c99e3f611f064679118c6c3bf6aa472ca9 (commit)
      from  d39c060b4da6341ca43e8d24d33186af312b810b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=259f57d2777f806640810460b28a861b532099c7
commit 259f57d2777f806640810460b28a861b532099c7
Merge: d39c060 628be3c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 3 16:22:10 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jul 3 16:22:10 2013 -0400

    Merge topic 'try_compile-escape-flags' into next
    
    628be3c try_compile: Escape CMAKE_<lang>_FLAGS in test projects (#14268)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=628be3c99e3f611f064679118c6c3bf6aa472ca9
commit 628be3c99e3f611f064679118c6c3bf6aa472ca9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 3 15:57:02 2013 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jul 3 16:05:22 2013 -0400

    try_compile: Escape CMAKE_<lang>_FLAGS in test projects (#14268)
    
    If CMAKE_<lang>_FLAGS contains quotes or other CMake language characters
    they must be escaped when written into the generated CMakeLists.txt file
    so that the test project parses them properly.
    
    Teach the TryCompile test to cover this case by adding a flag with
    quotes into CMAKE_C_FLAGS during a C language try_compile.

diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 860417f..e312806 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -12,6 +12,7 @@
 #include "cmCoreTryCompile.h"
 #include "cmake.h"
 #include "cmCacheManager.h"
+#include "cmLocalGenerator.h"
 #include "cmGlobalGenerator.h"
 #include "cmExportTryCompileFileGenerator.h"
 #include <cmsys/Directory.hxx>
@@ -214,8 +215,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
       }
 
     // Detect languages to enable.
-    cmGlobalGenerator* gg =
-      this->Makefile->GetCMakeInstance()->GetGlobalGenerator();
+    cmLocalGenerator* lg = this->Makefile->GetLocalGenerator();
+    cmGlobalGenerator* gg = lg->GetGlobalGenerator();
     std::set<std::string> testLangs;
     for(std::vector<std::string>::iterator si = sources.begin();
         si != sources.end(); ++si)
@@ -295,13 +296,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
     for(std::set<std::string>::iterator li = testLangs.begin();
         li != testLangs.end(); ++li)
       {
-      fprintf(fout, "SET(CMAKE_%s_FLAGS \"", li->c_str());
       std::string langFlags = "CMAKE_" + *li + "_FLAGS";
-      if(const char* flags = this->Makefile->GetDefinition(langFlags.c_str()))
-        {
-        fprintf(fout, " %s ", flags);
-        }
-      fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
+      const char* flags = this->Makefile->GetDefinition(langFlags.c_str());
+      fprintf(fout, "SET(CMAKE_%s_FLAGS %s)\n", li->c_str(),
+              lg->EscapeForCMake(flags?flags:"").c_str());
+      fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
+              " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
       }
     fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n");
     fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n");
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 4540fd0..a181e3c 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -89,6 +89,18 @@ if(SHOULD_FAIL)
    message(SEND_ERROR "Should fail passed ${TRY_OUT}")
 endif()
 
+# try to compile a file that should compile
+set(_c_flags "${CMAKE_C_FLAGS}")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"")
+try_compile(SHOULD_PASS
+    ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+    ${TryCompile_SOURCE_DIR}/testdef.c
+    OUTPUT_VARIABLE TRY_OUT)
+if(NOT SHOULD_PASS)
+  message(SEND_ERROR "should pass failed ${TRY_OUT}")
+endif()
+set(CMAKE_C_FLAGS "${_c_flags}")
+
 if(NOT SHOULD_FAIL)
   if(SHOULD_PASS)
     message("All Tests passed, ignore all previous output.")
diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c
new file mode 100644
index 0000000..5401e71
--- /dev/null
+++ b/Tests/TryCompile/testdef.c
@@ -0,0 +1,4 @@
+#ifndef TESTDEF
+# error "TESTDEF should be defined!"
+#endif
+int main(void) { return 0; }

-----------------------------------------------------------------------

Summary of changes:
 Source/cmCoreTryCompile.cxx     |   16 ++++++++--------
 Tests/TryCompile/CMakeLists.txt |   12 ++++++++++++
 Tests/TryCompile/testdef.c      |    4 ++++
 3 files changed, 24 insertions(+), 8 deletions(-)
 create mode 100644 Tests/TryCompile/testdef.c


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list