Benoît
Benoît

Reputation: 16994

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 :

  1. Launch the tool (not needed if configuration file has been modified)
  2. Retrieve new list of C++ files to be compiled (ideally isolated in a folder inside the project)
  3. 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.

Upvotes: 0

Views: 479

Answers (3)

Brian R. Bondy
Brian R. Bondy

Reputation: 347216

I think what you should do is create a custom makefile and use that for builds.

Please see this page for more information.

Upvotes: 1

greyfade
greyfade

Reputation: 25647

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.

Upvotes: 1

dirkgently
dirkgently

Reputation: 111130

  • 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?

Upvotes: 1

Related Questions