MantisBT - CMake
View Issue Details
0014493CMakeCMakepublic2013-10-18 08:452014-06-02 08:39
mar-na 
Brad King 
normalminoralways
closedfixed 
 
CMake 3.0CMake 3.0 
0014493: Document relationship of VS_KEYWORD and VS_GLOBAL_KEYWORD
I want set the Visual Studio project keyword for a managed project to ManagedCProj. I use VS 2008.
I found the target property VS_GLOBAL_KEYWORD. It was added in Issue 0012586. But this only works for VS 2010 and not for VS 2008.
In the source code is this only added in cmVisualStudio10TargetGenerator.

Is cmLocalVisualStudio7Generator the right place to fix it?
There I found VS_KEYWORD. Is this the same?

cmLocalVisualStudio7Generator:
const char* keyword = target.GetProperty("VS_KEYWORD");
  if(!keyword)
    {
    keyword = "Win32Proj";
    }
    
from cmVisualStudio10TargetGenerator:
  const char* vsGlobalKeyword =
    this->Target->GetProperty("VS_GLOBAL_KEYWORD");
  if(!vsGlobalKeyword)
    {
    this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
    }
  else
    {
    this->WriteString("<Keyword>", 2);
    (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) <<
      "</Keyword>\n";
    }
set_target_properties(myTarget PROPERTIES VS_GLOBAL_KEYWORD "ManagedCProj")
No tags attached.
related to 0012586closed Brad King [patch] CMake does not support Visual Studio projects types or dotnet references with managed C++ 
related to 0008707closed David Cole Add support for global variables in Visual Studio generator 
patch Fix-target-property-for-visual-Studio-project-keyword.patch (2,692) 2013-10-21 05:22
https://public.kitware.com/Bug/file/4911/Fix-target-property-for-visual-Studio-project-keyword.patch
? vs2008-managed_cpp_dotnet_2.vcproj (5,346) 2013-10-21 11:17
https://public.kitware.com/Bug/file/4916/vs2008-managed_cpp_dotnet_2.vcproj
Issue History
2013-10-18 08:45mar-naNew Issue
2013-10-18 09:08Brad KingRelationship addedrelated to 0012586
2013-10-18 09:13Brad KingNote Added: 0034151
2013-10-18 09:15Brad KingNote Added: 0034152
2013-10-21 05:22mar-naFile Added: Fix-target-property-for-visual-Studio-project-keyword.patch
2013-10-21 05:22mar-naNote Added: 0034177
2013-10-21 10:04Brad KingNote Added: 0034189
2013-10-21 10:23Brad KingNote Added: 0034191
2013-10-21 10:23Brad KingAssigned To => Brad King
2013-10-21 10:23Brad KingStatusnew => resolved
2013-10-21 10:23Brad KingResolutionopen => fixed
2013-10-21 10:23Brad KingFixed in Version => CMake 3.0
2013-10-21 10:23Brad KingTarget Version => CMake 3.0
2013-10-21 10:23Brad KingSummaryCould not set Visual Studio project keyword with VS_GLOBAL_KEYWORD and VS 2008 => Document relationship of VS_KEYWORD and VS_GLOBAL_KEYWORD
2013-10-21 10:49mar-naNote Added: 0034200
2013-10-21 10:49mar-naStatusresolved => feedback
2013-10-21 10:49mar-naResolutionfixed => reopened
2013-10-21 10:54Brad KingNote Added: 0034202
2013-10-21 10:55Brad KingStatusfeedback => resolved
2013-10-21 10:55Brad KingResolutionreopened => fixed
2013-10-21 11:16mar-naNote Added: 0034206
2013-10-21 11:16mar-naStatusresolved => feedback
2013-10-21 11:16mar-naResolutionfixed => reopened
2013-10-21 11:17mar-naFile Added: vs2008-managed_cpp_dotnet_2.vcproj
2013-10-21 11:19Brad KingNote Added: 0034207
2013-10-21 11:21Brad KingRelationship addedrelated to 0008787
2013-10-21 11:22Brad KingRelationship deletedrelated to 0008787
2013-10-21 11:22Brad KingRelationship addedrelated to 0008708
2013-10-21 11:22Brad KingRelationship deletedrelated to 0008708
2013-10-21 11:22mar-naNote Added: 0034208
2013-10-21 11:22mar-naStatusfeedback => assigned
2013-10-21 11:22Brad KingRelationship addedrelated to 0008707
2013-10-21 11:23mar-naNote Added: 0034209
2013-10-21 11:25Brad KingNote Added: 0034210
2014-01-27 13:51Brad KingStatusassigned => resolved
2014-01-27 13:51Brad KingResolutionreopened => fixed
2014-06-02 08:39Robert MaynardNote Added: 0036094
2014-06-02 08:39Robert MaynardStatusresolved => closed

Notes
(0034151)
Brad King   
2013-10-18 09:13   
Yes, it looks like these are the same except VS_KEYWORD is for VS < 10 and VS_GLOBAL_KEYWORD is for VS >= 10. It looks like VS_KEYWORD was added here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49840778 [^]

but was left out of the original VS 10 generator implementation. Then VS_GLOBAL_KEYWORD was added here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1f976ce [^]

for VS 10 and no one noticed that VS_KEYWORD should have been there.
(0034152)
Brad King   
2013-10-18 09:15   
It looks like VS_KEYWORD also has meaning for Fortran targets when generating the .vfproj files for the Intel Fortran VS plugin.
(0034177)
mar-na   
2013-10-21 05:22   
Try to resolve: Fix-target-property-for-visual-Studio-project-keyword.patch
Tested with VS 2008 and VS 2010.

Marked VS_GLOBAL_KEYWORD as obsolete.

for VS <= 2008:
unchanged

for VS >= 2010:
Use VS_KEYWORD instead of VS_GLOBAL_KEYWORD.
If VS_GLOBAL_KEYWORD was found then use the value for VS_KEYWORD. (for Backward compatibility)
(0034189)
Brad King   
2013-10-21 10:04   
The current behavior has been status-quo since 2.8.7 which is almost two years old now. I like the name VS_GLOBAL_KEYWORD better for VS 10 because it is grouped with other Global values in the msbuild project file set by VS_GLOBAL_* properties. I think it is better to just document the current behavior (which is for which version).
(0034191)
Brad King   
2013-10-21 10:23   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b9fe4b63 [^]
(0034200)
mar-na   
2013-10-21 10:49   
Only a question. (Sorry if it is not allowed to reopen it for additional questions)

Should I allways added this in me CMakeList.txt files:

# sets the "keyword" attribute in the project file
if(MSVC_VERSION LESS 1600) # For < VS 2010
  set_target_properties(MyTarget PROPERTIES VS_KEYWORD "ManagedCProj")
else() # For >= VS 2010
  set_target_properties(MyTarget PROPERTIES VS_GLOBAL_KEYWORD "ManagedCProj")
(0034202)
Brad King   
2013-10-21 10:54   
There is no reason not to set a property that will not be used so you can do just

 set_target_properties(MyTarget PROPERTIES
   VS_KEYWORD "ManagedCProj" # < VS 2010
   VS_GLOBAL_KEYWORD "ManagedCProj" # >= VS 2010
   )
(0034206)
mar-na   
2013-10-21 11:16   
Sorry again

If I set VS_GLOBAL_KEYWORD in a VS 2008 project then I get it additional in the section global. But is this right?
When I create I Managed C++ Project direct with VS 2008 then it set only the Key attribut but do not added it to the global section.

<Globals>
</Globals>
(0034207)
Brad King   
2013-10-21 11:19   
Ugh, that's hitting this:

http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:VS_GLOBAL_variable [^]
(0034208)
mar-na   
2013-10-21 11:22   
Add file wich was self generated with VS 2008.

When it was generated with CMake. I get this:
<Globals>
    <Global
        Name="KEYWORD"
        Value="ManagedCProj"
    />
</Globals>
(0034209)
mar-na   
2013-10-21 11:23   
Sorry. It was auto assign. How could I revert this??
(0034210)
Brad King   
2013-10-21 11:25   
This is a long-existing conflict between the old VS 2008 generator feature and the new VS 2010 VS_GLOBAL_* properties. Does the extra Global hurt anything?
(0036094)
Robert Maynard   
2014-06-02 08:39   
Closing resolved issues that have not been updated in more than 4 months.