I have spent a few hours trying to solve what seems like a simple problem.

I need to generate a file with some dependencies and install it.

If I want cmake to figure out how to compile and link it, I can

   add_executable(mytarget mytarget.c)
   install(TARGETS mytarget DESTINATION bin)

I also know that if I get cmake to configure a file, I can install it:

   configure_file (
      ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
      ${CMAKE_CURRENT_BINARY_DIR}/config.h )
   intall(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
      DESTINATION include )

But what if I have a tool of my own that will generate the file? I know I can:

   add_custom_command(
      OUTPUT mygeneratedfile
      COMMAND mytool -o mygeneratedfile
      DEPENDS mysourcefile
   )

and this works well *provided* that mygeneratedfile is in turn a source file for another derivation, but I cannot follow that with:

   install(FILES mygeneratedfile DESTINATION bin)

because mygeneratedfile is not a 'target', and I can't make it into a target with add_custom_target() because that's talking about something else entirely (commands that will be run unconditionally, not based on dependencies)

Am I missing something?

In my specific case, mytool actually creates an executable via it's own build system, but it could also be creating a script of some kind that needs to be installed. Of course in that case, I could possibly trick CMake by generating mygeneratedfile.in and using configure_file() with no substitutions (pretty dubious), but I can't do that with a binary file. Is this not possible?


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to