How to keep CMake-QT generated MOCs in individual obj files? - visual-studio

Is it possible to have CMake-QT generate individual .obj files during AUTOMOC thus allowing for Whole Program Optimization during link time?
If yes - how?
TLDR - Pseudologic:
CMAKE_AUTOMOC ON => [mocs_compilation.obj != (moc_a.obj moc_b.obj)] => linker(one_instead_of_many.obj)? dependency missing : no dependency missing
Situation
When I set CMAKE_AUTOMOC ON in a Project, a file named mocs_compilation.cpp is created in the <project_name>_autogen folder which includes the AUTOMOCed files and thus creates one object instead of several individual files.
Why I think it is important?
Using Link Time Code Generation/Whole Program Optimization in Visual Studio 2015 our build (with custom moc-generation steps and individual .boj files) works without problems - possibly getting rid of unnecessary .obj files thus even eliminating a dependency to an extra LIB/DLL.
PS: By the way I really think there should be a cmake-qt tag if anyone cares to create one.

Seems it is a general issue with CMake:
https://gitlab.kitware.com/cmake/cmake/issues/17277

Related

Configuration-specific resw resource string variants

Been trying to set up configuration-specific variants of resource .resw files in my project, so I could have have different resource string values in Debug and in Release (and in other configurations).
There are standard facilities in VS to have files conditionally included or excluded from build depending on selected Configuration. I have set up file properties to be Content=Yes and Excluded From Build=No for a file that must be included in a configuration, and the other way around for the other file.
The variants appear as expected in the IDE - only one matching current configuration is active, and another one is shown with Content=False in the Properties view, and with a red icon in the files list. The vcxproj also contains correct PRIResource nodes for .resw files with DeploymentContent and ExcludedFromBuild set:
<ItemGroup>
<PRIResource Include="Debug\Strings.resw">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">false</ExcludedFromBuild>
<DeploymentContent...
Building this project however fails with a message
error PRI277: 0xdef00532 - Conflicting values for resource 'resw
name/resource name'
Examining intermediate files reveals that both .resw variants are listed in resources.resfiles that is then fed into MakePri.exe . The ExcludedFromBuild setting appears to be ignored.
How would I get this to work? Is there a special way to control the inclusion of resw files? Maybe a different approach to having string variants altogether?
There are apparently "qualifiers" for organizing resource variants, and a naming scheme (https://learn.microsoft.com/en-us/windows/uwp/app-resources/tailor-resources-lang-scale-contrast). There is even a "Configuration" qualifier, though it is not entirely clear which configuration that is, and where at run time I am supposed to take an identifier to select a resource variant I want.
Adding this as an answer for the sake of completeness, as this is relevant and might even be useful to someone. But I am not happy with project configuration concerns being displaced to runtime, with unneeded and possibly sensitive values being added to the package. So I decided to force-emulate ExcludedFromBuild and am picking and copying the single .resw variant I need into build via a Custom Build Step. Shout out to whoever is responsible for this awkward mess at Microsoft.

Best sphinx workflow for large project with long compile time

I'm working in a large sphinx project with long compile time.
I want to find a way to compile my file(s) of interest without dealing with the entire project.
One way to reduce this is to create an index_small.rst and change the makefile to use that rst instead of the standard index.rst.
One problem with this is that I get warnings for all the rst files I haven't included in the toc tree.
Use the exclude_patterns and :orphan: directives on your index_small.rst:
Use exclude_patterns to explicitly exclude documents or directories from building completely. Use the “orphan” metadata to let a document be built, but notify Sphinx that it is not reachable via a toctree.

Expressions in a build rule "Output Files"?

Can you include expressions in the "Output Files" section of a build rule in Xcode? Eg:
$(DERIVED_FILE_DIR)$(echo "/dynamic/dir")/$(INPUT_FILE_BASE).m
Specifically, when translating Java files with j2objc, the resulting files are saved in subfolders, based on the java packages (eg. $(DERIVED_FILE_DIR)/com/google/Class.[hm]). This is without using --no-package-directories, which I can't use because of duplicate file names in different packages.
The issue is in Output Files, because Xcode doesn't know how to search for the output file at the correct location. The default location is $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).m, but I need to perform a string substitution to insert the correct path. However any expression added as $(expression) gets ignored, as it was never there.
I also tried to export a variable from the custom script and use it in Output Files, but that doesn't work either because the Output Files are transformed into SCRIPT_OUTPUT_FILE_X before the custom script is ran.
Unfortunately, Xcode's build support is pretty primitive (compared to say, make, which is third-odd years older :-). One option to try is splitting the Java source, so that the two classes with the same names are in different sub-projects. If you then use different prefixes for each sub-project, the names will be disambiguated.
A more fragile, but maybe simpler approach is to define a separate rule for the one of the two classes, so that it can have a unique prefix assigned. Then add an early build phase to translate it before any other Java classes, so the rules don't overlap.
For me, the second alternative does work (Xcode 7.3.x) - to a point.
My rule is not for Java, but rather for Google Protobuf, and I tried to maintain the same hierarchy (like your Java package hierarchy) in the generated code as in the source .proto files. Indeed files (.pb.cc and .pb.h) were created as expected, with their hierarchies, inside the Build/Intermediates/myProject.build/Debug/DerivedSources directory.
However, Xcode usually knows to continue and compile the generated output into the current target - but that breaks as it only looks for files in the actual ${DERIVED_FILE} - not within sub-directories underneath.
Could you please explain better "Output Files are transformed into SCRIPT_OUTPUT_FILE_X" ? I do not understand.

MSBuild evaluation fingerprint out of date

We are working with some huge Visual Studio 2010 solutions with a great many static library projects shared between the two. After building either of these solutions the other solution will complain that many (but not all) of the projects are out of date, though actually building naturally does next to nothing and is almost instant.
After following the steps on this question on debugging MSBuild project dependencies I can see many lines of the following messages indicating that the projects are considered out of date because of a "different evaluation fingerprint":
[8444] Project not up to date because the last build has different evaluation fingerprint.
[8444] devenv.exe Information: 0 :
[8444] Project not up to date because the last build has different evaluation fingerprint.
[8444] devenv.exe Information: 0 :
I have come up completely blank while trying to find out what an MSBuild evaluation fingerprint is, where they come from, or what could cause them to be off like this.
Creating new project files is a non-starter given their shear size, the complexity of their configuration requirements, and the lack of enough time in our schedule for cleaning up small annoyances like this.
What are MSBuild evaluation fingerprints and how are they determined?
I assume you are using C++?
The issue is that the solution directory which was used to build the project is saved to to "*.lastbuildstate" file.
It's just a plain text file which look like:
#v4.0:v100:false
Debug|Win32|C:\MyPath\ToSolution\|
The second line is used as project evaluation fingerprint.
First line consist of following information (see line 246 in Microsoft.CppBuild.targets)
#$(TargetFrameworkVersion):$(PlatformToolSet):$(EnableManagedIncrementalBuild)
Second line (see line 38 in Microsoft.CppBuild.targets)
$(Configuration)|$(Platform)|$(SolutionDir)|
Microsoft.CppBuild.targets can be found at %ProgramFiles (x86)%\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets
Maybe its possible to modify / extend the MSBuild scripts not to use the SolutionDir in the lastbuildstate file.

XCode - Editing xcodeproj bundle (specifically project.pbxproj)

I'm working in XCode and I've also written an external editor tool that generates resources for use in the project. In the best case scenario, the tool would edit the project.pbxproj file so that it includes the generated resources in the project. I've read through the file in an attempt to understand it, and it's mostly discernible but there is still one major question I have.
If I wanted to generate a new Group from outside XCode (or a new anything, for that matter), how do I know what ID code to use? For example: 19C28FACFE9D520D11CA2CBB is one of them from my project. How am I supposed to know what to use if I make my own? Do they just need to be unique? Would it be legal to just make one up: 000000000000000000000001 and 000000000000000000000002 and 000000000000000000000003 etc. ?
Any help on this would be wonderful. Thanks.
Yes, you can make your own. The best way would be to use a hash function such as MD5 or SHA1 to generate it then you can truncate it at the desired length. I would hash the name of the file/group along with a time stamp appended this way you get a more unique result.

Resources