Re: [CMake] Adding an individual define to each source file of a library

2018-08-24 Thread George PF
>> foreach(x IN LISTS mysrcs) >> message("at ${x}") >> set_property(SOURCE x APPEND PROPERTY COMPILE_DEFINITIONS >> "TEST1;TEST2;") > > almost there but you forgot to take value of 'x' > > set_property(SOURCE ${x} APPEND PROPERTY COMPILE_DEFINITIONS "TEST1;TEST2;") > > works fo

Re: [CMake] Adding an individual define to each source file of a library

2018-08-23 Thread Eric Noulard
Le jeu. 23 août 2018 à 19:18, George PF a écrit : > > > However, whatever I write into 'set_property()' - no APPEND, single > entry, > > > not quoted - does not end up > > > on the compiler command line. Is there a type mismatch which is > silently > > > ignored? > > > > > > > Or you are doing th

Re: [CMake] Adding an individual define to each source file of a library

2018-08-23 Thread George PF
> > However, whatever I write into 'set_property()' - no APPEND, single entry, > > not quoted - does not end up > > on the compiler command line. Is there a type mismatch which is silently > > ignored? > > > > Or you are doing this in a directory which is not the one where the target > is defined

Re: [CMake] Adding an individual define to each source file of a library

2018-08-23 Thread Eric Noulard
Le jeu. 23 août 2018 à 18:31, George PF a écrit : > Thank you for the precise pointers, I added to the same CMakeLists.txt: > > get_property(mysrcs TARGET mylib PROPERTY SOURCES) > > foreach(x IN LISTS mysrcs) > message("at ${x}") > set_property(SOURCE x APPEND PROPERTY CO

Re: [CMake] Adding an individual define to each source file of a library

2018-08-23 Thread George PF
Thank you for the precise pointers, I added to the same CMakeLists.txt: get_property(mysrcs TARGET mylib PROPERTY SOURCES) foreach(x IN LISTS mysrcs) message("at ${x}") set_property(SOURCE x APPEND PROPERTY COMPILE_DEFINITIONS "TEST1;TEST2;") #set_source_files_pr

Re: [CMake] Adding an individual define to each source file of a library

2018-08-23 Thread Eric Noulard
Le jeu. 23 août 2018 à 13:02, George PF a écrit : > Hello, > > following "modern cmake" conventions I want to create a library where > every single file is compiled with an individual define (-D_fileX_, > required for a macro which integrates code into every translation unit). > > So following th

[CMake] Adding an individual define to each source file of a library

2018-08-23 Thread George PF
Hello, following "modern cmake" conventions I want to create a library where every single file is compiled with an individual define (-D_fileX_, required for a macro which integrates code into every translation unit). So following this add_library(mylib SHARED file1.c file2.c) target_l