[CMake] cmake 2.6: add_custom_command - add_custom_target

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Jan 1 01:32:35 EST 2010


On 2010-01-01 01:57+0100 Spicy wrote:

> Hi cmakers,
>
> I decided to start a new project using cmake. While I got a lot of
> things going quickly, some things are taking me to despair. The current
> issue has a couple of web hits, but either I misunderstand something
> critical or cmake 2.6 (as of current Debian Lenny) is broken:
>
> --8<-------CMakeLists.txt------------
> cmake_minimum_required(VERSION 2.6)
> project(test)
> add_custom_command(
> OUTPUT bla.txt
> COMMAND touch bla.txt
> )
> add_custom_target(bla DEPENDS bla.txt)
> --8<-------CMakeLists.txt------------

> Any ideas what is going wrong here?

Yes.  replace bla.txt everywhere by ${CMAKE_CURRENT_BINARY_DIR}/bla.txt, and
all will be well. I have just checked that works, and also verified the
problem you found if you use bla.txt instead.

It's possible you might be able to also solve the problem using
WORKING_DIRECTORY, but I am not sure about that, and I know
${CMAKE_CURRENT_BINARY_DIR}/bla.txt (i.e., being specific about the
path) always does work.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list