Reputation: 91
I am working on a project with many .cpp
files on vs2013
, and using a precompiled header for them. I am using CMake to build my project.
But I have one .c
file (let's call it xyz.c
) for which I want to disable precompiled header.
I tried several methods, but if I enable precompiled headers to all .cpp
file, it automatically turns on for the .c
file as well. This is what I tried:
set_source_files_properties (xyz.c
PROPERTIES COMPILE_FLAGS /Y-xyz.c )
Assuming that /Yu
is on for all files, I just try to turn off this option for xyz.c
.
If any one knows any method, please let me know.
Upvotes: 8
Views: 5048
Reputation: 5233
Starting from cmake 3.16 setting /Y-
compiler option will not work. Correct way to disable precompiled headers for individual file is like this:
set_source_files_properties(non-pch.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
Documentation: https://cmake.org/cmake/help/v3.16/prop_sf/SKIP_PRECOMPILE_HEADERS.html
(Not so useful anyway)
Upvotes: 12
Reputation: 15976
/Y-
doesn't take arguments. Try:
set_source_files_properties(xyz.c
PROPERTIES COMPILE_FLAGS /Y-)
Alternatively, instead of using /Yu
on all files and disable it only for your .c
file, you can use the opposite approach and only use /Yu
for the .cpp
files. Given your .cpp
files are listed in a variable SOURCES
and my_pch.h
is your precompiled header:
set_source_files_properties(${SOURCES}
PROPERTIES COMPILE_FLAGS /Yumy_pch.h)
Upvotes: 4