Disable precompiled header for single file

I am working on a project with many .cppfiles on vs2013and using a precompiled header for them. I use CMake to create my project.

But I have one .cfile (let it be called xyz.c) for which I want to disable the precompiled header.

I tried several methods, but if I include precompiled headers in the whole file .cpp, it will automatically be included for the file .c. This is what I tried:

set_source_files_properties (xyz.c
  PROPERTIES COMPILE_FLAGS /Y-xyz.c )

Assuming it is /Yuenabled for all files, I'm just trying to disable this option for xyz.c.

If anyone knows any method, please let me know.

+4
source share
1 answer

/Y-does not accept arguments. Try:

set_source_files_properties(xyz.c
  PROPERTIES COMPILE_FLAGS /Y-)

Alternatively, instead of using /Yufor all files and disable it only for your file .c, you can use the opposite approach and use /Yuonly for files .cpp. Given that your files .cppare listed in a variable SOURCES, and my_pch.hyour precompiled header:

set_source_files_properties(${SOURCES}
  PROPERTIES COMPILE_FLAGS /Yumy_pch.h)
+3
source

Source: https://habr.com/ru/post/1662398/


All Articles