[CMake] How to calculate a value "on the fly" for use with gcc compiler option?
Jörg Förstner
Joerg.Foerstner at ubidyne.com
Fri Jul 17 14:32:38 EDT 2009
Hi,
I've a problem converting one important feature of our old make-build-process to the new cmake-build-process.
The problem:
In our old build process, each object file was binary different from one build run to another.
This problem was caused by gcc using randomly generated symbol names.
The solution with make:
We use gcc's option "-frandom-seed=<value>", which uses a given value as a starting point for it's random number generator.
As every file shall have a unique random seed, we calculate the MD5 checksum of each source file "on the fly".
This checksum is then used as a value for the option "-frandom-seed".
Here's how the current compile rule in the old Makefile looks like:
$(CC) -frandom-seed=$(shell md5sum $< | sed 's/\(.*\) .*/\1/') $(CCFLAGS) -c $< -o $@
I tried to do this in cmake, but I only have this command:
ADD_DEFINITIONS(
"-frandom-seed=$(shell md5sum $< | sed 's/\(.*\) .*/\1/')"
)
But how can I determine the current filename and replace "$<" by the filename?
How can this be made using cmake?
Best Regards,
Joerg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090717/554e51fd/attachment.htm>
More information about the CMake
mailing list