<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 3/6/2010 8:04 PM, J Decker wrote:
<blockquote
 cite="mid:8596d02a1003061804w32ec9919j390551f17be6cd28@mail.gmail.com"
 type="cite">
  <pre wrap="">there is a foreach() operator...
  </pre>
</blockquote>
Well, thanks for trying, but what I actually want to know is how to add
something to all the current targets <i>automatically</i> - as in
without specifying them by hand, and how to get the compiler flags etc
of a particular target so that I can <i>generate</i> a custom command
that matches the given target.<br>
<br>
&nbsp;&nbsp;&nbsp; get_file_component(pchbase ${PrecompiledHeader} NAME_WE)<br>
&nbsp;&nbsp;&nbsp; get_file_component(pchpath ${PrecompiledHeader} PATH)<br>
<br>
<b>&nbsp;&nbsp;&nbsp; foreach ( target in LISTS CMAKE_TARGET_LIST )</b><br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set(pchname "${CMAKE_BINARY_DIR}/${pchbase}.${target}.h")<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get_target_properties(defines ${target} COMPILE_DEFINITIONS)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; get_target_properties(flags ${target} COMPILE_FLAGS)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; set_target_properties(${target} PROPERTIES COMPILE_FLAGS
"${flags} -include ${pchname} -Winvalid-pch")<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; add_custom_command(${target} PRE_BUILD COMMAND<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "ln -s ${pchname} ${PrecompiledHeader}" <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "g++ ${defines} ${flags} -o ${pchname}.gch ${pchname}")<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>
&nbsp;&nbsp;&nbsp; endforeach ()<br>
<br>
Marked in bold is the part I'm struggling with.<br>
<br>
- Oliver<br>
<br>
</body>
</html>