Generating vcxproj files with object output paths like in object_parallel_to_source mode - visual-studio-2010

What configuration do I need to give QMake to generate a vcxproj file where the object files are arranged in a tree like the original code?
I have been searching for quite a while and even scrutinized the source of qmake but to no avail.
So far I tried CONFIG -= flat which only changed the filters, but not the output paths. And object_parallel_to_source which only works with makefiles as far as I can tell.
I need the feature to avoid name clashes of object files having the same name, because their source files have the same name but reside in different folders.
It is definitely possible to avoid this with MSVC by setting the appropriate output path for files in their properties dialog. However, this is tedious and as I am developing a project mainly on Linux and then porting it over to Windows from time to time I have to do the whole procedure over and over again.

Related

Can I delete every other file than the compiled program?

When I build solution in Visual Studio (2022), it generates an EXE (or DLL if I chose a class library) just as expected, except it also generates some files, like PDB, and some CS files. I know what most of them do, but if I am making a software, which consists of multiple of these files, I wouldn't want or like some people looking at the application directory and find source files and/or source code and solutions. This makes me come up with a question: Would deleting every single file except the compiled EXE or DLL impact their usability, or is there any other circumstance(s) to avoid creating these files, like SLN or PDB?
Thanks in advance :)
I have not tried anything, because, I simply don't know how to prevent VS from creating these files, except compiled files.
The .pdb files are outputs of your compilation. You can suppress them with:
<DebugSymbols>false</DebugSymbols>
The other files, like .cs and .sln are inputs to your project. Deleting them will mean you cannot build your program any more. I don't understand why you would want them to be deleted. If they're appearing in your output directory, check that you don't have "Copy local" (CopyToOutputDirectory) set on those items in your project.

By default Visual Studio puts output files in the source tree, how do I move them elsewhere?

A default install of Visual Studio 2013 creates intermediate and output files in the source tree. This is makes housekeeping harder - I can't just nuke a whole directory to get rid of intermediate files, for example. It also makes it easy to accidentally add a whole bunch of said junk to source control by mistake.
How do you tell VS to put the files elsewhere?
Open your proj file in a text editor, and look for something like this, depending on your platform/configuration:
<OutputPath>bin\x64\Release\</OutputPath>
Change it to whatever path you want it to be.
At build time the locations of these files comes from the $(IntDir) and $(OutDir) build variables. These are defined by shared property sheet entries - shared as in shared by all projects built on a system. Updating that shared property sheet to put them elsewhere is a little tedious but only has to be done once.
For example, to change them such that intermediate files are placed in D:\Obj and output files are placed in D:\Exe:
From the View menu, select PropertyManager.
Expand any project node, e.g. MyProject.
Expand any platform configuration node, e.g. Debug | Win32.
Open the Microsoft.Cpp.Win32.user property sheet.
Select the General section
Set the Intermediate Directory to (note the trailing backslash!)
D:\Obj\$(SolutionName)\$(ProjectName)\$(Platform)\$(Configuration)\
Set the Output Directory to (note the trailing backslash!)
D:\Exe\$(SolutionName)\$(ProjectName)\$(Platform)\$(Configuration)\
Repeat these steps for the remaining platform configuration nodes, e.g. Debug | x64
The property sheets are shared by different build types (e.g. debug, release) within a configuration, but not across platforms. This is why you have to repeat the steps for each platform (e.g. Win32 & x64). But you only have to do this for one project because they all use the same set of property sheets.
BEWARE!
There is a possible issue with this setup. Because the full drive and path is omitted from the directories, if you have more than one copy of a project/solution they will both try to write their output to the same location, possibly leading to horribleness.

Method to make IncludeDirs available to external tool

I'm currently trying to make splint available as an external tool in Visual Studio 2010.
It has problems with finding all includes for the file, since it seems that the INCLUDE variable is only set at build time and I haven't found any other possibility to extract the include files in any way.
My question: Would there be any way to extract the IncludeDir field from the current file's project's Properties page, ideally with the VC++'s AdditionalIncludeDirectories?
Note also that AdditionalIncludeDirectories is per file, as it can be changed for individual source files as well as on the project level, and if it contains macros it can evaluate differently for each source file too!
I'm not familiar with driving the MSBuild objects via the API, but that's used by the IDE. Whether that way or by simply running MSBuild.exe, you need to get it to figure out all the properties, conditions, etc. and then tell you the result. If everything is well behaved, you could create a target that also uses the ClCompile item array and emits the %(AdditionalIncludeDirectories) metadata somehow such as writing it to a file or passing it to your other tool somehow. That's what's used to generate the /I parameters to CL, and you can get the same values.
If things are not well behaved in that necessary values are changed during the detailed build process, you would need to get the same prelims done just like the ClCompile target normally does, too. Or just override ClCompile with your own (last definition of a target is used) so it certainly is in the same context.
Either way, there are places where build script files can be automatically included into all projects, so you can add your stuff there or use a command argument (I think) to MSBuild to add another Include.
—John

Build problems with Visual C++ project after checking in and checking out from CVS

I am building a cross platform product and one of the requirements is across windows(win32,AMD64 and IA61). The product as is relatively simple CLI but we have a separate build team who checks out the code from CVS and build in separate build environments. I am able to build succesfully(using Visual C++ 2005) in one platform(AMD machine). But once I check in the code, check out the build fails.
The cause of the build failure is because the include library paths are wrongly specified in the property sheets. Specifically the output file folder under the Linker in property pages are specified wrongly. So these libraries get built in a different folder from where the other projects are expecting them.
However along with the source I check in the .sln files (and later .vcproj files) also everytime. Morover if I open the .sln file in the folder where the build is not succeeding, there is no difference between the one where I could succesfully build(pre check in). In fact using windiff I could not see any difference between the two build folders (except some .ncb and cvs log files).
So any idea what is going on? Where does VC++ 2005 take the include directories take the output folder path from if not from .sln? Is CVS somehow interfering with the process? Anything else I could try out.
Thanks in advance.
Just to update the problem was resolved. The root cause is the .vcproj files were not getting checked in CVS!! This is where the individual project settings were stored(I was under the impression that this is done in .sln files).
I think the problem can be that after you have changed the settings in one build configuration (for example x86-Release) but forgotten to change them for another configuration (for example ia64-Debug), and when configuration changes, you have this problem.
Another thing that I would check on your place is project dependencies. If those are set in the right way VS will look for project output exactly where it is outputted, even when you change the output folder.
Do you have any binary files checked in as ASCII?
The round trip to and from CVS can corrupt binary files that are incorrectly marked as ASCII because CVS performs character processing on ASCII files (e.g. to give you the correct end of line codes for your OS). Corruption can occur even in an all Windows environment.
See the Binary section in the CVS FAQ for more information.

Xcode file system

I am using Xcode as part of my build for OS X, but since it is not the only IDE used, files may be added from the file system directly.
As far as I can tell, there are two ways of adding folders:
Folder reference picks up all the changes on the file system but does not register any of the files as sources.
Recursive copy allows for the files to be built but I need to constantly maintain the file structure
I am wondering if there was a way to setup Xcode to build all of the files that are a part of the folder reference or failing that, if there is a quick script to automagically fix file system discrepancies.
I came up with proof-of-concept solution that works, but will require some work to use in production. Basically, I set up a new "External Target", which compiles all source files in a given directory into a static library. Then the static library is linked into the Main Application.
In detail:
Create a directory (lets call it 'Code') inside your project directory and put some source code in it.
Create a Makefile in the Code directory to compile the source into a static library. Mine looks like this.*****
Create an External Target (lets call it 'ExternalCode') and point it to the Code directory where your source and Makefile reside.
Build the ExternalCode and create a reference to the compiled static library (ExternalCode.a) in the Products area of your project. Get Info on the reference and change the Path Type to "Relative to Built Product".
Make sure ExternalCode.a is in the "Link With Binary Libraries" section of your main target.
Add the ExternalCode target as a dependency of your main target
Add the Code directory to your "User Header Search Paths" of your main target.
Now when you drop some source files into 'Code', Xcode should recompile everything. I created a demo project as a proof of concept. To see it work in, copy B.h/m from the 'tmp' directory into the 'Codes' directory.
*Caveats: The Makefile I provided is oversimplified. If you want to use it in a real project, you'll need to spend some time getting all the build flags correct. You'll have to decide whether it's worth it to manually manage the build process instead of letting Xcode handle most of the details for you. And watch out for paths with whitespace in them; Make does not handle them very well.
Xcode's AppleScript dictionary has the nouns and verbs required to do these tasks. Assuming your other IDE's build scripts know what files are added/deleted, you could write very simple AppleScripts to act as the glue. For example a script could take a parameter specifying a file to add to the current open project in Xcode. Another script could take a parameter to remove a file from the current project. Then your other IDE could just call these scripts like any other command line tool in your build script.
I'm not aware of any built-in functionality to accomplish this. If you need it to be automatic, your best option may be to write a Folder Action AppleScript and attach it to your project folder.
In all likelihood it would be a rather difficult (and probably fairly brittle) solution, though.
It's not pretty, and I think it only solves half your problem but... If you recursively copy, then quit xcode. Then you delete the folders, and replace them with simlinks to the original folders, you at least have files that are seen as code, and they are in the same files as the other IDE is looking at... You still will need to manually add and remove files.
I sort of doubt that there's a better way to do this without some form of scripting (like folder actions) because xcode allows you to have multiple targets in one project, so it's not going to know that you want to automatically include all of the files in any particular target. So, you're going to have to manually add each file to the current target each time anyway...
One way to import another file from add/existing file:
and set your customization for new file that added .
see this

Resources