From 53116d39424ac3ec8819aab6710211634be6240e Mon Sep 17 00:00:00 2001 From: Matt Davies Date: Wed, 18 Mar 2020 12:07:08 +0000 Subject: VS: Use unordered_map to write HLSL settings. --- Source/cmVisualStudio10TargetGenerator.cxx | 193 +++++++++++++++-------------- Source/cmVisualStudio10TargetGenerator.h | 7 ++ 2 files changed, 107 insertions(+), 93 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 6f5d813..d55d30d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1754,20 +1754,37 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1, } } +bool cmVisualStudio10TargetGenerator::cmPropertyIsSameInAllConfigs( + const ConfigToSettings& toolSettings, const std::string& propName) +{ + std::string firstPropValue = ""; + for (const auto& configToSettings : toolSettings) { + const std::unordered_map& settings = + configToSettings.second; + + if (firstPropValue.empty()) { + if (settings.find(propName) != settings.end()) { + firstPropValue = settings.find(propName)->second; + } + } + + if (settings.find(propName) == settings.end()) { + return false; + } + + if (settings.find(propName)->second != firstPropValue) { + return false; + } + } + + return true; +} + void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, cmSourceFile const* sf) { bool toolHasSettings = false; const char* tool = "None"; - std::string shaderType; - std::string shaderEntryPoint; - std::string shaderModel; - std::string shaderAdditionalFlags; - std::string shaderDisableOptimizations; - std::string shaderEnableDebug; - std::string shaderObjectFileName; - std::string outputHeaderFile; - std::string variableName; std::string settingsGenerator; std::string settingsLastGenOutput; std::string sourceLink; @@ -1775,6 +1792,11 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, std::string copyToOutDir; std::string includeInVsix; std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); + ConfigToSettings toolSettings; + for (const auto& config : this->Configurations) { + toolSettings[config]; + } + if (this->ProjectType == csproj && !this->InSourceBuild) { toolHasSettings = true; } @@ -1782,47 +1804,72 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, tool = "FXCompile"; // Figure out the type of shader compiler to use. if (const char* st = sf->GetProperty("VS_SHADER_TYPE")) { - shaderType = st; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["ShaderType"] = st; + } } // Figure out which entry point to use if any if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) { - shaderEntryPoint = se; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["EntryPointName"] = se; + } } // Figure out which shader model to use if any if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) { - shaderModel = sm; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["ShaderModel"] = sm; + } } // Figure out which output header file to use if any if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) { - outputHeaderFile = ohf; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["HeaderFileOutput"] = ohf; + } } // Figure out which variable name to use if any if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) { - variableName = vn; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["VariableName"] = vn; + } } // Figure out if there's any additional flags to use if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) { - shaderAdditionalFlags = saf; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["AdditionalOptions"] = saf; + } } // Figure out if debug information should be generated if (const char* sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) { - shaderEnableDebug = sed; - toolHasSettings = true; + cmGeneratorExpression ge; + std::unique_ptr cge = ge.Parse(sed); + + for (const std::string& config : this->Configurations) { + std::string evaluated = cge->Evaluate(this->LocalGenerator, config); + + if (!evaluated.empty()) { + toolSettings[config]["EnableDebuggingInformation"] = + cmIsOn(evaluated) ? "true" : "false"; + } + } } // Figure out if optimizations should be disabled if (const char* sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) { - shaderDisableOptimizations = sdo; - toolHasSettings = true; + cmGeneratorExpression ge; + std::unique_ptr cge = ge.Parse(sdo); + + for (const std::string& config : this->Configurations) { + std::string evaluated = cge->Evaluate(this->LocalGenerator, config); + + if (!evaluated.empty()) { + toolSettings[config]["DisableOptimizations"] = + cmIsOn(evaluated) ? "true" : "false"; + } + } } if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) { - shaderObjectFileName = sofn; - toolHasSettings = true; + for (const std::string& config : this->Configurations) { + toolSettings[config]["ObjectFileOutput"] = sofn; + } } } else if (ext == "jpg" || ext == "png") { tool = "Image"; @@ -1892,11 +1939,37 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } + if (!toolSettings.empty()) { + toolHasSettings = true; + } + Elem e2(e1, tool); this->WriteSource(e2, sf); if (toolHasSettings) { e2.SetHasElements(); + std::vector writtenSettings; + for (const auto& configSettings : toolSettings) { + for (const auto& setting : configSettings.second) { + + if (std::find(writtenSettings.begin(), writtenSettings.end(), + setting.first) != writtenSettings.end()) { + continue; + } + + if (cmPropertyIsSameInAllConfigs(toolSettings, setting.first)) { + e2.Element(setting.first, setting.second); + writtenSettings.push_back(setting.first); + } else { + e2.WritePlatformConfigTag(setting.first, + "'$(Configuration)|$(Platform)'=='" + + configSettings.first + "|" + + this->Platform + "'", + setting.second); + } + } + } + if (!deployContent.empty()) { cmGeneratorExpression ge; std::unique_ptr cge = @@ -1922,73 +1995,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } } - if (!shaderType.empty()) { - e2.Element("ShaderType", shaderType); - } - if (!shaderEntryPoint.empty()) { - e2.Element("EntryPointName", shaderEntryPoint); - } - if (!shaderModel.empty()) { - e2.Element("ShaderModel", shaderModel); - } - if (!outputHeaderFile.empty()) { - for (size_t i = 0; i != this->Configurations.size(); ++i) { - e2.WritePlatformConfigTag("HeaderFileOutput", - "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + - this->Platform + "'", - outputHeaderFile); - } - } - if (!variableName.empty()) { - for (size_t i = 0; i != this->Configurations.size(); ++i) { - e2.WritePlatformConfigTag("VariableName", - "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + - this->Platform + "'", - variableName); - } - } - if (!shaderEnableDebug.empty()) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(shaderEnableDebug); - - for (size_t i = 0; i != this->Configurations.size(); ++i) { - const std::string& enableDebug = - cge->Evaluate(this->LocalGenerator, this->Configurations[i]); - if (!enableDebug.empty()) { - e2.WritePlatformConfigTag("EnableDebuggingInformation", - "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + - this->Platform + "'", - cmIsOn(enableDebug) ? "true" : "false"); - } - } - } - if (!shaderDisableOptimizations.empty()) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(shaderDisableOptimizations); - for (size_t i = 0; i != this->Configurations.size(); ++i) { - const std::string& disableOptimizations = - cge->Evaluate(this->LocalGenerator, this->Configurations[i]); - if (!disableOptimizations.empty()) { - e2.WritePlatformConfigTag( - "DisableOptimizations", - "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] + - "|" + this->Platform + "'", - (cmIsOn(disableOptimizations) ? "true" : "false")); - } - } - } - if (!shaderObjectFileName.empty()) { - e2.Element("ObjectFileOutput", shaderObjectFileName); - } - if (!shaderAdditionalFlags.empty()) { - e2.Element("AdditionalOptions", shaderAdditionalFlags); - } if (!settingsGenerator.empty()) { e2.Element("Generator", settingsGenerator); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 4977c1a..8e5f29b 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -10,6 +10,7 @@ #include #include #include +#include #include class cmComputeLinkInformation; @@ -236,6 +237,12 @@ private: using ToolSourceMap = std::map; ToolSourceMap Tools; + + using ConfigToSettings = + std::unordered_map>; + bool cmPropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, + const std::string& propName); std::string GetCMakeFilePath(const char* name) const; }; -- cgit v0.12 From 2ce42f281fb5403cad398e886f0138d60f6a1dae Mon Sep 17 00:00:00 2001 From: Matt Davies Date: Wed, 18 Mar 2020 12:25:02 +0000 Subject: VS: Add VS_SETTINGS source file property VS_SETTINGS is a list of key value pairs that get written as item metadata for the associated non-built file. The entire value of VS_SETTINGS is evaluated as a generator expression. --- Source/cmVisualStudio10TargetGenerator.cxx | 34 ++++++++++++++++++++++++++++-- Source/cmVisualStudio10TargetGenerator.h | 6 ++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d55d30d..d67fe72 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1754,7 +1754,35 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1, } } -bool cmVisualStudio10TargetGenerator::cmPropertyIsSameInAllConfigs( +void cmVisualStudio10TargetGenerator::ParseSettingsProperty( + const char* settingsPropertyValue, ConfigToSettings& toolSettings) +{ + if (settingsPropertyValue) { + cmGeneratorExpression ge; + + std::unique_ptr cge = + ge.Parse(settingsPropertyValue); + + for (const std::string& config : this->Configurations) { + std::string evaluated = cge->Evaluate(this->LocalGenerator, config); + + std::vector settings = cmExpandedList(evaluated); + for (const std::string& setting : settings) { + const std::string::size_type assignment = setting.find('='); + if (assignment != std::string::npos) { + const std::string propName = setting.substr(0, assignment); + const std::string propValue = setting.substr(assignment + 1); + + if (!propValue.empty()) { + toolSettings[config][propName] = propValue; + } + } + } + } + } +} + +bool cmVisualStudio10TargetGenerator::PropertyIsSameInAllConfigs( const ConfigToSettings& toolSettings, const std::string& propName) { std::string firstPropValue = ""; @@ -1939,6 +1967,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } + ParseSettingsProperty(sf->GetProperty("VS_SETTINGS"), toolSettings); + if (!toolSettings.empty()) { toolHasSettings = true; } @@ -1957,7 +1987,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, continue; } - if (cmPropertyIsSameInAllConfigs(toolSettings, setting.first)) { + if (PropertyIsSameInAllConfigs(toolSettings, setting.first)) { e2.Element(setting.first, setting.second); writtenSettings.push_back(setting.first); } else { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 8e5f29b..790811b 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -241,8 +241,10 @@ private: using ConfigToSettings = std::unordered_map>; - bool cmPropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, - const std::string& propName); + bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, + const std::string& propName); + void ParseSettingsProperty(const char* settingsPropertyValue, + ConfigToSettings& toolSettings); std::string GetCMakeFilePath(const char* name) const; }; -- cgit v0.12 From f00e1b816d7220b700f7f8d24347d80b66e30c86 Mon Sep 17 00:00:00 2001 From: Matt Davies Date: Wed, 18 Mar 2020 12:38:38 +0000 Subject: VS: Add VS_SOURCE_SETTINGS_ target property VS_SOURCE_SETTINGS_ is a list of key value pairs that get written as item metadata for any file associated with for that target. The entire value of VS_SOURCE_SETTINGS_ is evaluated as a generator expression. VS_SETTINGS can override settings specified in this property. --- Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++++++++++++++ Source/cmVisualStudio10TargetGenerator.h | 1 + 2 files changed, 17 insertions(+) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d67fe72..7eaf625 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1967,6 +1967,22 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } + if (ParsedToolTargetSettings.find(tool) == ParsedToolTargetSettings.end()) { + const char* toolTargetProperty = + this->GeneratorTarget->Target->GetProperty("VS_SOURCE_SETTINGS_" + + std::string(tool)); + ConfigToSettings toolTargetSettings; + ParseSettingsProperty(toolTargetProperty, toolTargetSettings); + + ParsedToolTargetSettings[tool] = toolTargetSettings; + } + + for (const auto& configToSetting : ParsedToolTargetSettings[tool]) { + for (const auto& setting : configToSetting.second) { + toolSettings[configToSetting.first][setting.first] = setting.second; + } + } + ParseSettingsProperty(sf->GetProperty("VS_SETTINGS"), toolSettings); if (!toolSettings.empty()) { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 790811b..f5eb72b 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -241,6 +241,7 @@ private: using ConfigToSettings = std::unordered_map>; + std::unordered_map ParsedToolTargetSettings; bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, const std::string& propName); void ParseSettingsProperty(const char* settingsPropertyValue, -- cgit v0.12 From 2ca1102f8347b0d25b476a9a785977f2dc8a812b Mon Sep 17 00:00:00 2001 From: Matt Davies Date: Wed, 18 Mar 2020 16:40:56 +0000 Subject: VS: Test VS_SETTINGS and VS_SOURCE_SETTINGS_ properties. --- Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 2 + Tests/RunCMake/VS10Project/VsSettings-check.cmake | 23 +++++++++++ Tests/RunCMake/VS10Project/VsSettings.cmake | 5 +++ .../VS10Project/VsSourceSettingsTool-check.cmake | 34 ++++++++++++++++ .../VS10Project/VsSourceSettingsTool.cmake | 5 +++ Tests/RunCMake/VS10Project/shader.hlsl | 1 + Tests/RunCMake/VS10Project/shader2.hlsl | 1 + Tests/VSWinStorePhone/CMakeLists.txt | 7 +++- Tests/VSWinStorePhone/EnsurePropertiesSet.cmake | 45 ++++++++++++++++++++++ 9 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/VS10Project/VsSettings-check.cmake create mode 100644 Tests/RunCMake/VS10Project/VsSettings.cmake create mode 100644 Tests/RunCMake/VS10Project/VsSourceSettingsTool-check.cmake create mode 100644 Tests/RunCMake/VS10Project/VsSourceSettingsTool.cmake create mode 100644 Tests/RunCMake/VS10Project/shader.hlsl create mode 100644 Tests/RunCMake/VS10Project/shader2.hlsl create mode 100644 Tests/VSWinStorePhone/EnsurePropertiesSet.cmake diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 3ca7cc0..5ccca01 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -31,6 +31,8 @@ run_cmake(VsDpiAwareBadParam) run_cmake(VsPrecompileHeaders) run_cmake(VsPrecompileHeadersReuseFromCompilePDBName) run_cmake(VsDeployEnabled) +run_cmake(VsSettings) +run_cmake(VsSourceSettingsTool) run_cmake(VsWinRTByDefault) diff --git a/Tests/RunCMake/VS10Project/VsSettings-check.cmake b/Tests/RunCMake/VS10Project/VsSettings-check.cmake new file mode 100644 index 0000000..0f8b26c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSettings-check.cmake @@ -0,0 +1,23 @@ +macro(ensure_props_set projectFile) + if(NOT EXISTS "${projectFile}") + set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.") + return() + endif() + + set(SettingFound FALSE) + + file(STRINGS "${projectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "SourceProperty1Value") + message("SourceProperty1 setting found") + set(SettingFound TRUE) + endif() + endforeach() + + if (NOT SettingFound) + set(RunCMake_TEST_FAILED "SourceProperty1 setting was not found") + return() + endif() +endmacro() + +ensure_props_set("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") diff --git a/Tests/RunCMake/VS10Project/VsSettings.cmake b/Tests/RunCMake/VS10Project/VsSettings.cmake new file mode 100644 index 0000000..a4b321b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSettings.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) + +add_library(foo foo.cpp shader.hlsl) +set_property(SOURCE shader.hlsl PROPERTY VS_SETTINGS + "$<$:SourceProperty1=SourceProperty1Value>") diff --git a/Tests/RunCMake/VS10Project/VsSourceSettingsTool-check.cmake b/Tests/RunCMake/VS10Project/VsSourceSettingsTool-check.cmake new file mode 100644 index 0000000..29a89c3 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSourceSettingsTool-check.cmake @@ -0,0 +1,34 @@ +macro(ensure_props_set projectFile) + if(NOT EXISTS "${projectFile}") + set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.") + return() + endif() + + set(FirstSettingFound FALSE) + set(SecondSettingFound FALSE) + + file(STRINGS "${projectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "TargetProperty1ValueDebug") + if (FirstSettingFound) + message("TargetProperty1 setting found twice") + set(SecondSettingFound TRUE) + else() + message("TargetProperty1 setting found once") + set(FirstSettingFound TRUE) + endif() + endif() + endforeach() + + if (NOT FirstSettingFound) + set(RunCMake_TEST_FAILED "TargetProperty1 setting not found at all") + return() + endif() + + if (NOT SecondSettingFound) + set(RunCMake_TEST_FAILED "TargetProperty1 setting found once when it should be found twice") + return() + endif() +endmacro() + +ensure_props_set("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") diff --git a/Tests/RunCMake/VS10Project/VsSourceSettingsTool.cmake b/Tests/RunCMake/VS10Project/VsSourceSettingsTool.cmake new file mode 100644 index 0000000..498962f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSourceSettingsTool.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) + +add_library(foo foo.cpp shader.hlsl shader2.hlsl) +set_property(TARGET foo PROPERTY VS_SOURCE_SETTINGS_FXCompile + "$<$:TargetProperty1=TargetProperty1ValueDebug>") diff --git a/Tests/RunCMake/VS10Project/shader.hlsl b/Tests/RunCMake/VS10Project/shader.hlsl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Tests/RunCMake/VS10Project/shader.hlsl @@ -0,0 +1 @@ + diff --git a/Tests/RunCMake/VS10Project/shader2.hlsl b/Tests/RunCMake/VS10Project/shader2.hlsl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Tests/RunCMake/VS10Project/shader2.hlsl @@ -0,0 +1 @@ + diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index b8e157d..558d5de 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -127,7 +127,7 @@ set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3) set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED") set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h") - +set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SETTINGS "$<$:SourceProperty1=SourceProperty1Value>") source_group("Source Files" FILES ${SOURCE_FILES}) source_group("Header Files" FILES ${HEADER_FILES}) @@ -135,6 +135,11 @@ source_group("Resource Files" FILES ${RESOURCE_FILES}) add_executable(${EXE_NAME} WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES}) set_property(TARGET ${EXE_NAME} PROPERTY VS_WINRT_COMPONENT TRUE) +set_property(TARGET ${EXE_NAME} PROPERTY VS_SOURCE_SETTINGS_FXCompile + "TargetProperty1=$<$:TargetProperty1ValueDebug>$<$:TargetProperty1ValueRelease>") + +add_custom_command(TARGET ${EXE_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -Dvcxproj="${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.vcxproj" -P "${CMAKE_CURRENT_SOURCE_DIR}/EnsurePropertiesSet.cmake") string(SUBSTRING "${CMAKE_SYSTEM_VERSION}" 0, 4, SHORT_VERSION) diff --git a/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake b/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake new file mode 100644 index 0000000..528c46f --- /dev/null +++ b/Tests/VSWinStorePhone/EnsurePropertiesSet.cmake @@ -0,0 +1,45 @@ +macro(ensure_props_set projectFile) + if(NOT EXISTS "${projectFile}") + message(FATAL_ERROR "Project file ${projectFile} does not exist.") + return() + endif() + + set(SourcePropertyFound FALSE) + set(DebugTargetPropertyFound FALSE) + set(ReleaseTargetPropertyFound FALSE) + + file(STRINGS "${projectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "SourceProperty1Value") + message("SourceProperty1 setting found") + set(SourcePropertyFound TRUE) + endif() + + if(line MATCHES "TargetProperty1ValueDebug") + message("Debug TargetProperty1 setting found") + set(DebugTargetPropertyFound TRUE) + endif() + + if(line MATCHES "TargetProperty1ValueRelease") + message("Release TargetProperty1 setting found") + set(ReleaseTargetPropertyFound TRUE) + endif() + endforeach() + + if (NOT SourcePropertyFound) + message(FATAL_ERROR "SourceProperty1 setting not found") + return() + endif() + + if (NOT DebugTargetPropertyFound) + message(FATAL_ERROR "Debug TargetProperty1 setting not found") + return() + endif() + + if (NOT ReleaseTargetPropertyFound) + message(FATAL_ERROR "Release TargetProperty1 setting not found") + return() + endif() +endmacro() + +ensure_props_set("${vcxproj}") -- cgit v0.12 From 0723e04f7a13ca1b1ae5c4ef2c603b922bcf82e8 Mon Sep 17 00:00:00 2001 From: Matt Davies Date: Fri, 27 Mar 2020 15:40:43 +0000 Subject: VS: Add documentation for VS_SETTINGS and VS_SOURCE_SETTINGS_. --- Help/manual/cmake-properties.7.rst | 2 ++ Help/prop_sf/VS_SETTINGS.rst | 18 ++++++++++++++++++ Help/prop_tgt/VS_SOURCE_SETTINGS_tool.rst | 19 +++++++++++++++++++ Help/release/dev/vs-non-built-file-item-metadata.rst | 10 ++++++++++ 4 files changed, 49 insertions(+) create mode 100644 Help/prop_sf/VS_SETTINGS.rst create mode 100644 Help/prop_tgt/VS_SOURCE_SETTINGS_tool.rst create mode 100644 Help/release/dev/vs-non-built-file-item-metadata.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index e552377..55edfb0 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -377,6 +377,7 @@ Properties on Targets /prop_tgt/VS_SCC_PROVIDER /prop_tgt/VS_SDK_REFERENCES /prop_tgt/VS_SOLUTION_DEPLOY + /prop_tgt/VS_SOURCE_SETTINGS_tool /prop_tgt/VS_USER_PROPS /prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION /prop_tgt/VS_WINRT_COMPONENT @@ -486,6 +487,7 @@ Properties on Source Files /prop_sf/VS_DEPLOYMENT_LOCATION /prop_sf/VS_INCLUDE_IN_VSIX /prop_sf/VS_RESOURCE_GENERATOR + /prop_sf/VS_SETTINGS /prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS /prop_sf/VS_SHADER_ENABLE_DEBUG /prop_sf/VS_SHADER_ENTRYPOINT diff --git a/Help/prop_sf/VS_SETTINGS.rst b/Help/prop_sf/VS_SETTINGS.rst new file mode 100644 index 0000000..0719406 --- /dev/null +++ b/Help/prop_sf/VS_SETTINGS.rst @@ -0,0 +1,18 @@ +VS_SETTINGS +----------- + +Set any item metadata on a non-built file. + +Takes a list of ``Key=Value`` pairs. Tells the Visual Studio generator to set +``Key`` to ``Value`` as item metadata on the file. + +For example: + +.. code-block:: cmake + + set_property(SOURCE file.hlsl PROPERTY VS_SETTINGS "Key=Value" "Key2=Value2") + +will set ``Key`` to ``Value`` and ``Key2`` to ``Value2`` on the +``file.hlsl`` item as metadata. + +Generator expressions are supported. diff --git a/Help/prop_tgt/VS_SOURCE_SETTINGS_tool.rst b/Help/prop_tgt/VS_SOURCE_SETTINGS_tool.rst new file mode 100644 index 0000000..f706888 --- /dev/null +++ b/Help/prop_tgt/VS_SOURCE_SETTINGS_tool.rst @@ -0,0 +1,19 @@ +VS_SOURCE_SETTINGS_ +------------------------- + +Set any item metadata on all non-built files that use . + +Takes a list of ``Key=Value`` pairs. Tells the Visual Studio generator +to set ``Key`` to ``Value`` as item metadata on all non-built files +that use ````. + +For example: + +.. code-block:: cmake + + set_property(TARGET main PROPERTY VS_SOURCE_SETTINGS_FXCompile "Key=Value" "Key2=Value2") + +will set ``Key`` to ``Value`` and ``Key2`` to ``Value2`` for all +non-built files that use ``FXCompile``. + +Generator expressions are supported. diff --git a/Help/release/dev/vs-non-built-file-item-metadata.rst b/Help/release/dev/vs-non-built-file-item-metadata.rst new file mode 100644 index 0000000..26cbad0 --- /dev/null +++ b/Help/release/dev/vs-non-built-file-item-metadata.rst @@ -0,0 +1,10 @@ +vs-non-built-file-item-metadata +------------------------------- + +* The :prop_tgt:`VS_SOURCE_SETTINGS_` target property was added + to tell :ref:`Visual Studio Generators` for VS 2010 and above to add + metadata to non-built source files using ````. + +* The :prop_sf:`VS_SETTINGS` source file property was added to tell + :ref:`Visual Studio Generators` for VS 2010 and above to add + metadata to a non-built source file. -- cgit v0.12