[CMake] Bug or misusage ???

Brad King brad.king at kitware.com
Tue Mar 7 10:48:35 EST 2006


Philippe Poilbarbe wrote:
> But now as I do it correctly :), the target "extract_gshhs" (I gave
> another name in actual file) has no dependency whatever I put
> after DEPENDS or by mean of ADD_DEPENDENCIES
> command the only dependency generated in build.make is
> for build.make itself. The other targets like gshhs_f.b are
> correct but not connected to any other:
[snip]
> ADD_CUSTOM_COMMAND(
>        OUTPUT  ${BRATHL_UNITFILE}
>        COMMAND BuildBrathlUnitFile.pl "${UDUNITS_DAT_FILE}" 
> ${BRATHL_UNITFILE}
>        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/BuildBrathlUnitFile.pl 
> "${UDUNITS_DAT_FILE}"
>        COMMENT "Unit file specific to BRATHL")
> INSTALL_FILES(/share/brathl FILES ${BRATHL_UNITFILE})
> SET(TO_CLEAN ${BRATHL_UNITFILE})
> 
> MACRO (EXPAND_GSHHS PRECISION)
>  SET(EXTRACTED_FILE "gshhs_${PRECISION}.b")
>  ADD_CUSTOM_COMMAND(
>        OUTPUT  ${EXTRACTED_FILE}
>        COMMAND UnzipFile.pl gshhs_data_files.zip ${EXTRACTED_FILE}
>        DEPENDS gshhs_data_files.zip)
>  INSTALL_FILES(/share/brathl FILES ${EXTRACTED_FILE})
>  SET(TO_CLEAN @TO_CLEAN@ ${EXTRACTED_FILE})
> ENDMACRO (EXPAND_GSHHS)

Use this to build up the dependency list:

SET(TO_CLEAN ${TO_CLEAN} ${EXTRACTED_FILE})

> ADD_CUSTOM_TARGET(build_data_files ALL DEPENDS @TO_CLEAN@)

and this to reference it:

ADD_CUSTOM_TARGET(build_data_files ALL DEPENDS ${TO_CLEAN})

The @ syntax is meant only for use in the input files to CONFIGURE_FILE. 
  It was accidentally supported in CMake code previously but is no 
longer reliable.

> # This line has nothing to do with actual make file it is just
> # for testproblem with CMake
> ADD_DEPENDENCIES(build_data_files ${CMAKE_CURRENT_SOURCE_DIR}/nothing 
> ${CMAKE_CURRENT_SOURCE_DIR}/existing just_to_see)

This will do nothing unless there are other top-level targets called 
"just_to_see", etc.  Again, see the command's documentation (which is 
much clearer in CMake 2.2 than previously).

> SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES 
> "${TO_CLEAN}")

If you are using CMake 2.2 or above the output files of custom commands 
are automatically included in the list to be cleaned.

-Brad


More information about the CMake mailing list