[cmake-developers] [CMake 0012628]: CMake uses variable called ${OUTPUT}, causes problems when user tries to use a variable called ${OUTPUT}

Mantis Bug Tracker mantis at public.kitware.com
Thu Dec 15 06:20:31 EST 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=12628 
====================================================================== 
Reported By:                Colin Powers
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12628
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-12-15 06:20 EST
Last Modified:              2011-12-15 06:20 EST
====================================================================== 
Summary:                    CMake uses variable called ${OUTPUT}, causes
problems when user tries to use a variable called ${OUTPUT}
Description: 
I just found one of our CMakeLists.txt with the following line:

ADD_CUSTOM_TARGET(policy ALL echo
                         DEPENDS ${OUTPUT}
)

Where ${OUTPUT} was populated in a for loop like this:

list(APPEND OUTPUT ${target})

The value of ${target} is not really important. It seems ${OUTPUT} was also
being manipulated by CMake, and we found that in one of the produced makefiles
(./policy/CMakeFiles/policy.dir/build.make) the following content was there
unexpectedly:

policy/CMakeFiles/policy: <build dir>/policy/Change\ Dir:\ <build
dir>/CMakeFiles/CMakeTmp

Run\ Build\ Command:/usr/bin/gmake\ "cmTryCompileExec/fast"
/usr/bin/gmake\ -f\ CMakeFiles/cmTryCompileExec.dir/build.make\
CMakeFiles/cmTryCompileExec.dir/build
gmake[1]:\ Entering\ directory\ `<build dir>/CMakeFiles/CMakeTmp'
/usr/local/bin/cmake\ -E\ cmake_progress_report\ <build
dir>/CMakeFiles/CMakeTmp/CMakeFiles\ 1
Building\ CXX\ object\ CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o
/usr/local/bin/c++\ \ \ \ \ -o\
CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o\ -c\ <build
dir>/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking\ CXX\ executable\ cmTryCompileExec
/usr/local/bin/cmake\ -E\ cmake_link_script\
CMakeFiles/cmTryCompileExec.dir/link.txt\ --verbose=1
/usr/local/bin/c++\ \ \ \ \ \ \ \ \
CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o\ \ -o\ cmTryCompileExec\
-rdynamic\ 
gmake[1]:\ Leaving\ directory\ `<build dir>/CMakeFiles/CMakeTmp'

I guess this is perhaps content that ends up in ./CMakeFiles/CMakeOutput.log?

In any case, ${OUTPUT} was perhaps not the best choice of variable name for us,
and I am able to solve the problem by doing something more sensible. However, is
it sensible for CMake to be using this variable name itself? Is this variable
name reserved and is that documented anywhere? I had a quick look around and
couldn't find anything. Searching for other instances of the problem was also
difficult, as you might expect when your keyword is "output".

For reference the actual error I was getting was on typing 'make': target
pattern contains no `%'

Steps to Reproduce: 
Try adding somewhere sensible in your CMakeLists.txt:

message("-- OUTPUT IS: ${OUTPUT}")

Observe that it is populated with various content.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-12-15 06:20 Colin Powers   New Issue                                    
======================================================================




More information about the cmake-developers mailing list