<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>How to calculate a value "on the fly" for use with gcc compiler option?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I've a problem converting one important feature of our old make-build-process to the new cmake-build-process.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">The problem:</FONT>
<BR><FONT SIZE=2 FACE="Arial">In our old build process, each object file was binary different from one build run to another.</FONT>
<BR><FONT SIZE=2 FACE="Arial">This problem was caused by gcc using randomly generated symbol names.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">The solution with make:</FONT>
<BR><FONT SIZE=2 FACE="Arial">We use gcc's option "-frandom-seed=<value>", which uses a given value as a starting point for it's random number generator.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">As every file shall have a unique random seed, we calculate the MD5 checksum of each source file "on the fly".</FONT>
<BR><FONT SIZE=2 FACE="Arial">This checksum is then used as a value for the option "-frandom-seed".</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Here's how the current compile rule in the old Makefile looks like:</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $(CC) -frandom-seed=<B>$(shell md5sum $< | sed 's/\(.*\) .*/\1/')</B> $(CCFLAGS) -c $< -o $@</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I tried to do this in cmake, but I only have this command:</FONT>
<BR><FONT SIZE=2 FACE="Arial">ADD_DEFINITIONS( </FONT>
<BR><FONT SIZE=2 FACE="Arial"> "-frandom-seed=$(shell md5sum $< | sed 's/\(.*\) .*/\1/')"</FONT>
<BR><FONT SIZE=2 FACE="Arial">)</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">But how can I determine the current filename and replace "$<" by the filename?</FONT>
<BR><FONT SIZE=2 FACE="Arial">How can this be made using cmake?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Best Regards,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Joerg</FONT>
</P>
</BODY>
</HTML>