[Cmake] problems custom target dependencies

Andy Cedilnik andy . cedilnik at kitware . com
06 Nov 2003 13:50:25 -0500


Hi Jeongnim Kim,

You are lucky. CMake 1.8.1 has the redesigned custom command interface,
so it is much easier:

PROJECT(Abinit)

# list of fotran codes

SET(FSOURCES recip cpointg speck bzdef bzred inbz listmg symgen pointg
pgsymo trgsym fccsym bccsym bctsym group1 pgl1 rlv3 atftm1 rot1 symatm
sort3 spchek trmlen)

FOREACH(source ${FSOURCES})
   ADD_CUSTOM_COMMAND(
     OUTPUT ${Abinit_BINARY_DIR}/${source}.o
     DEPENDS ${Abinit_SOURCE_DIR}/${source}.f
     COMMAND g77
     ARGS -o ${Abinit_BINARY_DIR}/${source}.o
             ${Abinit_SOURCE_DIR}/${source}.f
     )
   SET(OUTPUTS ${OUTPUTS} ${Abinit_BINARY_DIR}/${source}.o)
   SET(OUTPUTS_STRING "${OUTPUTS_STRING}
       ${Abinit_BINARY_DIR}/${source}.o")
ENDFOREACH(source)

ADD_CUSTOM_COMMAND(
   OUTPUT ${Abinit_BINARY_DIR}/libabinit.a
   DEPENDS ${OUTPUTS}
   COMMAND ar
   ARGS cr ${Abinit_BINARY_DIR}/libabinit.a
   ${OUTPUT_STRING}
   )
ADD_CUSTOM_TARGET(libabinit.a ALL ${CMAKE_COMMAND} -E echo DEPENDS
   ${Abinit_BINARY_DIR}/libainit.a)

This should work. 
Let me know if it does not.

				Andy

On Thu, 2003-11-06 at 13:34, Jeongnim Kim wrote:
> I'm very new to cmake but find it very useful and powerful for our C++ 
> projects.
> 
> I'm trying to create a fortran library and follow the instruction posted on
> 12 March 2003 with a title "Using CMake for scientific computing?".
> http://www . cmake . org/pipemail/cmake/2003-March/003469 . html
> 
> There was a post on similar problems to my problem: custom target dependencies
> but I could not find any follow-up for that thread.
> 
> Attached is my CMakeList.txt and would appreciate your suggestions how to
> fix the problem. The version of cmake I'm using is 1.8.1.

> To summarize my problem (tried several method, including ADD_DEPENDENCIES,
> but in vain), I see that Makefile has an empty field:...