Skip to content

Commit

Permalink
README: document that sccache is incompatible with /Zi with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing authored and sylvestre committed Oct 26, 2021
1 parent 06303be commit 6256f4b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ To use sccache with cmake, provide the following command line arguments to cmake
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
```

To generate PDB files for debugging with MSVC, only the [`/Z7` option](https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-160) works with sccache; the PDB files generated with the `/Zi` and `/ZI` options cannot be cached. Note that CMake sets `/Zi` by default, so if you use CMake, you will need something like this in your CMakeLists.txt:

```
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
```

---

Build Requirements
Expand Down

0 comments on commit 6256f4b

Please sign in to comment.