[CMake] Passing Macro Arguments to "configure_file"

Michael Jackson mike.jackson at bluequartz.net
Wed Feb 4 09:04:22 EST 2009


Not sure what I am doing wrong but here is my problem.
   I have a macro that takes a few arguments. Within the macro I am  
calling "configure_file" and in the file that gets configured I am  
using the values of the arguments. Unfortunately after the file is  
configured during cmake time the values are blank. Here is a concise  
test case.


#---- CMakeLists.txt file Begin
cmake_minimum_required(VERSION 2.6)
macro(vartest variable)
   message(STATUS "----------------------------------")
   message(STATUS "variable: ${variable}")
   SET (Test_Variable "${variable}/Test_Output.cmake")
   CONFIGURE_FILE("Test.txt.in" "Test.txt" @ONLY IMMEDIATE)
endmacro(vartest variable)
set (target "myTarget")
vartest(${target})
#---- CMakeLists.txt file End

# ---- Test.txt.in Begin
variable = @variable@
Test_Variable = @Test_Variable@
# ---- Test. txt.in End

The output I get from Cmake is:
509:[mjackson at Shepard-2:Build]$ cmake ../
-- ----------------------------------
-- variable: myTarget
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mjackson/Desktop/Test/Build


and the txt file looks like this:
variable =
Test_Variable = myTarget/Test_Output.cmake

Is this a bug or something I am doing wrong or am I just not  
understanding something basic about macros. (Probably the "dumb"  
part.. )

Thanks for any help
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio





More information about the CMake mailing list