Compile auto generated files without adding them to vcxproj - c++

I've been trying to find a solution to my question using several methods, however with no luck at all.
The problem I have is that I want my Visual Studio 2015 C++ project (.vcxproj) to automatically include auto generated cpp files (from prebuild event) in the compilation process.
So far the main suggestion I found is to add files to my project that match the names of the auto generated files. However, this is not a scalable/reliable solution because new files can be generated depending on the input, which means I have to manually add newly generated files.
I've tried using MSBUILD targets based on the answer to this question, however that does not appear to work.
Is there any possible way to auto generate CPPs and have the project compile them without having to add them to the project?

Related

Automatically including source files into Visual Studio 15

Overview:
I am wanting to allow visual studio 15 to automatically add an existing source file after I generate them.
Full explanation:
I am currently generating a lot of new .h and .cpp files with other tools outside of the IDE using bat scripts and such but needing to use them within the IDE to integrate with the project. As such I would be great if there was a a way to allow VS to add these source files automatically after they are generated without having to add them manually.
The files are always generated into the same given folder path if that helps.
You could generate the project with a CMake script. When you run your batch file, you could have it re-invoke CMake to update the project with the new sources. If you are generating files, especially if you can't predict the names in advance, you will likely want to use the CMake's file(GLOB ...) command.

auto compile generated visual studio files without adding to project

I created a project in VS2013 that generates C++ source files, and I want it to also compile the generated files to a static-lib without having to add the generated files to the project.
Ideally I want something like a custom build command that compiles everything that resides in the directory holding the generated files, but works inside VS and is triggered anytime the project regenerates the files.

Automatically add files to be compiled in visual studio

I am using Visual Studio 2010 to build an application in C++. I have a custom build event which creates additional headers and source files in a separate directory. How can I tell Visual Studio to include those generated files in its build queue. I don't necessarily need to add them to the project but I need to compile them like they are part of the project.
If the names of the files don't change, create a folder(filter) called generated and add those files to this folder(filter). If they don't exist VS won't complain when compiling, if they exist they will be included in the build.
I use this scheme when i have to use generated files.
I don't think it's possible (unless there's an add-on for that or something). But what you could do is to generate all those files and then add them to the project. After that in the custom build event specify them as outputs. That way VS will not try to build them before they are generated and will not complain that they are missing.

Source directories in Visual Studio 2010

I am using OF in my project and I want to use some add-ons but I have to add .cpp files to my project in order to compile them. I don't like it. Is there any option so I could specify a folder to scan for source files and compile every .cpp file it finds?
I thought it might be Source Directories in VC++ Directories section but it didn't work. Then I don't really get what it does.
If you want to compile sources using Visual Studio, you will have to add them to your project.
There is nothing wrong about adding external sources to your project in a nice filter.
You can also create a makefile to be used by Visual Studio which will list sources you need.
I'm not aware of an option that does what you ask for in VS. The Source directories configuration is used for locating source files that go along with libraries that you are using in your project. This way you can use the library in its binary format without the need to recompile it every time you rebuild your project, but you can also step into its code while debugging.

Can the list of C++ files in a Visual Studio project be dynamically filled?

I have a tool that generates most (but not all) files that need to be compiled in Visual Studio. The tool reads a configuration file and generates c++ files afterwards. This list can differ from one call to another when the configuration is altered.
I am wondering whether it would be possible to adapt the compiling process to my needs, which would be :
Launch the tool (not needed if configuration file has been modified)
Retrieve new list of C++ files to be compiled (ideally isolated in a folder inside the project)
Compile C++ files
EDIT: Having to close Visual Studio for this process to work is a no-go for me. The idea would be to have cpp files dynamically added as the first step of the compilation process.
Use a pre-build step to run your tool.
Also, create a file containing the list of includes and sources
This file name should be fixed (so that you don't have to change project properties or the vcproj file) -- add it to the project. E.g:
Project Properties > Command Line > Additional Options > #headerListingFile
You are not trying to integrate lex/yacc output with VS, are you?
Would CMake help? It's an automated project manager that generates Makefiles and VS projects for projects you define. Just add a source file, re-run CMake and you're done.
I think what you should do is create a custom makefile and use that for builds.
Please see this page for more information.