[CMake] How to force package target generate a file before proceeding
Roman Bolshakov
roolebo at gmail.com
Wed Feb 18 20:23:19 EST 2015
add_custom_command is rather used for operations performed during build phase (which is completely separate off packaging)
You could create hgHash.txt during packaging by using install(SCRIPT) command:
install(SCRIPT hgHash.cmake)
install(
FILES hgHash.txt
DESTINATION yourapp
)
Hypothetical hgHash.cmake would be quite straightforward:
message(STATUS "Getting hg hash")
execute_process(
COMMAND hg --debug id -i
OUTPUT_FILE hgHash.txt
)
That would create hgHash.txt unconditionally during each cpack/make install/cmake -P cmake_install.cmake invocation
-Roman
—
Sent from Mailbox
On Wed, Feb 18, 2015 at 12:55 AM, Shyrokov, Sasha
<Sasha-Shyrokov at idexx.com> wrote:
> Hi,
> I would like to include a generated file into a package. I have something like that:
> include(CPack)
> add_custom_command (OUTPUT hgHash.txt
> COMMAND hg --debug id -i >hgHash.txt
> COMMENT "Getting hg hash")
> add_custom_target (hg_hash
> DEPENDS hgHash.txt
> COMMENT "hg_hash target")
> Now the following would solve my problems, but it does not work:
> add_dependencies(package hg_hash)
> I get:
> Cannot add target-level dependencies to non-existent target "package".
> 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.
> What am I missing?
> Thanks,
> Sasha
> --
> 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:
> http://public.kitware.com/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150218/2036a3c1/attachment-0001.html>
More information about the CMake
mailing list