I have an executable depends on some nonexisting files.I use ADD_CUSTOM_COMMAND to produce these files. However, make reports "no rule" errors even rules are there. Type "make envC.cpp" directly works instead.

The rule in the Makefile:

envC.cpp: /home/ship2rr/hdrsfaults.h
   @echo "Building Custom command envC.cpp..."
   /usr/bin/soapcpp2 -x -w -L -n -penv /home/ship2rr/hdrsfaults.h

scheduler: $(scheduler_SRC_OBJS) $(scheduler_EXTERNAL_OBJS) $(scheduler_DEPEND_LIBS)
   @echo "Building executable /home/ship2rr/test/scheduler..."
c++ -fPIC $(scheduler_SRC_OBJS) $(scheduler_EXTERNAL_OBJS) -o /home/ship2rr/test/scheduler ...

Here is output from make:

Reading makefiles...
Reading makefile `Makefile'...
Reading makefile `cmake.depends' (search path) (no ~ expansion)...
Updating goal targets....
Considering target file `scheduler'.
File `scheduler' does not exist.
 Considering target file `/home/ship2rr/test/scheduler'.
  File `/home/ship2rr/test/scheduler' does not exist.
   Considering target file `envC.o'.
    File `envC.o' does not exist.
     Considering target file `/home/ship2rr/test/envC.cpp'.
      File `/home//ship2rr/test/envC.cpp' does not exist.
      Finished prerequisites of target file `/home/ship2rr/test/envC.cpp'.
     Must remake target `/home/seePort/ship2rr/test/envC.cpp'.
make: *** No rule to make target `/home/ship2rr/test/envC.cpp', needed by `envC.o'. Stop.

Here is my CMakeLists.txt
###############################################
PROJECT (SEEPORT_SCHEDULER)

SET (SOAP_OBJS ... # here are some soap files)
SET (KALMAN_OBJS .. # here are some cpp files)
SET(GSOAP /usr/bin/soapcpp2)
SET(GSFLAGS -x -w -L -n)
...

# the first seven (7) cpp files do not exist
ADD_EXECUTABLE(scheduler envC.cpp ssServer.cpp ssC.cpp psClient.cpp psC.cpp tsClient.cpp tsC.cpp
${PROJECT_SOURCE_DIR}/schedMain.cpp ${SOAP_OBJS} ${KALMAN_OBJS}
)

???????????????????????????????????????????????????
# these target will generate those nonexisting files
ADD_CUSTOM_TARGET(ptzTarget ALL ${GSOAP} ${GSFLAGS} ${PROJECT_SOURCE_DIR}/ptzsvc.h) ADD_CUSTOM_TARGET(schTarget ALL ${GSOAP} ${GSFLAGS} ${PROJECT_SOURCE_DIR}/schedsvc.h) ADD_CUSTOM_TARGET(thrTarget ALL ${GSOAP} ${GSFLAGS} ${PROJECT_SOURCE_DIR}/threatsvc.hh) ADD_CUSTOM_TARGET(envcTarget ALL ${GSOAP} ${GSFLAGS} ${PROJECT_SOURCE_DIR}/hdrsfaults.h)

ADD_DEPENDENCIES(scheduler ptzTarget schTarget thrTarget envcTaret)
??????????????????????????????????????????????????

SET_SOURCE_FILES_PROPERTIES(pfile envC.cpp ssServer.cpp ssC.cpp psClient.cpp psC.cpp tsClient.cpp tsC.cpp
PROPERTIES GENERATED TRUE)

# show one out of six ADD_CUSTOM_COMMAND
FOREACH(pfile psC.cpp psClient.cpp psServer.cpp)
   ADD_CUSTOM_COMMAND(OUTPUT ${pfile}
   COMMAND ${GSOAP}
   ARGS ${GSFLAGS} ${PROJECT_SOURCE_DIR}/ptzsvc.h
   DEPENDS ${PROJECT_SOURCE_DIR}/ptzsvc.h)
ENDFOREACH(pfile)
####################################################


My questions are:
A) Is this a bug of cmake or how can I correct it to make it work?

B) If I use ADD_CUSTOM_TARGET and ADD_DEPENDENCIES as showed between question marks, it will not work. It still compiles encV.cpp first instead of producing custom-defined targets. However, if I manually move $(scheduler_DEPEND_LIBS) before $(scheduler_SRC_OBJS) in the above second rule, it works. How can I make sure my custome-defined targets be built first or is there a method to specify the order of dependencies?

Thank,

Tao

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to