# compilation database file generation for GCC and IAR toolchains

**URL:** https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198
**Category:** Usage
**Tags:** os:windows
**Created:** [April 22, 2021, 11:39am UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198 "2021-04-22T11:39:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Krishna](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/71c47a/32.png) [@Krishna](https://discourse.cmake.org/u/Krishna)
#### Post date: [April 22, 2021, 11:39am UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198/1 "2021-04-22T11:39:23Z")

</div>

I’m generating a compilation database file **compilation\_commands.json** by setting **set(CMAKE\_EXPORT\_COMPILE\_COMMANDS ON)** in the cmake.

The compilation\_commands.json file was generating for both GCC & IAR toolchains. Now the issue is for IAR the included paths generating with double backward slashes. See below for example.

{  
“directory”: “D:\\iar-release”,  
“command”: "D:\\IAR\\Ver8\_50\_1\\arm\\bin\\iccarm.exe --silent D:AppStub.c -Itmh -  
I…\\…\\product\application -I…\\…\\shared\\common -I…\\…\\shared  
“file”: “D:\AppStub.c”  
}

whereas for GCC, it is with forwarding slash as expected.

Will it generate based on the toolchain?

Please help me in resolving.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 22, 2021, 3:46pm UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198/2 "2021-04-22T15:46:53Z")

</div>

Are the backslashes a problem? Aren’t the paths the same either way? Though it is odd that it differs based on toolchain…

---

<div class="post-metadata">

### Author: ![Krishna](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/71c47a/32.png) [@Krishna](https://discourse.cmake.org/u/Krishna)
#### Post date: [April 23, 2021, 10:48am UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198/3 "2021-04-23T10:48:23Z")

</div>

Hi Ben,

Thanks for the reply!

Actually, I’m parsing this JSON file to the cppcheck tool for static analysis. This tool is ignoring the included paths (-I…\…\product\application -I…\…\shared\common -I…\…\shared) with double backslashes.

Is there a way in CMake to generate compilation\_commands.json with included paths single forward slashes?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 23, 2021, 11:40am UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198/4 "2021-04-23T11:40:39Z")

</div>

It seems like a bug that it transforms in one case but not the other. Investigation as to the difference would be needed. Could you create a small, simple example project that shows the difference when configured with each toolchain?

---

<div class="post-metadata">

### Author: ![Krishna](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/71c47a/32.png) [@Krishna](https://discourse.cmake.org/u/Krishna)
#### Post date: [April 26, 2021, 11:21am UTC](https://discourse.cmake.org/t/compilation-database-file-generation-for-gcc-and-iar-toolchains/3198/5 "2021-04-26T11:21:56Z")

</div>

Hi Ben,

Cppcheck latest version accepting the paths even with double backslashes.

Thank you.
