[CMake] EXEC_PROGRAM question

Brad King brad.king at kitware.com
Fri Mar 25 11:30:05 EST 2005


Doug Henry wrote:
> I am doing the following command in my top level CMakeLists.txt file:
> 
> EXEC_PROGRAM(
>     date
>     ARGS +%y%j
>     OUTPUT_VARIABLE DATEVAR)
> 
> ADD_DEFINITIONS(-DDATESTR=${DATEVAR})
> 
> 
> The thing I don't understand is that DATEVAR is only defined in the
> top-level makefile.  It does not appear in other subdirs/projects. 
> How do I get the DATEVAR variable to be cached and useable in a more
> global way (e.g. like traditional SET statements)?

I've just added this FAQ entry:

http://www.cmake.org/Wiki/CMake_FAQ#I_use_EXEC_PROGRAM_but_the_result_is_not_set_in_subdirectories.__Why.3F

-Brad


More information about the CMake mailing list