On 02/22/2012 05:02 PM, Andrea Crotti wrote: > Again I'm having some troubles with the different building stages: > > I would like to have a target that simply unzips all the files contained > in a directory, > which can be found with a simple globbing. > > add_custom_target(unzip_all_eggs > file(GLOB eggs RELATIVE ${EGG_BUILD_DIRECTORY}/*egg) > COMMAND ${PYTHON_EXECUTABLE} ${UNZIP_SCRIPT} ${egg} > ) > > > The problem is that [...]
...FILE(GLOB ...) is a CMake command executed by CMake, whereas the custom target's COMMANDs are executed by the build tool at build time, so this approach fails from the first. > A possible solution is to make my UNZIP_SCRIPT smarter and just do the > globbing > itself, is there any other more CMake-like solution? ADD_CUSTOM_TARGET(unzip_all_eggs ${CMAKE_COMMAND} -DEGGDIR=${EGG_BUILD_DIRECTORY} -P ${CMAKE_SOURCE_DIR}/unzip_all_eggs.cmake) # ${CMAKE_SOURCE_DIR}/unzip_all_eggs.cmake: SET(PYTHON_EXECUTABLE ...) SET(UNZIP_SCRIPT ...) FILE(GLOB eggs RELATIVE ${EGGDIR}/*egg) EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} ${UNZIP_SCRIPT} ${eggs} WORKING_DIRECTORY ... ) You might want to provide an unzip_all_eggs.cmake.in template including SET(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@) SET(UNZIP_SCRIPT @UNZIP_SCRIPT@) use CONFIGURE_FILE(unzip_all_eggs.cmake.in unzip_all_eggs.cmake @ONLY) to generate the actual unzip_all_eggs.cmake after searching Python and your script, and specify -P ${CMAKE_BINARY_DIR}/unzip_all_eggs.cmake. Regards, Michael -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake