The set_target_properties() of COMPILE_FLAGS allows you to add the -DDEBUG just for the mylibd target (although you should really use the COMPILE_DEFINITIONS property for preprocessor symbols).  Why do you need to mess with the &lt;FLAGS&gt; part of the compile command ?  Can&#39;t you add extra compiler command flags like this:<br>
<br>    set(CMAKE_C_FLAGS &quot;${CMAKE_C_FLAGS} -myFlag&quot;)<br><br>or even replace the default flags entirely like this:<br><br>    set(CMAKE_C_FLAGS &quot;-foo&quot;)<br><br>I&#39;m not sure what you are trying to achieve.  Can you explain in a bit more detail ?<br>
<br>--<br>Glenn<br><br><div class="gmail_quote">On 8 September 2011 04:35, David Dunkle <span dir="ltr">&lt;<a href="mailto:ddunkle@arxan.com">ddunkle@arxan.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thanks, Glenn. That almost works. However, the values of &lt;FLAGS&gt; is hard to construct in this case. It looks something like this:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">add_library(mylib, STATIC, ${files})<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;color:#1F497D">set_target_properties(mylib<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">                                      PROPERTIES PREFIX “”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">                                      COMPILE_FLAGS ${target_compiler_flags})<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">add_library(mylibd, STATIC, ${files})<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">set_target_properties(mylibd,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">                                      PROPERTIES PREFIX “”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">                                      COMPILE_FLAGS “-DDEBUG ${target_compiler_flags}”)<u></u><u></u></span></p><div class="im"><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">set(CMAKE_C_COMPILE_OBJECT &quot;${target_compiler} -c &lt;FLAGS&gt; -o &lt;OBJECT&gt;&quot;)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I can replace &lt;FLAGS&gt; with ${target_compiler_flags} yielding this:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">set(CMAKE_C_COMPILE_OBJECT “${target_compiler} –c ${target_compiler_flags} –o &lt;OBJECT&gt;”)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">but then the –DDEBUG is missing for the build of mylibd. I guess both mylibd and mylib use CMAKE_C_COMPILE_OBJECT and I need a way to pass the –DDEBUG to the compile of one and not the other.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">-David<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt"> Glenn Coombs [mailto:<a href="mailto:glenn.coombs@gmail.com" target="_blank">glenn.coombs@gmail.com</a>] <br><b>Sent:</b> Wednesday, September 07, 2011 4:19 AM<br>
<b>To:</b> David Cole<br><b>Cc:</b> David Dunkle; <a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a><br><b>Subject:</b> Re: [CMake] novice question: modification of FLAGS rule variable?<u></u><u></u></span></p>
<div><div></div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt">What you can do however is set the variable which uses the &lt;FLAGS&gt; definition, i.e. CMAKE_C_COMPILE_OBJECT in your example.  I have a CMakeLists.txt file where I override the default assembler flags:<br>
<br>set(CMAKE_ASM-ATT_COMPILE_OBJECT &quot;&lt;CMAKE_ASM-ATT_COMPILER&gt; ${ASM_SYS_FLAGS} -o &lt;OBJECT&gt; &lt;SOURCE&gt;&quot;)<br><br>to use what is set in my ASM_SYS_FLAGS variable instead of the default &lt;FLAGS&gt; one.  I&#39;m not sure but I think you are supposed to set these sort of variables early on in a CMakeList.txt before the project() or enable_language() commands.  Also, I think that later changes to the ASM_SYS_FLAGS variable are ignored.<br>
<br>--<br>Glenn<u></u><u></u></p><div><p class="MsoNormal">On 5 September 2011 19:53, David Cole &lt;<a href="mailto:david.cole@kitware.com" target="_blank">david.cole@kitware.com</a>&gt; wrote:<u></u><u></u></p><div><div>
<p class="MsoNormal">On Mon, Sep 5, 2011 at 1:31 PM, David Dunkle &lt;<a href="mailto:ddunkle@arxan.com" target="_blank">ddunkle@arxan.com</a>&gt; wrote:<br>&gt; Is it possible to read and to set a property/rule variable like &lt;FLAGS&gt;?<br>
&gt; What syntax would I use to do that? I mean &lt;FLAGS&gt; as it, for example,<br>&gt; appears here:<br>&gt;<br>&gt;<br>&gt;<br>&gt; set(CMAKE_C_COMPILE_OBJECT &quot;${target_compiler} -c &lt;FLAGS&gt; -o &lt;OBJECT&gt;&quot;)<br>
&gt;<br>&gt;<br>&gt;<br>&gt; For example can I do something like this (this is pseudo code)?<br>&gt;<br>&gt;<br>&gt;<br>&gt; #read<br>&gt;<br>&gt; set(MY_FLAGS,  ${&lt;FLAGS&gt;} );<br>&gt;<br>&gt;<br>&gt;<br>&gt; …<br>&gt;<br>
&gt;<br>&gt;<br>&gt; #set<br>&gt;<br>&gt; set(&lt;FLAGS&gt;, ${MY_FLAGS});<br>&gt;<br>&gt;<br>&gt;<br>&gt; In the documentation, here:<br>&gt;<br>&gt;<br>&gt;<br>&gt; <a href="http://cmake.org/Wiki/CMake_Useful_Variables#Expansion_Rules" target="_blank">http://cmake.org/Wiki/CMake_Useful_Variables#Expansion_Rules</a><br>
&gt;<br>&gt;<br>&gt;<br>&gt; it hints at this being possible but doesn’t explain, at least not so that I<br>&gt; understand.<br>&gt;<br>&gt;<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; -David<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>
&gt;<u></u><u></u></p></div></div><p class="MsoNormal">&gt; _______________________________________________<br>&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt;<br>&gt; Please keep messages on-topic and check the CMake FAQ at:<br>&gt; <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>&gt;<br><br>The wiki page is simply misleading. You cannot set those from the<br>
CMake language. CMake decides on their values in internal code, and<br>then substitutes appropriately when generating make files or<br>solution/project files for the build system.<br><br>You can set things the &quot;CMAKE_CXX_FLAGS&quot; which eventually get<br>
translated into the substitution that CMake performs, but you cannot<br>alter &quot;&lt;FLAGS&gt;&quot; in the rules variables.<br><br><br>HTH,<br>David<br>_______________________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p>
</div></div></div></div></blockquote></div><br>