[Cmake-commits] CMake branch, next, updated. v3.8.0-rc1-645-g29c967e

Brad King brad.king at kitware.com
Tue Feb 28 11:36:55 EST 2017


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  29c967ef21bf0248e965cac171cfa2fb51fbaf1c (commit)
       via  44d3cdc45b83c0cdca61513022f36f2dcc569169 (commit)
       via  8dc32b8b86c65c3ab201f22c3bf3570a72513355 (commit)
       via  434492e3c038d2fe18442c8f43daa3078b3cd58c (commit)
      from  126c84a4bb4122c67839f60dba1a0877ff0234c0 (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=29c967ef21bf0248e965cac171cfa2fb51fbaf1c
commit 29c967ef21bf0248e965cac171cfa2fb51fbaf1c
Merge: 126c84a 44d3cdc
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Feb 28 11:36:53 2017 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Feb 28 11:36:53 2017 -0500

    Merge topic 'csproj_add_free_source_tags' into next
    
    44d3cdc4 VS: add test for VS_CSHARP_* source file property
    8dc32b8b VS: add CSharpUtilities module
    434492e3 VS: add VS_CSHARP_<tagname> sourcefile property


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44d3cdc45b83c0cdca61513022f36f2dcc569169
commit 44d3cdc45b83c0cdca61513022f36f2dcc569169
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Fri Feb 24 09:28:13 2017 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 28 10:55:45 2017 -0500

    VS: add test for VS_CSHARP_* source file property

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7848dca..7f270db 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -735,7 +735,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
               if (!value.empty()) {
                 this->WriteString("<", 3);
                 (*this->BuildFileStream) << tagName << ">";
-                (*this->BuildFileStream) << value;
+                (*this->BuildFileStream) << cmVS10EscapeXML(value);
                 (*this->BuildFileStream) << "</" << tagName << ">\n";
               }
             }
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index bc1ec97..3af877f 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -3,3 +3,4 @@ run_cmake(VsConfigurationType)
 run_cmake(VsTargetsFileReferences)
 run_cmake(VsCustomProps)
 run_cmake(VsDebuggerWorkingDir)
+run_cmake(VsCSharpCustomTags)
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
new file mode 100644
index 0000000..70ea193
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
@@ -0,0 +1,23 @@
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+  set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+  return()
+endif()
+
+set(tagFound FALSE)
+
+set(tagName "MyCustomTag")
+set(tagValue "MyCustomValue")
+
+file(STRINGS "${csProjectFile}" lines)
+foreach(line IN LISTS lines)
+  if(line MATCHES "^ *<${tagName}>${tagValue}</${tagName}>")
+    message(STATUS "foo.csproj has tag ${tagName} with value ${tagValue} defined")
+    set(tagFound TRUE)
+  endif()
+endforeach()
+
+if(NOT tagFound)
+  set(RunCMake_TEST_FAILED "Source file tag ${tagName} with value ${tagValue} not found.")
+  return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
new file mode 100644
index 0000000..c51e9c3
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
@@ -0,0 +1,11 @@
+enable_language(CSharp)
+add_library(foo foo.cs)
+
+set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props")
+
+set(tagName "MyCustomTag")
+set(tagValue "MyCustomValue")
+
+set_source_files_properties(foo.cs
+  PROPERTIES
+  VS_CSHARP_${tagName} "${tagValue}")
diff --git a/Tests/RunCMake/VS10Project/foo.cs b/Tests/RunCMake/VS10Project/foo.cs
new file mode 100644
index 0000000..3695dc9
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/foo.cs
@@ -0,0 +1,3 @@
+void foo()
+{
+}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8dc32b8b86c65c3ab201f22c3bf3570a72513355
commit 8dc32b8b86c65c3ab201f22c3bf3570a72513355
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Thu Feb 23 16:49:37 2017 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 28 10:55:45 2017 -0500

    VS: add CSharpUtilities module

diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 2dd56c7..5e96d79 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -66,6 +66,7 @@ All Modules
    /module/CPackRPM
    /module/CPack
    /module/CPackWIX
+   /module/CSharpUtilities
    /module/CTest
    /module/CTestCoverageCollectGCOV
    /module/CTestScriptMode
diff --git a/Help/module/CSharpUtilities.rst b/Help/module/CSharpUtilities.rst
new file mode 100644
index 0000000..3621bbc
--- /dev/null
+++ b/Help/module/CSharpUtilities.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CSharpUtilities.cmake
diff --git a/Help/release/dev/CSharpUtilities.rst b/Help/release/dev/CSharpUtilities.rst
new file mode 100644
index 0000000..e33bd88
--- /dev/null
+++ b/Help/release/dev/CSharpUtilities.rst
@@ -0,0 +1,7 @@
+CSharpUtilities
+---------------
+
+* A new :module:`CSharpUtilities` module was added to make parameterization
+  of Visual Studio CSharp targets easier and more flexible. Provided functions
+  allow automated setting of source file properties to support Windows Forms,
+  WPF/XAML or other technologies as needed.
diff --git a/Modules/CSharpUtilities.cmake b/Modules/CSharpUtilities.cmake
new file mode 100644
index 0000000..ddad85a
--- /dev/null
+++ b/Modules/CSharpUtilities.cmake
@@ -0,0 +1,298 @@
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CSharpUtilities
+---------------
+
+Functions to make configuration of CSharp/.NET targets easier.
+
+A collection of CMake utility functions useful for dealing with CSharp
+targets for Visual Studio generators from version 2010 and later.
+
+The following functions are provided by this module:
+
+**Main functions**
+
+- :command:`csharp_set_windows_forms_properties`
+- :command:`csharp_set_designer_cs_properties`
+- :command:`csharp_set_xaml_cs_properties`
+
+**Helper functions**
+
+- :command:`csharp_get_filename_keys`
+- :command:`csharp_get_filename_key_base`
+- :command:`csharp_get_dependentupon_name`
+
+Main functions provided by the module
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: csharp_set_windows_forms_properties
+
+  Sets source file properties for use of Windows Forms. Use this, if your CSharp
+  target uses windows forms::
+
+    csharp_set_windows_forms_properties([<file1> [<file2> [...]]])
+
+  ``<fileN>``
+    List of all source files which are relevant for setting the
+    :prop_sf:`VS_CSHARP_<tagname>` properties (including ``.cs``, ``.resx`` and
+    ``.Designer.cs`` extensions).
+
+  In the list of all given files for all files ending with ``.Designer.cs`` and
+  ``.resx`` is searched.  For every *designer* or *resource* file a file with the
+  same base name but only ``.cs`` as extension is searched.  If this is found, the
+  :prop_sf:`VS_CSHARP_<tagname>` properties are set as follows:
+
+  for the **.cs** file:
+   - VS_CSHARP_SubType "Form"
+
+  for the **.Designer.cs** file (if it exists):
+   - VS_CSHARP_DependentUpon <cs-filename>
+   - VS_CSHARP_DesignTime "" (delete tag if previously defined)
+   - VS_CSHARP_AutoGen ""(delete tag if previously defined)
+
+  for the **.resx** file (if it exists):
+   - VS_RESOURCE_GENERATOR "" (delete tag if previously defined)
+   - VS_CSHARP_DependentUpon <cs-filename>
+   - VS_CSHARP_SubType "Designer"
+
+.. command:: csharp_set_designer_cs_properties
+
+  Sets source file properties for use of WPF/XAML. Use this, if your CSharp
+  target uses WPF/XAML::
+
+    csharp_set_designer_cs_properties([<file1> [<file2> [...]]])
+
+  ``<fileN>``
+    List of all source files which are relevant for setting the
+    :prop_sf:`VS_CSHARP_<tagname>` properties (including ``.cs``,
+    ``.resx``, ``.settings`` and ``.Designer.cs`` extensions).
+
+  In the list of all given files for all files ending with
+  ``.Designer.cs`` is searched. For every *designer* file all files
+  with the same base name but different extensions are searched. If
+  a match is found, the source file properties of the *designer* file
+  are set depending on the extension of the matched file:
+
+  if match is **.resx** file:
+   - VS_CSHARP_AutoGen "True"
+   - VS_CSHARP_DesignTime "True"
+   - VS_CSHARP_DependentUpon <resx-filename>
+
+  if match is **.cs** file:
+   - VS_CSHARP_DependentUpon <cs-filename>
+
+  if match is **.settings** file:
+   - VS_CSHARP_AutoGen "True"
+   - VS_CSHARP_DesignTimeSharedInput "True"
+   - VS_CSHARP_DependentUpon <settings-filename>
+
+.. command:: csharp_set_xaml_cs_properties
+
+  Sets source file properties for use of WPF/XAML. Use this, if your
+  CSharp target uses WPF/XAML::
+
+    csharp_set_xaml_cs_properties([<file1> [<file2> [...]]])
+
+  ``<fileN>``
+    List of all source files which are relevant for setting the
+    :prop_sf:`VS_CSHARP_<tagname>` properties (including ``.cs``,
+    ``.xaml``, and ``.xaml.cs`` extensions).
+
+  In the list of all given files for all files ending with
+  ``.xaml.cs`` is searched. For every xaml file, a file
+  with the same base name but extension ``.xaml`` is searched.
+  If a match is found, the source file properties of the ``.xaml.cs``
+  file are set:
+
+   - VS_CSHARP_DependentUpon <xaml-filename>
+
+Helper functions which are used by the above ones
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: csharp_get_filename_keys
+
+  Helper function which computes a list of key values to identify
+  source files independently of relative/absolute paths given in cmake
+  and eliminates case sensitivity::
+
+    csharp_get_filename_keys(OUT [<file1> [<file2> [...]]])
+
+  ``OUT``
+    name of the variable in which the list of keys is stored
+
+  ``<fileN>``
+    filename as given to to CSharp target using :command:`add_library`
+    or :command:`add_executable`
+
+  In some way the function applies a canonicalization to the source names.
+  This is necessary to find file matches if the files have been added to
+  the target with different directory prefixes:
+
+  .. code-block:: cmake
+
+    add_library(lib
+      myfile.cs
+      ${CMAKE_CURRENT_SOURCE_DIR}/myfile.Designer.cs)
+
+    set_source_files_properties(myfile.Designer.cs PROPERTIES
+      VS_CSHARP_DependentUpon myfile.cs)
+
+    # this will fail, because in cmake
+    #  - ${CMAKE_CURRENT_SOURCE_DIR}/myfile.Designer.cs
+    #  - myfile.Designer.cs
+    # are not the same source file. The source file property is not set.
+
+.. command:: csharp_get_filename_key_base
+
+  Returns the full filepath and name **withouth** extension of a key.
+  KEY is expected to be a key from csharp_get_filename_keys. In BASE
+  the value of KEY without the file extension is returned::
+
+    csharp_get_filename_key_base(BASE KEY)
+
+  ``BASE``
+    The computed "base" of ``KEY``.
+
+  ``KEY``
+    The key of which the base will be computed. Expected to be a
+    upper case full filename.
+
+.. command:: csharp_get_dependentupon_name
+
+  Computes a string which can be used as value for the source file property
+  :prop_sf:`VS_CSHARP_<tagname>` with *target* being ``DependentUpon``::
+
+    csharp_get_dependentupon_name(NAME FILE)
+
+  ``NAME``
+    result value
+
+  ``FILE``
+    filename to convert to DependentUpon value
+
+  Actually this is only the filename without any path given at the moment.
+
+#]=======================================================================]
+
+function(csharp_get_filename_keys OUT)
+  set(${OUT} "")
+  foreach(f ${ARGN})
+    get_filename_component(f ${f} REALPATH)
+    string(TOUPPER ${f} f)
+    list(APPEND ${OUT} ${f})
+  endforeach()
+  set(${OUT} "${${OUT}}" PARENT_SCOPE)
+endfunction()
+
+function(csharp_get_filename_key_base base key)
+  get_filename_component(dir ${key} DIRECTORY)
+  get_filename_component(fil ${key} NAME_WE)
+  set(${base} "${dir}/${fil}" PARENT_SCOPE)
+endfunction()
+
+function(csharp_get_dependentupon_name out in)
+  get_filename_component(${out} ${in} NAME)
+  set(${out} ${${out}} PARENT_SCOPE)
+endfunction()
+
+function(csharp_set_windows_forms_properties)
+  csharp_get_filename_keys(fileKeys ${ARGN})
+  foreach(key ${fileKeys})
+    get_filename_component(ext ${key} EXT)
+    if(${ext} STREQUAL ".DESIGNER.CS" OR
+       ${ext} STREQUAL ".RESX")
+      csharp_get_filename_key_base(NAME_BASE ${key})
+      list(FIND fileKeys "${NAME_BASE}.CS" FILE_INDEX)
+      if(NOT ${FILE_INDEX} EQUAL -1)
+        list(GET ARGN ${FILE_INDEX} FILE_NAME)
+        # set properties of main form file
+        set_source_files_properties("${FILE_NAME}"
+          PROPERTIES
+          VS_CSHARP_SubType "Form")
+        csharp_get_dependentupon_name(LINK "${FILE_NAME}")
+        # set properties of designer file (if found)
+        list(FIND fileKeys "${NAME_BASE}.DESIGNER.CS" FILE_INDEX)
+        if(NOT ${FILE_INDEX} EQUAL -1)
+          list(GET ARGN ${FILE_INDEX} FILE_NAME)
+          set_source_files_properties("${FILE_NAME}"
+            PROPERTIES
+            VS_CSHARP_DependentUpon "${LINK}"
+            VS_CSHARP_DesignTime ""
+            VS_CSHARP_AutoGen "")
+        endif()
+        # set properties of corresponding resource file (if found)
+        list(FIND fileKeys "${NAME_BASE}.RESX" FILE_INDEX)
+        if(NOT ${FILE_INDEX} EQUAL -1)
+          list(GET ARGN ${FILE_INDEX} FILE_NAME)
+          set_source_files_properties("${FILE_NAME}"
+            PROPERTIES
+            VS_RESOURCE_GENERATOR ""
+            VS_CSHARP_DependentUpon "${LINK}"
+            VS_CSHARP_SubType "Designer")
+        endif()
+      endif()
+    endif()
+  endforeach()
+endfunction()
+
+function(csharp_set_designer_cs_properties)
+  csharp_get_filename_keys(fileKeys ${ARGN})
+  set(INDEX -1)
+  foreach(key ${fileKeys})
+    math(EXPR INDEX "${INDEX}+1")
+    list(GET ARGN ${INDEX} source)
+    get_filename_component(ext ${key} EXT)
+    if(${ext} STREQUAL ".DESIGNER.CS")
+      csharp_get_filename_key_base(NAME_BASE ${key})
+      if("${NAME_BASE}.RESX" IN_LIST fileKeys)
+        list(FIND fileKeys "${NAME_BASE}.RESX" FILE_INDEX)
+        list(GET ARGN ${FILE_INDEX} FILE_NAME)
+        csharp_get_dependentupon_name(LINK "${FILE_NAME}")
+        set_source_files_properties("${source}"
+          PROPERTIES
+          VS_CSHARP_AutoGen "True"
+          VS_CSHARP_DesignTime "True"
+          VS_CSHARP_DependentUpon "${LINK}")
+      elseif("${NAME_BASE}.CS" IN_LIST fileKeys)
+        list(FIND fileKeys "${NAME_BASE}.CS" FILE_INDEX)
+        list(GET ARGN ${FILE_INDEX} FILE_NAME)
+        csharp_get_dependentupon_name(LINK "${FILE_NAME}")
+        set_source_files_properties("${source}"
+          PROPERTIES
+          VS_CSHARP_DependentUpon "${LINK}")
+      elseif("${NAME_BASE}.SETTINGS" IN_LIST fileKeys)
+        list(FIND fileKeys "${NAME_BASE}.SETTINGS" FILE_INDEX)
+        list(GET ARGN ${FILE_INDEX} FILE_NAME)
+        csharp_get_dependentupon_name(LINK "${FILE_NAME}")
+        set_source_files_properties("${source}"
+          PROPERTIES
+          VS_CSHARP_AutoGen "True"
+          VS_CSHARP_DesignTimeSharedInput "True"
+          VS_CSHARP_DependentUpon "${LINK}")
+      endif()
+    endif()
+  endforeach()
+endfunction()
+
+function(csharp_set_xaml_cs_properties)
+  csharp_get_filename_keys(fileKeys ${ARGN})
+  set(INDEX -1)
+  foreach(key ${fileKeys})
+    math(EXPR INDEX "${INDEX}+1")
+    list(GET ARGN ${INDEX} source)
+    get_filename_component(ext ${key} EXT)
+    if(${ext} STREQUAL ".XAML.CS")
+      csharp_get_filename_key_base(NAME_BASE ${key})
+      if("${NAME_BASE}.XAML" IN_LIST fileKeys)
+        list(FIND fileKeys "${NAME_BASE}.XAML" FILE_INDEX)
+        list(GET ARGN ${FILE_INDEX} FILE_NAME)
+        csharp_get_dependentupon_name(LINK "${FILE_NAME}")
+        set_source_files_properties("${source}"
+          PROPERTIES
+          VS_CSHARP_DependentUpon "${LINK}")
+      endif()
+    endif()
+  endforeach()
+endfunction()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=434492e3c038d2fe18442c8f43daa3078b3cd58c
commit 434492e3c038d2fe18442c8f43daa3078b3cd58c
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Thu Feb 23 16:48:16 2017 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Feb 27 13:06:38 2017 -0500

    VS: add VS_CSHARP_<tagname> sourcefile property

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 5fad10c..ac21d48 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -367,6 +367,7 @@ Properties on Source Files
    /prop_sf/SKIP_AUTOUIC
    /prop_sf/SYMBOLIC
    /prop_sf/VS_COPY_TO_OUT_DIR
+   /prop_sf/VS_CSHARP_tagname
    /prop_sf/VS_DEPLOYMENT_CONTENT
    /prop_sf/VS_DEPLOYMENT_LOCATION
    /prop_sf/VS_INCLUDE_IN_VSIX
diff --git a/Help/prop_sf/VS_CSHARP_tagname.rst b/Help/prop_sf/VS_CSHARP_tagname.rst
new file mode 100644
index 0000000..d42159f
--- /dev/null
+++ b/Help/prop_sf/VS_CSHARP_tagname.rst
@@ -0,0 +1,19 @@
+VS_CSHARP_<tagname>
+-------------------
+
+Visual Studio and CSharp source-file-specific configuration.
+
+Tell the Visual Studio generator to set the source file tag
+``<tagname>`` to a given value in the generated Visual Studio CSharp
+project. Ignored on other generators and languages. This property
+can be used to define dependencies between source files or set any
+other Visual Studio specific parameters.
+
+Example usage:
+
+.. code-block:: cmake
+
+  set_source_files_property(<filename>
+           PROPERTIES
+           VS_CSHARP_DependentUpon <other file>
+           VS_CSHARP_SubType "Form")
diff --git a/Help/release/dev/VS_CSHARP_tagname.rst b/Help/release/dev/VS_CSHARP_tagname.rst
new file mode 100644
index 0000000..3fce83d
--- /dev/null
+++ b/Help/release/dev/VS_CSHARP_tagname.rst
@@ -0,0 +1,6 @@
+VS_CSHARP_<tagname>
+-------------------
+
+* :ref:`Visual Studio Generators` for VS 2010 and above learned a
+  new :prop_sf:`VS_CSHARP_<tagname>` source file property to specify
+  custom ``.csproj`` content for source files.
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index b193f65..bbcc300 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -86,6 +86,7 @@ public:
 
   // Get the properties
   cmPropertyMap& GetProperties() { return this->Properties; }
+  const cmPropertyMap& GetProperties() const { return this->Properties; }
 
   /**
    * Check whether the given source file location could refer to this
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index e3853ed..7848dca 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -706,20 +706,40 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
           if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
             generator = g;
           }
-          this->WriteString("<Generator>", 3);
-          (*this->BuildFileStream) << cmVS10EscapeXML(generator)
-                                   << "</Generator>\n";
-          if (designerResource.find(srcDir) == 0) {
-            designerResource = designerResource.substr(srcDir.length() + 1);
-          } else if (designerResource.find(binDir) == 0) {
-            designerResource = designerResource.substr(binDir.length() + 1);
-          } else {
-            designerResource =
-              cmsys::SystemTools::GetFilenameName(designerResource);
+          if (!generator.empty()) {
+            this->WriteString("<Generator>", 3);
+            (*this->BuildFileStream) << cmVS10EscapeXML(generator)
+                                     << "</Generator>\n";
+            if (designerResource.find(srcDir) == 0) {
+              designerResource = designerResource.substr(srcDir.length() + 1);
+            } else if (designerResource.find(binDir) == 0) {
+              designerResource = designerResource.substr(binDir.length() + 1);
+            } else {
+              designerResource =
+                cmsys::SystemTools::GetFilenameName(designerResource);
+            }
+            this->ConvertToWindowsSlash(designerResource);
+            this->WriteString("<LastGenOutput>", 3);
+            (*this->BuildFileStream) << designerResource
+                                     << "</LastGenOutput>\n";
+          }
+        }
+        const cmPropertyMap& props = (*oi)->GetProperties();
+        for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
+             ++p) {
+          static const std::string propNamePrefix = "VS_CSHARP_";
+          if (p->first.find(propNamePrefix.c_str()) == 0) {
+            std::string tagName = p->first.substr(propNamePrefix.length());
+            if (!tagName.empty()) {
+              std::string value = props.GetPropertyValue(p->first);
+              if (!value.empty()) {
+                this->WriteString("<", 3);
+                (*this->BuildFileStream) << tagName << ">";
+                (*this->BuildFileStream) << value;
+                (*this->BuildFileStream) << "</" << tagName << ">\n";
+              }
+            }
           }
-          this->ConvertToWindowsSlash(designerResource);
-          this->WriteString("<LastGenOutput>", 3);
-          (*this->BuildFileStream) << designerResource << "</LastGenOutput>\n";
         }
       }
 
@@ -1968,42 +1988,21 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
         sourceFileTags["Link"] = link;
       }
     }
-    // check if file is a generated .Designer.cs or .xaml.cs file
-    // to add additional necessary tags
-    const std::string fileExtension =
-      cmsys::SystemTools::GetFilenameExtension(f);
-    if (fileExtension == ".Designer.cs" || fileExtension == ".xaml.cs") {
-      f = f.substr(0, f.length() - fileExtension.length());
-      if (sourceFileTags.find("Link") == sourceFileTags.end() &&
-          !this->InSourceBuild) {
-        // add link fallback
-        sourceFileTags["Link"] =
-          cmsys::SystemTools::GetFilenameName(f) + fileExtension;
-      }
-      std::vector<std::string> extensions;
-      extensions.push_back(".resx");
-      extensions.push_back(".settings");
-      extensions.push_back(".xaml");
-      extensions.push_back(".cs");
-      std::string dependencyExtension;
-      for (std::vector<std::string>::iterator i = extensions.begin();
-           i != extensions.end(); ++i) {
-        if (cmsys::SystemTools::FileExists(f + *i)) {
-          dependencyExtension = *i;
-          // There should never be more than one match. Otherwise
-          // one cannot tell on which match the file depends.
-          break;
+    const cmPropertyMap& props = sf.GetProperties();
+    for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
+         ++p) {
+      static const std::string propNamePrefix = "VS_CSHARP_";
+      if (p->first.find(propNamePrefix.c_str()) == 0) {
+        std::string tagName = p->first.substr(propNamePrefix.length());
+        if (!tagName.empty()) {
+          const std::string val = props.GetPropertyValue(p->first);
+          if (!val.empty()) {
+            sourceFileTags[tagName] = val;
+          } else {
+            sourceFileTags.erase(tagName);
+          }
         }
       }
-      if (dependencyExtension == ".resx") {
-        sourceFileTags["DesignTime"] = "True";
-        sourceFileTags["AutoGen"] = "True";
-      } else if (dependencyExtension == ".settings") {
-        sourceFileTags["DesignTimeSharedInput"] = "True";
-        sourceFileTags["AutoGen"] = "True";
-      }
-      sourceFileTags["DependentUpon"] =
-        cmsys::SystemTools::GetFilenameName(f) + dependencyExtension;
     }
     // write source file specific tags
     if (!sourceFileTags.empty()) {

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

Summary of changes:
 Help/manual/cmake-modules.7.rst                    |    1 +
 Help/manual/cmake-properties.7.rst                 |    1 +
 Help/module/CSharpUtilities.rst                    |    1 +
 Help/prop_sf/VS_CSHARP_tagname.rst                 |   19 ++
 Help/release/dev/CSharpUtilities.rst               |    7 +
 Help/release/dev/VS_CSHARP_tagname.rst             |    6 +
 Modules/CSharpUtilities.cmake                      |  298 ++++++++++++++++++++
 Source/cmSourceFile.h                              |    1 +
 Source/cmVisualStudio10TargetGenerator.cxx         |   93 +++---
 Tests/RunCMake/VS10Project/RunCMakeTest.cmake      |    1 +
 .../VS10Project/VsCSharpCustomTags-check.cmake     |   23 ++
 .../RunCMake/VS10Project/VsCSharpCustomTags.cmake  |   11 +
 .../foo.cpp => RunCMake/VS10Project/foo.cs}        |    0
 13 files changed, 415 insertions(+), 47 deletions(-)
 create mode 100644 Help/module/CSharpUtilities.rst
 create mode 100644 Help/prop_sf/VS_CSHARP_tagname.rst
 create mode 100644 Help/release/dev/CSharpUtilities.rst
 create mode 100644 Help/release/dev/VS_CSHARP_tagname.rst
 create mode 100644 Modules/CSharpUtilities.cmake
 create mode 100644 Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
 create mode 100644 Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
 copy Tests/{CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp => RunCMake/VS10Project/foo.cs} (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list