views:

189

answers:

3

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.

+1  A: 

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

Please see this page for more information.

Brian R. Bondy
Does it mean i have to separate my project into two ?
Benoît
updated description
Brian R. Bondy
+1  A: 
  • 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?

dirkgently
No I am not. I'll look into what you're suggesting
Benoît
The tool is in-house (i can change its behaviour if necessary)
Benoît
+1  A: 

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.

greyfade
I am afraid not. There is a part of the project (some c++ files) which i do not want to change... CMake cannot dynamically modify the project, it can only be run from outside Visual Studio... Nice tool, though.
Benoît
I thought it might be useful because your tool could be modified to simply output a set() statement to a file, where your main CMakeLists.txt file could include() it. Then, when you run CMake, it spits out your updated project. It's only a little inconvenient to restart VS, IMO.
greyfade