[Cmake-commits] CMake branch, next, updated. v3.0.0-rc5-3169-g8b10a15

Brad King brad.king at kitware.com
Thu May 15 15:46:38 EDT 2014


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  8b10a15f2760a6afc8f64200147cae8c9963dea1 (commit)
       via  a339ea652952666182d2e63ddce088d023e2a5f5 (commit)
       via  ae80cb9f28c8c278a6897f331f65a1be77058897 (commit)
      from  cad5ad5449d2f9ff87997c75a760592e9e48c6b0 (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=8b10a15f2760a6afc8f64200147cae8c9963dea1
commit 8b10a15f2760a6afc8f64200147cae8c9963dea1
Merge: cad5ad5 a339ea6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 15:46:37 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 15 15:46:37 2014 -0400

    Merge topic 'xcode-file-type' into next
    
    a339ea65 Xcode: Add source file property to control file type (#14854)
    ae80cb9f Xcode: Refactor internal source file type selection


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a339ea652952666182d2e63ddce088d023e2a5f5
commit a339ea652952666182d2e63ddce088d023e2a5f5
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 13:50:53 2014 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 14:34:52 2014 -0400

    Xcode: Add source file property to control file type (#14854)
    
    Add source file properties to control Xcode file type attributes:
    
      XCODE_EXPLICIT_FILE_TYPE   => explicitFileType
      XCODE_LAST_KNOWN_FILE_TYPE => lastKnownFileType
    
    Add a RunCMake.XcodeProject test to verify generated project content.

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 14d2e7f..3036a5f 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -289,6 +289,8 @@ Properties on Source Files
    /prop_sf/OBJECT_OUTPUTS
    /prop_sf/SYMBOLIC
    /prop_sf/WRAP_EXCLUDE
+   /prop_sf/XCODE_EXPLICIT_FILE_TYPE
+   /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE
 
 Properties on Cache Entries
 ===========================
diff --git a/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
new file mode 100644
index 0000000..1b24701
--- /dev/null
+++ b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
@@ -0,0 +1,8 @@
+XCODE_EXPLICIT_FILE_TYPE
+------------------------
+
+Set the Xcode ``explicitFileType`` attribute on its reference to a
+source file.  CMake computes a default based on file extension but
+can be told explicitly with this property.
+
+See also :prop_sf:`XCODE_LAST_KNOWN_FILE_TYPE`.
diff --git a/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
new file mode 100644
index 0000000..42e3757
--- /dev/null
+++ b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
@@ -0,0 +1,9 @@
+XCODE_LAST_KNOWN_FILE_TYPE
+--------------------------
+
+Set the Xcode ``lastKnownFileType`` attribute on its reference to a
+source file.  CMake computes a default based on file extension but
+can be told explicitly with this property.
+
+See also :prop_sf:`XCODE_EXPLICIT_FILE_TYPE`, which is preferred
+over this property if set.
diff --git a/Help/release/dev/xcode-file-type.rst b/Help/release/dev/xcode-file-type.rst
new file mode 100644
index 0000000..6f637f7
--- /dev/null
+++ b/Help/release/dev/xcode-file-type.rst
@@ -0,0 +1,7 @@
+xcode-file-type
+---------------
+
+* The :generator:`Xcode` generator learned to check source
+  file properties  :prop_sf:`XCODE_EXPLICIT_FILE_TYPE` and
+  :prop_sf:`XCODE_LAST_KNOWN_FILE_TYPE` for a custom Xcode
+  file reference type.
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index ac75fc2..e5fc436 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -647,13 +647,14 @@ cmXCodeObject*
 cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
   const std::string &fullpath,
   cmTarget& cmtarget,
-  const std::string &lang)
+  const std::string &lang,
+  cmSourceFile* sf)
 {
   // Using a map and the full path guarantees that we will always get the same
   // fileRef object for any given full path.
   //
   cmXCodeObject* fileRef =
-    this->CreateXCodeFileReferenceFromPath(fullpath, cmtarget, lang);
+    this->CreateXCodeFileReferenceFromPath(fullpath, cmtarget, lang, sf);
 
   cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
   buildFile->SetComment(fileRef->GetComment());
@@ -696,7 +697,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
     this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
 
   cmXCodeObject* buildFile =
-    this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang);
+    this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang, sf);
   cmXCodeObject* fileRef = buildFile->GetObject("fileRef")->GetObject();
 
   cmXCodeObject* settings =
@@ -828,7 +829,8 @@ cmXCodeObject*
 cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
   const std::string &fullpath,
   cmTarget& cmtarget,
-  const std::string &lang)
+  const std::string &lang,
+  cmSourceFile* sf)
 {
   std::string fname = fullpath;
   cmXCodeObject* fileRef = this->FileRefs[fname];
@@ -850,6 +852,19 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
 
   bool useLastKnownFileType = false;
   std::string fileType;
+  if(sf)
+    {
+    if(const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE"))
+      {
+      fileType = e;
+      }
+    else if(const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE"))
+      {
+      useLastKnownFileType = true;
+      fileType = l;
+      }
+    }
+  if(fileType.empty())
     {
     // If fullpath references a directory, then we need to specify
     // lastKnownFileType as folder in order for Xcode to be able to
@@ -902,7 +917,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
     this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
 
   return this->CreateXCodeFileReferenceFromPath(
-    sf->GetFullPath(), cmtarget, lang);
+    sf->GetFullPath(), cmtarget, lang, sf);
 }
 
 //----------------------------------------------------------------------------
@@ -1052,7 +1067,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
         {
         std::string obj = *oi;
         cmXCodeObject* xsf =
-          this->CreateXCodeSourceFileFromPath(obj, cmtarget, "");
+          this->CreateXCodeSourceFileFromPath(obj, cmtarget, "", 0);
         externalObjFiles.push_back(xsf);
         }
       }
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 23616b4..c9937ed 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -163,10 +163,12 @@ private:
                          std::vector<cmLocalGenerator*>& generators);
   cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string &fullpath,
                                                   cmTarget& cmtarget,
-                                                  const std::string &lang);
+                                                  const std::string &lang,
+                                                  cmSourceFile* sf);
   cmXCodeObject* CreateXCodeSourceFileFromPath(const std::string &fullpath,
                                                cmTarget& cmtarget,
-                                               const std::string &lang);
+                                               const std::string &lang,
+                                               cmSourceFile* sf);
   cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
                                           cmTarget& cmtarget);
   cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 7f6ebf1..3eeda2f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -123,6 +123,10 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]")
   add_RunCMake_test(SolutionGlobalSections)
 endif()
 
+if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
+  add_RunCMake_test(XcodeProject)
+endif()
+
 add_RunCMake_test(File_Generate)
 add_RunCMake_test(ExportWithoutLanguage)
 add_RunCMake_test(target_link_libraries)
diff --git a/Tests/RunCMake/XcodeProject/CMakeLists.txt b/Tests/RunCMake/XcodeProject/CMakeLists.txt
new file mode 100644
index 0000000..12cd3c7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
new file mode 100644
index 0000000..8e4026b
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(XcodeFileType)
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
new file mode 100644
index 0000000..7882d7f
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
@@ -0,0 +1,10 @@
+set(expect-default "explicitFileType = sourcecode")
+set(expect-explicit "explicitFileType = \"sourcecode.c.h\"")
+set(expect-lastKnown "lastKnownFileType = \"sourcecode.c.h\"")
+foreach(src default explicit lastKnown)
+  file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeFileType.xcodeproj/project.pbxproj actual-${src}
+       REGEX "PBXFileReference.*src-${src}")
+  if(NOT actual-${src} MATCHES "${expect-${src}}")
+    message(SEND_ERROR "src-${src} does not match '${expect-${src}}':\n ${actual-${src}}")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType.cmake
new file mode 100644
index 0000000..7faa781
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_executable(main main.c src-default src-explicit src-lastKnown)
+set_property(SOURCE src-explicit PROPERTY XCODE_EXPLICIT_FILE_TYPE sourcecode.c.h)
+set_property(SOURCE src-lastKnown PROPERTY XCODE_LAST_KNOWN_FILE_TYPE sourcecode.c.h)
diff --git a/Tests/RunCMake/XcodeProject/main.c b/Tests/RunCMake/XcodeProject/main.c
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/XcodeProject/src-default b/Tests/RunCMake/XcodeProject/src-default
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/XcodeProject/src-explicit b/Tests/RunCMake/XcodeProject/src-explicit
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/XcodeProject/src-lastKnown b/Tests/RunCMake/XcodeProject/src-lastKnown
new file mode 100644
index 0000000..e69de29

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ae80cb9f28c8c278a6897f331f65a1be77058897
commit ae80cb9f28c8c278a6897f331f65a1be77058897
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu May 15 13:50:26 2014 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 15 14:01:16 2014 -0400

    Xcode: Refactor internal source file type selection
    
    Choose the attribute name and file type and send them through a single
    attribute generation code path.  Compute the file extension only when
    needed.  Leave the file type selection logic indented in a block so it
    can be made conditional later.

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d44da37..ac75fc2 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -848,36 +848,36 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
     }
   fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
 
-  // Compute the extension.
-  std::string ext;
-  std::string realExt =
-    cmSystemTools::GetFilenameLastExtension(fullpath);
-  if(!realExt.empty())
+  bool useLastKnownFileType = false;
+  std::string fileType;
     {
-    // Extension without the leading '.'.
-    ext = realExt.substr(1);
-    }
+    // If fullpath references a directory, then we need to specify
+    // lastKnownFileType as folder in order for Xcode to be able to
+    // open the contents of the folder.
+    // (Xcode 4.6 does not like explicitFileType=folder).
+    if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
+      {
+      fileType = "folder";
+      useLastKnownFileType = true;
+      }
+    else
+      {
+      // Compute the extension without leading '.'.
+      std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath);
+      if(!ext.empty())
+        {
+        ext = ext.substr(1);
+        }
 
-  // If fullpath references a directory, then we need to specify
-  // lastKnownFileType as folder in order for Xcode to be able to open the
-  // contents of the folder (Xcode 4.6 does not like explicitFileType=folder).
-  if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
-    {
-    fileRef->AddAttribute("lastKnownFileType",
-                          this->CreateString("folder"));
-    }
-  else
-    {
-    bool keepLastKnownFileType = false;
-    std::string sourcecode = GetSourcecodeValueFromFileExtension(ext,
-                             lang, keepLastKnownFileType);
-    const char* attribute = keepLastKnownFileType ?
-                             "lastKnownFileType" :
-                             "explicitFileType";
-    fileRef->AddAttribute(attribute,
-                          this->CreateString(sourcecode.c_str()));
+      fileType = GetSourcecodeValueFromFileExtension(
+        ext, lang, useLastKnownFileType);
+      }
     }
 
+  fileRef->AddAttribute(useLastKnownFileType? "lastKnownFileType"
+                                            : "explicitFileType",
+                        this->CreateString(fileType));
+
   // Store the file path relative to the top of the source tree.
   std::string path = this->RelativeToSource(fullpath.c_str());
   std::string name = cmSystemTools::GetFilenameName(path.c_str());

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

Summary of changes:
 Help/manual/cmake-properties.7.rst                 |    2 +
 Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst          |    8 ++
 Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst        |    9 +++
 Help/release/dev/xcode-file-type.rst               |    7 ++
 Source/cmGlobalXCodeGenerator.cxx                  |   77 ++++++++++++--------
 Source/cmGlobalXCodeGenerator.h                    |    6 +-
 Tests/RunCMake/CMakeLists.txt                      |    4 +
 .../{CMP0004 => XcodeProject}/CMakeLists.txt       |    0
 Tests/RunCMake/XcodeProject/RunCMakeTest.cmake     |    3 +
 .../XcodeProject/XcodeFileType-check.cmake         |   10 +++
 Tests/RunCMake/XcodeProject/XcodeFileType.cmake    |    4 +
 .../hello.f => Tests/RunCMake/XcodeProject/main.c  |    0
 .../RunCMake/XcodeProject/src-default              |    0
 .../RunCMake/XcodeProject/src-explicit             |    0
 .../RunCMake/XcodeProject/src-lastKnown            |    0
 15 files changed, 97 insertions(+), 33 deletions(-)
 create mode 100644 Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
 create mode 100644 Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
 create mode 100644 Help/release/dev/xcode-file-type.rst
 copy Tests/RunCMake/{CMP0004 => XcodeProject}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
 create mode 100644 Tests/RunCMake/XcodeProject/XcodeFileType.cmake
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/XcodeProject/main.c (100%)
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/XcodeProject/src-default (100%)
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/XcodeProject/src-explicit (100%)
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/XcodeProject/src-lastKnown (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list