I have irony-mode configured and I'm using it for a C++-project. The code is built using Make. I have a number of different make targets to build the code; test code, release code, unit test code etc. Each make target uses its own set of compilation flags and the unit test code is placed in a subdirectory. All this makes using one single compilation database for irony-mode less than ideal.
For each make target I have defined a corresponding make target that runs the build through Bear to generate a compilation database for the specific make target. Then I try to make irony-mode switch to using this newly generated compilation database by running the function
irony-cdb-json-select. It is documented as
Select CDB to use with a prompt. It is useful when you have several CDBs with the same project root.
But when I do
irony-cdb-menu nothing has changed, the compilation flags that should have been there are not there.
How do I force irony-mode to update the compilation database?
Using one Make target for release code and another for unit tests means a specific source file can be compiled using two different sets of compile flags. Unit tests makes use of mock objects which means in this context the list of includes (-I) might differ compared to compiling release code. So depending on if I work on release code or unit tests I think I need two different compilation databases.
The file compile_commands.json generated by Bear contains an entry for each source file. Does irony-mode read each entry and use the specific settings for one specific source file? Or does irony-mode read the first entry in compile_commands.json and applies these settings to all source files in the project? I could create one compile_commands.json by appending output from release builds and unit test builds so that the resulting compile_commands.json would have entries with different sets of include flags (-I) without duplicates for the same file of course. Is irony-mode sensitive to this?