[CMake] Compile flags for a single file
The Novice Coder
cmake at randmsystems.com
Mon Apr 18 16:09:22 EDT 2011
On Mon, 18 Apr 2011 21:52:31 +0200, Alexander Neundorf wrote:
> On Monday 18 April 2011, The Novice Coder wrote:
>> I've been trying most things I can think of, but have been unable
>> to
>> come up with a solution.. the basic gist is I need to change the
>> compile
>> flags for a SINGLE file within a project. Specifically, disabling
>> all
>> compile warnings for that file.
>>
>> add_definitions() seems to effect the whole project, so that's not
>> helping..
>>
>> Also couldn't use set_property() to do it either. (I could have
>> been
>> using it wrong).
>
> set_source_files_properties() should be able to set COMPILE_FLAGS for
> single
> files.
> * you might also write a file which only does some #define/#undef's
> and then
> includes the file in question ?
> * you might build a static library consisting only of that one file,
> if
> necessary in an own subdirectory (which has only the CMakeLists.txt
> with
> add_library(foo STATIC ../the_file.c), basically)
>
> Alex
Thank you very much! That got me on the right path. If anyone else
has the same issue, the final code was:
if(MSVC)
set_source_files_properties( ${contrib_db_cpp} PROPERTIES
COMPILE_FLAGS " /W0 " )
endif(MSVC)
More information about the CMake
mailing list