[CMake] Source file specific properties

Alexander Neundorf a.neundorf-work at gmx.net
Tue Oct 11 15:16:39 EDT 2011


On Monday 10 October 2011, Robert Dailey wrote:
> I'm using set_source_files_properties() to add COMPILE_DEFINITIONS to a
> single source file. Are these definitions appended to those added via
> target-specific defines, or do they completely replace the existing ones? I
> need them to append, which is why I ask.

They are appended.
And you can simply try that out quickly:

cmake_minimum_required(VERSION 2.8)

set_source_files_properties(hello.c PROPERTIES COMPILE_FLAGS -DFOO)

add_executable(hello main.c hello.c)


That's all you need for testing, and two source files:

int hello(void) { return 17; }

and a main.c:

#include <stdio.h>
extern int hello(void);

int main()
{
  printf("hello: %d\n", hello());
  return 0;
}

Alex


More information about the CMake mailing list