Eric BOIX wrote:
Here is a code snipet taken from my fig/CMakeLists.txt:
   FILE(GLOB MANUAL_FIG_GLOB "*.fig")
   FOREACH( filename ${MANUAL_FIG_GLOB} )
     GET_FILENAME_COMPONENT( filenameNoExt ${filename} NAME_WE )
     SET( filenameDest "${CMAKE_CURRENT_BINARY_DIR}/${filenameNoExt}.eps" )
     ADD_CUSTOM_COMMAND( OUTPUT    ${filenameDest}
                         COMMAND   ${FIG2DEV}
                         ARGS      -L eps ${filename} ${filenameDest}
                         DEPENDS   ${filename} )
     ADD_CUSTOM_TARGET(dummy${filename}_EPS ALL
                       DEPENDS  ${filenameDest})
   ENDFOREACH( filename )

The important thing is here that the target names (i.e. dummy${filename}_EPS)
can be numerous and are generated by cmake ! Now my main CMakeLists.txt used
to only state
    SUBDIRS( PREORDER fig)
which doesn't work anymore with cmake version 2.2.X...

Just create one target in the subdirectory:

# fig/CMakeLists.txt
FILE(GLOB MANUAL_FIG_GLOB "*.fig")
SET(ALL_OUT)
FOREACH( filename ${MANUAL_FIG_GLOB} )
  GET_FILENAME_COMPONENT( filenameNoExt ${filename} NAME_WE )
  SET( filenameDest "${CMAKE_CURRENT_BINARY_DIR}/${filenameNoExt}.eps" )
  ADD_CUSTOM_COMMAND( OUTPUT    ${filenameDest}
                      COMMAND   ${FIG2DEV}
                      ARGS      -L eps ${filename} ${filenameDest}
                      DEPENDS   ${filename} )
  SET(ALL_OUT ${ALL_OUT} ${filenameDest})
ENDFOREACH( filename )
ADD_CUSTOM_TARGET(build_figs ALL DEPENDS ${ALL_OUT})

Then in the top level directory:

# CMakeLists.txt
ADD_SUBDIRECTORY(fig)
ADD_CUSTOM_TARGET(build_docs ALL ...)
ADD_DEPENDENCIES(build_docs build_figs)

Your old approach would only work with the Makefile generator in CMake 2.0 and earlier. Other generators such as Visual Studio have always required the target-level dependencies to be correct. In CMake 2.0 and earlier users would have to get the target dependencies AND the directory order correct. In version 2.2 now only the target dependencies are needed.

-Brad
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to