<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le jeu. 23 août 2018 à 19:18, George PF <<a href="mailto:george.p.f@mail.com">george.p.f@mail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> > However, whatever I write into 'set_property()' - no APPEND, single entry,<br>
> > not quoted - does not end up<br>
> > on the compiler command line. Is there a type mismatch which is silently<br>
> > ignored?<br>
> ><br>
> <br>
> Or you are doing this in a directory which is not the one where the target<br>
> is defined and from the doc:<br>
> $ cmake --help-command set_property<br>
> <br>
> ...<br>
> ``SOURCE``<br>
> Scope may name zero or more source files. Note that source<br>
> file properties are visible only to targets added in the same<br>
> directory (CMakeLists.txt).<br>
> <br>
> ...<br>
<br>
This is all in the same directory, full setup and test:<br>
<br>
% cmake --version<br>
cmake version 3.12.0 [..]<br>
% mkdir mylib && cd mylib<br>
mylib% touch file1.c file2.c<br>
mylib% cat > CMakeLists.txt<br>
<br>
cmake_minimum_required(VERSION 3.12)<br>
<br>
add_library(mylib SHARED file1.c file2.c)<br>
<br>
get_property(mysrcs TARGET mylib PROPERTY SOURCES)<br>
foreach(x IN LISTS mysrcs)<br>
message("at ${x}")<br>
set_property(SOURCE x APPEND PROPERTY COMPILE_DEFINITIONS "TEST1;TEST2;")<br></blockquote><div><br></div><div>almost there but you forgot to take value of 'x'</div><div><br></div><div>set_property(SOURCE ${x} APPEND PROPERTY COMPILE_DEFINITIONS "TEST1;TEST2;")</div><div><div><br></div><div>works for me.</div><div><br></div><br class="gmail-Apple-interchange-newline"></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
endforeach(x)<br>
# ^D<br>
<br>
mylib% mkdir build && cd build && cmake ..<br>
[..]<br>
at file1.c<br>
at file2.c<br>
-- Configuring done<br>
[..]<br>
mylibs/build% grep -r TEST1 . || echo no TEST1<br>
no TEST1<br>
<br>
and 'make VERBOSE=1' also shows no extra -DTEST1 compiler arguments.<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>