[Cmake] Make clean

Gerhard Esterhuizen gerhard at stonethree . com
Thu, 27 Nov 2003 11:11:23 +0200


Brad King wrote:

>>>http://www . cmake . org/cgi-bin/cmakefaq . cgi?req=all#5 . 8
>>
>>I read that and it makes alot of sense. Unfortunately I am now
>>struggling with the out-of-source build. I left my ADD_CUSTOM_TARGET
>>line unchanged as
>>
>>ADD_CUSTOM_TARGET(api-docs ALL doxygen api-docs.doxy DEPENDS api-docs.doxy)
>>
>>and do "cmake _sourcedir_" from the build directory, where "_sourcedir_"
>>is the relative path to the source directory from the build directory.
>>When I do "make" it complains with a "No rule to make target
>>'api-docs.doxy'" (which is the dependancy). What is the correct way of
>>specifying the dependancy path so that it is independant of the build
>>directory or is this impossible ?
> 
> 
> You need to use a combination of ADD_CUSTOM_TARGET and ADD_CUSTOM_COMMAND.
> Use
> 
>   cmake --help ADD_CUSTOM_TARGET
> 
> and
> 
>   cmake --help ADD_CUSTOM_COMMAND
> 
> to read about the commands.  Basically you should use ADD_CUSTOM_TARGET to
> add a driver target with a DEPENDS that points at the output of a rule
> specified by ADD_CUSTOM_COMMAND that actually runs doxygen.

I saw the CMAKE_CURRENT_SOURCE in the Makefile and prefixed all
references to my dependency with it. This seems to work in principle and
I had success using ADD_CUSTOM_TARGET alone and in conjunction with
ADD_CUSTOM_COMMAND (as recommended).

A few comments and questions:

1. Although I understand the motivation for out-of-source builds, all
programs (e.g. Doxygen) doesn't support it that well (in that it assumes
the presence of certain file in its CWD and therefore doesn't benefit
from the use of variables such as CMAKE_CURRENT_SOURCE).

2. IF I refer to CMAKE_CURRENT_SOURCE in the MAIN_DEPENDENCY part of an
ADD_CUSTOM_COMMAND, i.e.

ADD_CUSTOM_COMMAND(OUTPUT api-docs-cmd
	           COMMAND doxygen
		   ARGS $(CMAKE_CURRENT_SOURCE)/api-docs.doxy
		   MAIN_DEPENDENCY $(CMAKE_CURRENT_SOURCE)/api-docs.doxy)

CMake errors with "CMake Error: CMake failed to properly look up
cmSourceFile: $(CMAKE_CURRENT_SOURCE)/api-docs.doxy". However,
specifying it as part of DEPENDENCIES works fine:

ADD_CUSTOM_COMMAND(... bla ...
		   DEPENDENCIES $(CMAKE_CURRENT_SOURCE)/api-docs.doxy)

I could not find anything in the docs (help or PDF) that explains this.

3. Why should I use ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET when the
following line suffices ?

ADD_CUSTOM_TARGET(api-docs ALL doxygen
$(CMAKE_CURRENT_SOURCE)/api-docs.doxy DEPENDS
$(CMAKE_CURRENT_SOURCE)/api-docs.doxy)

4. Where do I find a list of variables that CMake uses (e.g.
CMAKE_CURRENT_SOURCE) ?

Sorry for all the questions and thanks for the patient replies - I'm new
to CMake and still struggling to find my feet.

Regards,
	
	Gerhard.

-- 

gerhard esterhuizen <gerhard at stonethree . com>
project engineer

stone three signal processing (pty) ltd
http://www . stonethree . com
+27 21 851 3123 (phone)
+27 21 851 3127 (fax)