[CMake] add_custom_target: always built during "make" and "make install"

Tyler Roscoe tyler at cryptio.net
Mon Nov 2 10:09:53 EST 2009


On Mon, Nov 02, 2009 at 10:48:49PM +0800, Romain CHANU wrote:
> # Add a custom target to manage dependencies
> add_custom_target(cxx_xml_mapping DEPENDS xml_mapping)
> 
> add_custom_command(
>   OUTPUT cxx_xml_mapping
>   COMMAND ${XSD_EXECUTABLE} ARGS ${XSD_ARGS}
> ${CMAKE_CURRENT_SOURCE_DIR}/*.xsd
>   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.xsd
>   COMMENT "Generating C++ / XML mapping files")

Not sure if this is your problem but:

1. I don't think that verbiage in the docs about custom commands
*always* being out-of-date applies to makefile generators. I've only
seen that behavior in Visual Studio.

2. Your custom_command needs to have an OUTPUT that corresponds to the
DEPENDS of your custom_target. Here you have two different names,
xml_mapping and cxx_xml_mapping.

3. I'm not sure your custom_command can DEPEND on *.xsd. How is CMake
supposed to know whether *.xsd refers to 4 files or 40 files, and thus
how can it know when that set of files is up-to-date or not?

hth,
tyler


More information about the CMake mailing list