View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013016CMakeCMakepublic2012-03-05 18:322012-09-03 16:00
Reporterchris.haverkate 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionsuspended 
PlatformWindowsOSWindows 7OS Version6.2
Product VersionCMake 2.8.7 
Target VersionFixed in Version 
Summary0013016: [patch] CMake does not support setting "CompileAsManaged" attribute for Visual Studio managed C++ files.
DescriptionCMake does not support setting "CompileAsManaged" attribute for Visual Studio managed C++ files with the Visual Studio 10 generator.

This is not a very "cross-platform" feature (unless Mono supports managed C++?) but it is necessary for Intellisense for managed code.
Steps To ReproduceCreate a shared library project with managed C++ files with the Visual Studio 10 generator, and observe the apparent inability to specify whether a file needs to be compiled as managed C++ in the generated project XML file.
Additional InformationThe attached patch adds support for the VS_COMPILE_AS_MANAGED file property:

set_source_files_properties(file.cpp PROPERTIES VS_COMPILE_AS_MANAGED false)

I tried to copy the coding style but might not have it quite right, there wasn't much guidance on the wiki. If there is a better way to introduce these changes, I'm happy to resubmit.
TagsNo tags attached.
Attached Filespatch file icon VisualStudio10GeneratorAddingCompileAsManagedForSourceFileProperties.patch [^] (2,680 bytes) 2012-03-05 18:32 [Show Content]

 Relationships

  Notes
(0028809)
chris.haverkate (reporter)
2012-03-05 18:33

related to 0012586
(0028812)
Brad King (manager)
2012-03-06 08:32

Unlike 0012586 this is just a compiler flag, no? CMake should map the /clr compile flag to the CompileAsManaged property. Try this:

  set_property(SOURCE mysrc.c PROPERTY COMPILE_FLAGS "/clr")

or for a whole target:

  set_property(TARGET mylib PROPERTY COMPILE_FLAGS "/clr")
(0028846)
chris.haverkate (reporter)
2012-03-06 14:55

The problem stems from needing to use Visual Studio as our unit test runner. To do this we need to wrap our unit tests with a managed C++ test runner (that uses the MSTest framework) and leave the tests compiling as non-managed code.

To accomplish this, we set the project to be compiled as clr:

   set_target_properties(${projectname} PROPERTIES COMPILE_FLAGS "/clr")

and then individually set the compile preference for the unit test files:

   set_source_files_properties(file.cpp PROPERTIES VS_COMPILE_AS_MANAGED false)


I was unable to see a way to clear the "/clr" compile flag using the existing set_property()

Is there some other way to accomplish what we are trying to do using existing functionality?

Thanks.
(0028847)
Brad King (manager)
2012-03-06 15:06

I see there is no negative version of the /clr flag which could be added to the source file to switch it back off. Also there is no negative version of the COMPILE_FLAGS property.

One workaround is to compile the unit test sources with a separate library target (add_library) that is not managed. Then compile the test executable as managed and link to the library to get the unit tests. That way the /clr option can go in the executable target COMPILE_FLAGS property without affecting the unit test sources.

Either way the proposed VS_COMPILE_AS_MANAGED property is not complete. It will not work for the Makefile generators when running MS tools. The property will need to be generalized to map to the corresponding flags in each toolchain.
(0028859)
chris.haverkate (reporter)
2012-03-07 12:53

I reworked our build to only set the managed files with /clr instead of setting the target with /clr then negating the files that were normal C++.

This approach seems to be working now and eliminates the need for this patch.

Thanks for the help!
(0028860)
Brad King (manager)
2012-03-07 13:51

Thanks for reporting back. I'm resolving this issue as "suspended" until there is someone with further need along these lines.
(0030829)
David Cole (manager)
2012-09-03 16:00

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-03-05 18:32 chris.haverkate New Issue
2012-03-05 18:32 chris.haverkate File Added: VisualStudio10GeneratorAddingCompileAsManagedForSourceFileProperties.patch
2012-03-05 18:33 chris.haverkate Note Added: 0028809
2012-03-06 08:32 Brad King Note Added: 0028812
2012-03-06 14:55 chris.haverkate Note Added: 0028846
2012-03-06 15:06 Brad King Note Added: 0028847
2012-03-07 12:53 chris.haverkate Note Added: 0028859
2012-03-07 13:51 Brad King Note Added: 0028860
2012-03-07 13:51 Brad King Status new => resolved
2012-03-07 13:51 Brad King Resolution open => suspended
2012-03-07 13:51 Brad King Assigned To => Brad King
2012-09-03 16:00 David Cole Note Added: 0030829
2012-09-03 16:00 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team