[CMake] Problem when globbing files and using that OUTPUT variable between ADD_CUSTOM_COMMAND commands

2012-02-17 Thread NoRulez
Hi,i have several ADD_CUSTOM_COMMAND commands with a specified target (let's say TARGET1).Between those commands I need to collect files and want to use those collected files in the next ADD_CUSTOM_COMMAND.How can i do that, because the following doesn't work as expected.ADD_CUSTOM_COMMAND(TARGET TARGET1 COMMAND SAMPLE_COMMAND ARGS ARGUMENTS WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMENT "Doing some stuff" VERBATIM)# HERE I NEED A CUSTOM COMMAND where the CUSTOM_FILES variable can be used in the next ADD_CUSTOM_COMMANDADD_CUSTOM_COMMAND(OUTPUT CUSTOM_FILES
 COMMAND /usr/bin/find ARGS ${CUSTOM_PATH} -type f
 COMMENT "Find files"
 VERBATIM)
ADD_CUSTOM_COMMAND(TARGET TARGET1
 COMMAND SAMPLE_COMMAND ARGS ${CUSTOM_FILES}
 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 COMMENT "Doing some stuff"
 VERBATIM)ADD_CUSTOM_COMMAND(TARGET TARGET1
 COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 COMMENT "Doing some stuff"
 VERBATIM)Thanks in advanceBest RegardsNoRuleu--

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

Re: [CMake] Problem when globbing files and using that OUTPUT variable between ADD_CUSTOM_COMMAND commands

2012-02-17 Thread Eric Noulard
2012/2/17 NoRulez noru...@me.com:
 Hi,

 i have several ADD_CUSTOM_COMMAND commands with a specified target (let's
 say TARGET1).
 Between those commands I need to collect files and want to use those
 collected files in the next ADD_CUSTOM_COMMAND.
 How can i do that, because the following doesn't work as expected.

 ADD_CUSTOM_COMMAND(TARGET TARGET1
COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT Doing some stuff
VERBATIM)

may be you could do:

ADD_CUSTOM_COMMAND(TARGET TARGET1
   COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
   COMMAND ${CMAKE_COMMAND} -DOutFile=fl.cmake -P
collectFiles.cmake
   COMMAND ${CMAKE_COMMAND} -DInFile=fl.cmake -P
doPostProcessing.cmake
   WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
   COMMENT Doing some stuff
   VERBATIM)

the collectFiles step will do whatever you want and create the fl.cmake
file
which will be loaded by the second doPostProcessing in order to get
access to list of file in a pre-defined CMake var.

You can split this in separate add_custom_command but I don't see the need
in your example.


 # HERE I NEED A CUSTOM COMMAND where the CUSTOM_FILES variable can be used
 in the next ADD_CUSTOM_COMMAND
 ADD_CUSTOM_COMMAND(OUTPUT CUSTOM_FILES
COMMAND /usr/bin/find ARGS ${CUSTOM_PATH} -type f
COMMENT Find files
VERBATIM)

 ADD_CUSTOM_COMMAND(TARGET TARGET1
COMMAND SAMPLE_COMMAND ARGS ${CUSTOM_FILES}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT Doing some stuff
VERBATIM)

 ADD_CUSTOM_COMMAND(TARGET TARGET1
COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT Doing some stuff
VERBATIM)

 Thanks in advance

 Best Regards
 NoRuleu

 --

 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



-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
--

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

Re: [CMake] Problem when globbing files and using that OUTPUT variable between ADD_CUSTOM_COMMAND commands

2012-02-17 Thread Eric Noulard
2012/2/17 noru...@me.com

 Is there no way to depend on an other custom command without using extra 
 files?

I don't think there is beside the fact that you can specify dependency
to a target (including custom target) or files using OUTPUT and DEPENDS options.

 It would be nice if i can pass OUTPUT and TARGET to ADD_CUSTOM_COMMAND.

You can (using OUTPUT and DEPENDS) your problem is you don't
know the output of your command **statically**.

 So i here is my problem in a more detail:
 I want to get a list of files from 
 ${CMAKE_RUNTIME_OUTPUT_DIR}/${PROJECT_NAME}.app where all files beginning 
 with ${PROJECT_NAME} would be excluded.

The result of this command is only known at build-time.
At build time the build tool (make, Visual Studio, etc...) is
running not CMake,
The objective of add_custom_ is to execute some commands **at
build-time** on behalf
of the build tool how would the build tool handle a CMake variable
while CMake is not even running ???

 After that I want to iterate over that list (foreach) and run 
 ADD_CUSTOM_COMMAND for each file.
 I see here no need for any extra files.

I think you are missing a point.
the ADD_CUSTOM_COMMAND processed by CMake when reading
CMakeLists.txt at CMake time
are ***TRANSLATED*** into build tool rules.

I think there is a need of an extra file because it's the only way to
communicate
build-time informations between several build tool rules (i.e.
derived from custom command).

The only way around I see would be for you to know ahead of build (at
CMake time)
the list of files you'll be processing.


--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
--

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


Re: [CMake] Problem when globbing files and using that OUTPUT variable between ADD_CUSTOM_COMMAND commands

2012-02-17 Thread norulez
Is there no way to depend on an other custom command without using extra files?

It would be nice if i can pass OUTPUT and TARGET to ADD_CUSTOM_COMMAND.

So i here is my problem in a more detail:
I want to get a list of files from 
${CMAKE_RUNTIME_OUTPUT_DIR}/${PROJECT_NAME}.app where all files beginning with 
${PROJECT_NAME} would be excluded.
After that I want to iterate over that list (foreach) and run 
ADD_CUSTOM_COMMAND for each file.

I see here no need for any extra files.

Thanks in advance

Best Regards
NoRulez

Am 17.02.2012 um 13:47 schrieb Eric Noulard eric.noul...@gmail.com:

 
 
 2012/2/17 NoRulez noru...@me.com:
  Hi,
 
  i have several ADD_CUSTOM_COMMAND commands with a specified target (let's
  say TARGET1).
  Between those commands I need to collect files and want to use those
  collected files in the next ADD_CUSTOM_COMMAND.
  How can i do that, because the following doesn't work as expected.
 
  ADD_CUSTOM_COMMAND(TARGET TARGET1
 COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 COMMENT Doing some stuff
 VERBATIM)
 
 may be you could do:
 
 ADD_CUSTOM_COMMAND(TARGET TARGET1
COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
COMMAND ${CMAKE_COMMAND} -DOutFile=fl.cmake -P 
 collectFiles.cmake
COMMAND ${CMAKE_COMMAND} -DInFile=fl.cmake -P 
 doPostProcessing.cmake
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT Doing some stuff
VERBATIM)
 
 the collectFiles step will do whatever you want and create the fl.cmake file
 which will be loaded by the second doPostProcessing in order to get 
 access to list of file in a pre-defined CMake var.
 
 You can split this in separate add_custom_command but I don't see the need
 in your example.
 
 
  # HERE I NEED A CUSTOM COMMAND where the CUSTOM_FILES variable can be used
  in the next ADD_CUSTOM_COMMAND
  ADD_CUSTOM_COMMAND(OUTPUT CUSTOM_FILES
 COMMAND /usr/bin/find ARGS ${CUSTOM_PATH} -type f
 COMMENT Find files
 VERBATIM)
 
  ADD_CUSTOM_COMMAND(TARGET TARGET1
 COMMAND SAMPLE_COMMAND ARGS ${CUSTOM_FILES}
 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 COMMENT Doing some stuff
 VERBATIM)
 
  ADD_CUSTOM_COMMAND(TARGET TARGET1
 COMMAND SAMPLE_COMMAND ARGS ARGUMENTS
 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 COMMENT Doing some stuff
 VERBATIM)
 
  Thanks in advance
 
  Best Regards
  NoRuleu
 
  --
 
  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
 
 
 
 -- 
 Erk
 Membre de l'April - « promouvoir et défendre le logiciel libre » - 
 http://www.april.org
 
--

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