VS: add test for VS_CSHARP_* source file property

This commit is contained in:
Michael Stürmer 2017-02-24 09:28:13 +01:00 committed by Brad King
parent a202749c46
commit 506207f928
4 changed files with 38 additions and 0 deletions

View File

@ -3,3 +3,4 @@ run_cmake(VsConfigurationType)
run_cmake(VsTargetsFileReferences)
run_cmake(VsCustomProps)
run_cmake(VsDebuggerWorkingDir)
run_cmake(VsCSharpCustomTags)

View File

@ -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()

View File

@ -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}")

View File

@ -0,0 +1,3 @@
void foo()
{
}