[CMake] Bug or misusage ???
Philippe Poilbarbe
Philippe.Poilbarbe at cls.fr
Tue Mar 7 10:30:40 EST 2006
Brad King a écrit :
> ...
> ADD_CUSTOM_TARGET is meant to add a new top-level target (like
> ADD_LIBRARY or ADD_EXECUTABLE) in which build commands with
> dependencies are evaluated. Note this sentence in the command's
> documentation: "Adds a target with the given name that executes the
> given commands every time the target is built."
>
> You should use ADD_CUSTOM_COMMAND within the target:
>
> ADD_CUSTOM_COMMAND(
> OUTPUT gshhs_f.b
> COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/UnzipFile.pl
> ${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip gshhs_f.b
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip
> )
> ADD_CUSTOM_TARGET(extract_gshhs ALL DEPENDS gshhs_f.b)
>
> -Brad
Yes, I did not correctly read the description of the command; shame on me...
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:
data/gshhs_f.b:
@echo "Generating gshhs_f.b"
cd /home/su_php/dev2/BRAT/data && UnzipFile.pl gshhs_data_files.zip
gshhs_f.b
extract_gshhs: data/CMakeFiles/extract_gshhs.dir/build.make
# Convenience name for target.
data/CMakeFiles/extract_gshhs.dir/build: extract_gshhs
As it is not exactly what I wrote, there is the whole CMakeLists.txt
file at end, maybe I did something else wrong but I can't state what.
Thanks again for the answers.
Philippe.
<INCLUDE>
# $Id: CMakeLists.txt,v 1.4 2006/03/06 15:35:50 ppoilbarbe Exp $
# $Name: $
SET(BRATHL_DEFDATADIR "${CMAKE_INSTALL_PREFIX}/share/brathl" CACHE
INTERNAL "Default data dir")
SET(BRATHL_UNITFILE "brathl_units.dat" CACHE INTERNAL "Units file")
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)
EXPAND_GSHHS(c)
EXPAND_GSHHS(f)
EXPAND_GSHHS(h)
EXPAND_GSHHS(i)
EXPAND_GSHHS(l)
ADD_CUSTOM_TARGET(build_data_files ALL DEPENDS @TO_CLEAN@)
# 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)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"${TO_CLEAN}")
</INCLUDE>
More information about the CMake
mailing list