[Cmake-commits] CMake branch, next, updated. v3.4.0-rc1-733-g03c0c9c

Gregor Jasny gjasny at googlemail.com
Tue Oct 20 16:50:14 EDT 2015


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  03c0c9cc4098108010dc115bbdde4158fe423a40 (commit)
       via  18f848549bcbe4de8bfee66762304c2d241965fb (commit)
       via  b004a2d4798afd1747e8f52f52a7184890eb606c (commit)
       via  23520f1dca774bdb9aac3b0e264447d822d716de (commit)
       via  0b75f567d2ceb3de072ce50cfc9609a1760c35ac (commit)
       via  eefcb1e9bbcc3c5c6bfa140531d3ab5bb03f8961 (commit)
      from  b440006bcad4df6916b90b7505352cc866bf8b96 (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=03c0c9cc4098108010dc115bbdde4158fe423a40
commit 03c0c9cc4098108010dc115bbdde4158fe423a40
Merge: b440006 18f8485
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Tue Oct 20 16:50:12 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Oct 20 16:50:12 2015 -0400

    Merge topic 'xcode-optimization-flags' into next
    
    18f84854 Xcode: Add test case for bug report (#15794)
    b004a2d4 fixup! Add test case for Xcode optimisation level settings (#15794)
    23520f1d Use regex itself to check for white spaces around flag
    0b75f567 Xcode: Use regular expression to extract all optimisation flags (#15794)
    eefcb1e9 Add test case for Xcode optimisation level settings (#15794)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18f848549bcbe4de8bfee66762304c2d241965fb
commit 18f848549bcbe4de8bfee66762304c2d241965fb
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Tue Oct 20 22:01:29 2015 +0200
Commit:     Gregor Jasny <gjasny at googlemail.com>
CommitDate: Tue Oct 20 22:01:29 2015 +0200

    Xcode: Add test case for bug report (#15794)

diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index b716f0d..a8c6816 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -5,6 +5,7 @@ run_cmake(XcodeAttributeGenex)
 run_cmake(XcodeAttributeGenexError)
 run_cmake(XcodeObjectNeedsQuote)
 run_cmake(XcodeOptimizationFlags)
+run_cmake(XcodePreserveObjcFlag)
 if (NOT XCODE_VERSION VERSION_LESS 6)
   run_cmake(XcodePlatformFrameworks)
 endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake
new file mode 100644
index 0000000..332906f
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag-check.cmake
@@ -0,0 +1,7 @@
+set(expect "-ObjC")
+file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodePreserveObjcFlag.xcodeproj/project.pbxproj actual
+     REGEX "OTHER_CPLUSPLUSFLAGS = [^;]*;" LIMIT_COUNT 1)
+if(NOT "${actual}" MATCHES "${expect}")
+  message(SEND_ERROR "The actual project contains the line:\n ${actual}\n"
+    "which does not match expected regex:\n ${expect}\n")
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake
new file mode 100644
index 0000000..64db633
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types")
+
+project(XcodePreserveObjcFlag CXX)
+
+add_library(foo STATIC foo.cpp)
+set_target_properties(foo PROPERTIES COMPILE_OPTIONS -ObjC)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b004a2d4798afd1747e8f52f52a7184890eb606c
commit b004a2d4798afd1747e8f52f52a7184890eb606c
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Tue Oct 20 21:59:42 2015 +0200
Commit:     Gregor Jasny <gjasny at googlemail.com>
CommitDate: Tue Oct 20 21:59:42 2015 +0200

    fixup! Add test case for Xcode optimisation level settings (#15794)

diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
index 53da440..e14bf80 100644
--- a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
@@ -4,8 +4,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "")
 
 project(XcodeOptimizationFlags CXX)
 
-message(STATUS "NONE ${CMAKE_CXX_FLAGS} CXX ${CMAKE_CXX_FLAGS_RELEASE}")
-
 add_library(fooO1 STATIC foo.cpp)
 set_target_properties(fooO1 PROPERTIES COMPILE_OPTIONS -O1)
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23520f1dca774bdb9aac3b0e264447d822d716de
commit 23520f1dca774bdb9aac3b0e264447d822d716de
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Tue Oct 20 21:39:45 2015 +0200
Commit:     Gregor Jasny <gjasny at googlemail.com>
CommitDate: Tue Oct 20 21:39:45 2015 +0200

    Use regex itself to check for white spaces around flag

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 2a838e6..0e3af88 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1615,6 +1615,7 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
 // This function removes each matching occurrence of the expression and
 // returns the last one (i.e., the dominant flag in GCC)
 std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
+                                                     int matchIndex,
                                                      std::string& flags)
 {
   std::string retFlag;
@@ -1630,24 +1631,12 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
 
   while(regex.find(flags.c_str() + offset))
     {
-    const std::string::size_type startPos = offset + regex.start(0);
-    const std::string::size_type endPos = offset + regex.end(0);
+    const std::string::size_type startPos = offset + regex.start(matchIndex);
+    const std::string::size_type endPos = offset + regex.end(matchIndex);
     const std::string::size_type size = endPos - startPos;
 
     offset = startPos + 1;
 
-    // match must be start of string or preceded by white space
-    if(startPos > 0 && flags[startPos - 1] != ' ')
-      {
-      continue;
-      }
-
-    // match must be succeeded by white space or end of string
-    if(endPos < flags.size() && flags[endPos] != ' ')
-      {
-      continue;
-      }
-
     retFlag.assign(flags, startPos, size);
     flags.replace(startPos, size, size, ' ');
     }
@@ -2279,7 +2268,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
     {
     std::string& flags = cflags[*li];
     std::string& gflag = gflags[*li];
-    std::string oflag = this->ExtractFlagRegex("-Ofast|-Os|-O[0-9]*", flags);
+    std::string oflag =
+      this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags);
     if(oflag.size() == 2)
       {
       optLevel = "1";
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 9de7de6..791324d 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -151,7 +151,8 @@ private:
                            cmXCodeObject* buildSettings,
                            const std::string& buildType);
   std::string ExtractFlag(const char* flag, std::string& flags);
-  std::string ExtractFlagRegex(const char* exp, std::string& flags);
+  std::string ExtractFlagRegex(const char* exp, int matchIndex,
+                               std::string& flags);
   void SortXCodeObjects();
   // delete all objects in the this->XCodeObjects vector.
   void ClearXCodeObjects();

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b75f567d2ceb3de072ce50cfc9609a1760c35ac
commit 0b75f567d2ceb3de072ce50cfc9609a1760c35ac
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Sun Oct 18 22:43:25 2015 +0200
Commit:     Gregor Jasny <gjasny at googlemail.com>
CommitDate: Sun Oct 18 22:43:25 2015 +0200

    Xcode: Use regular expression to extract all optimisation flags (#15794)

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index bc05aea..2a838e6 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1612,6 +1612,50 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
 }
 
 //----------------------------------------------------------------------------
+// This function removes each matching occurrence of the expression and
+// returns the last one (i.e., the dominant flag in GCC)
+std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
+                                                     std::string& flags)
+{
+  std::string retFlag;
+
+  cmsys::RegularExpression regex(exp);
+  assert(regex.is_valid());
+  if(!regex.is_valid())
+    {
+    return retFlag;
+    }
+
+  std::string::size_type offset = 0;
+
+  while(regex.find(flags.c_str() + offset))
+    {
+    const std::string::size_type startPos = offset + regex.start(0);
+    const std::string::size_type endPos = offset + regex.end(0);
+    const std::string::size_type size = endPos - startPos;
+
+    offset = startPos + 1;
+
+    // match must be start of string or preceded by white space
+    if(startPos > 0 && flags[startPos - 1] != ' ')
+      {
+      continue;
+      }
+
+    // match must be succeeded by white space or end of string
+    if(endPos < flags.size() && flags[endPos] != ' ')
+      {
+      continue;
+      }
+
+    retFlag.assign(flags, startPos, size);
+    flags.replace(startPos, size, size, ' ');
+    }
+
+  return retFlag;
+}
+
+//----------------------------------------------------------------------------
 void
 cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
                                                 cmTarget& target,
@@ -2227,9 +2271,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
   bool same_gflags = true;
   std::map<std::string, std::string> gflags;
   std::string const* last_gflag = 0;
-  char optLevel[2];
-  optLevel[0] = '0';
-  optLevel[1] = 0;
+  std::string optLevel = "0";
 
   // Minimal map of flags to build settings.
   for (std::set<std::string>::iterator li = languages.begin();
@@ -2237,14 +2279,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
     {
     std::string& flags = cflags[*li];
     std::string& gflag = gflags[*li];
-    std::string oflag = this->ExtractFlag("-O", flags);
-    if(oflag.size() == 3)
+    std::string oflag = this->ExtractFlagRegex("-Ofast|-Os|-O[0-9]*", flags);
+    if(oflag.size() == 2)
       {
-      optLevel[0] = oflag[2];
+      optLevel = "1";
       }
-    if(oflag.size() == 2)
+    else if(oflag.size() > 2)
       {
-      optLevel[0] = '1';
+      optLevel = oflag.substr(2);
       }
     gflag = this->ExtractFlag("-g", flags);
     // put back gdwarf-2 if used since there is no way
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 9daf0ab..9de7de6 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -151,6 +151,7 @@ private:
                            cmXCodeObject* buildSettings,
                            const std::string& buildType);
   std::string ExtractFlag(const char* flag, std::string& flags);
+  std::string ExtractFlagRegex(const char* exp, std::string& flags);
   void SortXCodeObjects();
   // delete all objects in the this->XCodeObjects vector.
   void ClearXCodeObjects();

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eefcb1e9bbcc3c5c6bfa140531d3ab5bb03f8961
commit eefcb1e9bbcc3c5c6bfa140531d3ab5bb03f8961
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Sun Oct 18 21:53:12 2015 +0200
Commit:     Gregor Jasny <gjasny at googlemail.com>
CommitDate: Sun Oct 18 21:53:12 2015 +0200

    Add test case for Xcode optimisation level settings (#15794)

diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 8ab618b..b716f0d 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -4,6 +4,7 @@ run_cmake(XcodeFileType)
 run_cmake(XcodeAttributeGenex)
 run_cmake(XcodeAttributeGenexError)
 run_cmake(XcodeObjectNeedsQuote)
+run_cmake(XcodeOptimizationFlags)
 if (NOT XCODE_VERSION VERSION_LESS 6)
   run_cmake(XcodePlatformFrameworks)
 endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake
new file mode 100644
index 0000000..f5595b3
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake
@@ -0,0 +1,7 @@
+foreach(level 1 2 3 s fast)
+  file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeOptimizationFlags.xcodeproj/project.pbxproj actual-${level}
+       REGEX "GCC_OPTIMIZATION_LEVEL = ${level};" LIMIT_COUNT 1)
+  if(NOT actual-${level})
+    message(SEND_ERROR "Optimization level '${level}' not found in Xcode project.")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
new file mode 100644
index 0000000..53da440
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
@@ -0,0 +1,22 @@
+set(CMAKE_CONFIGURATION_TYPES "Release" CACHE INTERNAL "Supported configuration types")
+
+set(CMAKE_CXX_FLAGS_RELEASE "")
+
+project(XcodeOptimizationFlags CXX)
+
+message(STATUS "NONE ${CMAKE_CXX_FLAGS} CXX ${CMAKE_CXX_FLAGS_RELEASE}")
+
+add_library(fooO1 STATIC foo.cpp)
+set_target_properties(fooO1 PROPERTIES COMPILE_OPTIONS -O1)
+
+add_library(fooO2 STATIC foo.cpp)
+set_target_properties(fooO2 PROPERTIES COMPILE_OPTIONS -O2)
+
+add_library(fooO3 STATIC foo.cpp)
+set_target_properties(fooO3 PROPERTIES COMPILE_OPTIONS -O3)
+
+add_library(fooOs STATIC foo.cpp)
+set_target_properties(fooOs PROPERTIES COMPILE_OPTIONS -Os)
+
+add_library(fooOfast STATIC foo.cpp)
+set_target_properties(fooOfast PROPERTIES COMPILE_OPTIONS -Ofast)

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

Summary of changes:
 Source/cmGlobalXCodeGenerator.cxx                  |   48 ++++++++++++++++----
 Source/cmGlobalXCodeGenerator.h                    |    2 +
 Tests/RunCMake/XcodeProject/RunCMakeTest.cmake     |    2 +
 .../XcodeOptimizationFlags-check.cmake             |    7 +++
 .../XcodeProject/XcodeOptimizationFlags.cmake      |   20 ++++++++
 ...eck.cmake => XcodePreserveObjcFlag-check.cmake} |    6 +--
 .../XcodeProject/XcodePreserveObjcFlag.cmake       |    6 +++
 7 files changed, 80 insertions(+), 11 deletions(-)
 create mode 100644 Tests/RunCMake/XcodeProject/XcodeOptimizationFlags-check.cmake
 create mode 100644 Tests/RunCMake/XcodeProject/XcodeOptimizationFlags.cmake
 copy Tests/RunCMake/XcodeProject/{XcodeObjectNeedsQuote-check.cmake => XcodePreserveObjcFlag-check.cmake} (56%)
 create mode 100644 Tests/RunCMake/XcodeProject/XcodePreserveObjcFlag.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list