[CMake] Passing variable to program

Tyler Roscoe tyler at cryptio.net
Fri Apr 10 11:26:03 EDT 2009


On Fri, Apr 10, 2009 at 10:42:34AM -0400, John Dey wrote:
> I have converted a program from using make to cmake.  I needed to make  
> a change to the main.cc program to get it to work.  I am going back to  
> see if I can get it to work without making the change.  main.cc has a  
> statement something to the effect of "fprintf(stdin, "%s\n",  
> VERSION);" and the Makefile contains the statement "VERSION = 0.8.2".   
> How can I set the variable VERSION in CMakeLists.txt?  Any direction  
> on setting the variable would be appreciated.  Thanks.

There are a lot of ways to do this. I don't what's best but off the top
of my head:

- use a definition (-DVERSION=0.8.2)

- use a header file, possibly with CONFIGURE_FILE

tyler


More information about the CMake mailing list