larsch / cmake-precompiled-header

Visual Studio and GCC precompiled header macro for CMake
160 stars 42 forks source link

Avoiding using the same pre-compiled header in multiple projects/targets #26

Open Gazoo101 opened 1 year ago

Gazoo101 commented 1 year ago

As noted in this CMake script's caveats:

  • Its not currently possible to use the same precompiled-header in more than a single target in the same directory (No way to set the source file properties differently for each target).

However, I'm wondering if anyone has found a way to re-direct a secondary projects awareness of the cxx_stdafx.pch file this CMake script creates? I share source code across two projects in a single Visual Studio solution, and I get errors related to the generated pre-compiled header file, despite the secondary project specifically set to not use pre-compiled headers.

My functional, but clumsy, work-around is to duplicate the shared source so each project files are entirely separate. Has anyone else had to deal with this issue...?