[Cmake] custom target dependencies (readable version)
Alexandre Laoubi
alexandre . laoubi at thales-is . com
Tue, 24 Jun 2003 16:40:30 +0200
Hi,
after reading the manual, the faq and some cmake digests I decide to submit
this certainly quite simple problem : a custom target dependency on the main
target.
I need that some .h and .c of my projet to be generated. They should be
placed
in "inc" and "src" directories of "basis". They are created in
"genextension" directory
by the "EOgenext" executable. They depend of a descriptive file
"EXTFILE_STD.TXT"
placed also in "genextension" dir.
Thus, my basis CMakeList.txt file contains the following statements :
ADD_CUSTOM_TARGET(updateEOglext ALL)
SET(EXTFILE ${EO_SOURCE_DIR}/genextension/EXTFILE_STD.TXT)
ADD_CUSTOM_COMMAND(
COMMAND ${EO_BINARY_DIR}/genextension/EOgenext
ARGS -i EXTFILE_STD.TXT
TARGET updateEOglext
DEPENDS ${EXTFILE}
)
ADD_CUSTOM_COMMAND(COMMAND cp ARGS EOglext.h ${EO_SOURCE_DIR}/basis/inc
TARGET updateEOglext )
ADD_CUSTOM_COMMAND(COMMAND cp ARGS EOglext.c ${EO_SOURCE_DIR}/basis/src
TARGET updateEOglext )
AUX_SOURCE_DIRECTORY(src SRCS)
ADD_LIBRARY(${LIB} ${SRCS})
ADD_DEPENDENCIES(${LIB} updateEOglext)
It produces the following makefile (extract) :
basis_DEPEND_LIBS =
#---------------------------------------------------------
# static library
#
libbasis.a: $(basis_SRC_OBJS) $(basis_DEPEND_LIBS)
echo "Building static library libbasis.a..."
$(RM) libbasis.a
/usr/bin/ar cr libbasis.a $(basis_SRC_OBJS)
/usr/bin/ranlib libbasis.a
#---------------------------------------------------------
# Utility
#
updateEOglext: \
/cygdrive/c/gina2/PUBLIC/ala/EOenv/EO/genextension/EXTFILE_STD.TXT
echo "Building Utility updateEOglext..."
/cygdrive/c/gina2/PUBLIC/ala/EOenv/cmakeEO/genextension/EOgenext -i
EXTFILE_STD.TXT
cp EOglext.h /cygdrive/c/gina2/PUBLIC/ala/EOenv/EO/basis/inc
cp EOglext.c /cygdrive/c/gina2/PUBLIC/ala/EOenv/EO/basis/src
Unfortunately there is no dependency at all between the final target lib
libbasis.a and updateEOglext.
I tried to express this dependency with ADD_DEPENDENCIES but...
Any way is there a mean to express the depency between the main target and a
custom one ?
Thanks.
Alexandre Laoubi