CMake Visual Studio generator file extension matching issue
cmake version 3.16.3
I've found what appears to be a bug when using VS_RESOURCE_GENERATOR to define a satellite resource file.
The project contains localized Resources.xaml
with the naming convention Resources.<locale code>.xaml
, which should auto-generate to
Resources.<locale code>.Designer.cs
This method of naming satellite resources are the standard for being parsed by .NET's Cultures / Globalization.
The base Resources.xaml is created with the correct AutoGen compiler configuration, but the subsequent language-specific ones are not, thus throwing a compile warning in Visual Studio and localization not functioning in the resulting executable.
For example in my CMake configuration:
set_property(TARGET AppName PROPERTY VS_RESOURCE_GENERATOR_Resources.resx "${CMAKE_CURRENT_SOURCE_DIR}/Properties/Resources.Designer.cs")
set_property(TARGET AppName PROPERTY VS_RESOURCE_GENERATOR_Resources.en.resx "${CMAKE_CURRENT_SOURCE_DIR}/Properties/Resources.en.Designer.cs")
Results in:
<Compile Include="C:\...\Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
<Link>Properties\Resources.Designer.cs</Link>
</Compile>
<Compile Include="C:\...\Properties\Resources.fr.Designer.cs">
<Link>Properties\Resources.fr.Designer.cs</Link>
</Compile>
Projects generated in Visual Studio that have a working configuration would include the same AutoGen, DependentUpon and DesignTime tags for both files.
It would appear that the issue may stem from the way file-extensions are checked for full equality rather than checking if the file name ends with the matching tag.
This can be seen on the commit adding support for VS files with special extensions, though this code has been rewritten since.