<span id="mailbox-conversation"><div>add_custom_command is rather used for operations performed during build phase (which is completely separate off packaging)</div>
<div><br></div>
<div>You could create hgHash.txt during packaging by using install(SCRIPT) command:</div>
<div>install(SCRIPT hgHash.cmake)</div>
<div>
<div>install(</div>
<div>  FILES hgHash.txt</div>
<div>  DESTINATION yourapp</div>
<div id="mb-reply">)</div>
<div id="mb-reply"><br></div>
</div>
<div>Hypothetical hgHash.cmake would be quite straightforward:</div>
<div>
<div>message(STATUS "Getting hg hash")</div>
<div>execute_process(</div>
<div>  COMMAND hg --debug id -i</div>
<div>  OUTPUT_FILE hgHash.txt</div>
<div id="mb-reply">)</div>
<div id="mb-reply"><br></div>
<div id="mb-reply"><div>That would create hgHash.txt unconditionally during each cpack/make install/cmake -P cmake_install.cmake invocation</div></div>
<div id="mb-reply"><br></div>
<div id="mb-reply">-Roman</div>
</div></span><div class="mailbox_signature">
<br>—<br>Sent from <a href="https://www.dropbox.com/mailbox">Mailbox</a>
</div>
<br><br><div class="gmail_quote"><p>On Wed, Feb 18, 2015 at 12:55 AM, Shyrokov, Sasha <span dir="ltr"><<a href="mailto:Sasha-Shyrokov@idexx.com" target="_blank">Sasha-Shyrokov@idexx.com</a>></span> wrote:<br></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><p>Hi,
<br><br>I would like to include a generated file into a package. I have something like that:
<br>include(CPack)
<br><br>add_custom_command (OUTPUT hgHash.txt
<br>    COMMAND hg --debug id -i >hgHash.txt
<br>    COMMENT "Getting hg hash")
<br><br>add_custom_target (hg_hash
<br>    DEPENDS hgHash.txt
<br>    COMMENT "hg_hash target")
<br><br>Now the following would solve my problems, but it does not work:
<br>add_dependencies(package hg_hash)
<br><br>I get:
<br>Cannot add target-level dependencies to non-existent target "package".
<br><br>I know I have CPack configured properly, because if I create the file manually it gets included. I also can add the dependency on one of my libraries, but I only want to generate this file when package is executed.
<br><br>What am I missing?
<br><br>Thanks,
<br>Sasha
<br><br>-- 
<br><br>Powered by www.kitware.com
<br><br>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
<br><br>Kitware offers various services to support the CMake community. For more information on each offering, please visit:
<br><br>CMake Support: http://cmake.org/cmake/help/support.html
<br>CMake Consulting: http://cmake.org/cmake/help/consulting.html
<br>CMake Training Courses: http://cmake.org/cmake/help/training.html
<br><br>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
<br><br>Follow this link to subscribe/unsubscribe:
<br>http://public.kitware.com/mailman/listinfo/cmake
<br></p></blockquote></div><br>