[Cmake] ADD_CUSTOM_COMMAND and dependency checking

David Thompson dcthomp at sandia.gov
Tue, 17 Feb 2004 17:10:35 -0800


It sounds like one Makefile rule refers to Wrapper_wrap.c while the
other refers to the absolute path of Wrapper_wrap.c. The dependency and
the rule to build it must make the same reference (both use absolute or
both use relative filenames). At least, that's what's worked for me in
the past. Try

ADD_CUSTOM_COMMAND(     SOURCE ${SRC_NAME_ROOT}.i
                        OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${SRC_NAME_ROOT}_wrap.c
                        COMMAND swig
                        ARGS -python ${SRC_NAME_ROOT}.i
                        TARGET ${SRC_NAME_ROOT} )
You might need to be careful about the distinction between
CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR... swig should be
configured to write output files to the BINARY dir, not the source dir
(where Wrapper.i exists) since they will be different for out-of-source
builds.

> I know that I should have been able to figure this out, but I'm stupmed.
> I've got a custom command in CMakeLists.txt which makes an output file. 
> ccmake creates a reasonable-looking makefile, but then the actual build 
> process terminates because cmake.check_depends can't find the rule to 
> make the target created by my custom command. (This target IS in the 
> makefile, even!)
> 
> Here are the specifics:
> Using cmake 1.8.3 on Mac OS X 10.3
> 
> Here's the relevant bit of the CMakeLists.txt file:
> SET(SRC_NAME_ROOT Wrapper)
> ADD_CUSTOM_COMMAND(
> 			SOURCE ${SRC_NAME_ROOT}.i
> 			OUTPUTS ${SRC_NAME_ROOT}_wrap.c
> 			COMMAND swig
> 			ARGS -python ${SRC_NAME_ROOT}.i
> 			TARGET ${SRC_NAME_ROOT} )
> 
> The error that I get when I type make is:
> No rule to make target `/path/to/folder/Wrapper_wrap.c', needed by 
> `cmake.check_depends'.
> 
> This despite the fact that there IS the following rule in the generated 
> makefile:
> Wrapper_wrap.c:  Wrapper.i
>           at echo "Building Custom command Wrapper_wrap.c..."
>          swig -python Wrapper.i
> 
> I've tried all of the obvious tweaks to the ADD_CUSTOM_COMMAND (e.g. 
> ditching the SOURCE and/or TARGET directives, etc.)
> 
> Any suggestions on why I'm getting this error?
> 
> Thanks,
> 
> Zach Pincus
> 
> Department of Biochemistry and Program in Biomedical Informatics
> Stanford University School of Medicine
> 
> _______________________________________________
> Cmake mailing list
> Cmake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake