[CMake] How to force package target generate a file before proceeding
Shyrokov, Sasha
Sasha-Shyrokov at idexx.com
Thu Feb 19 09:26:12 EST 2015
Thanks Roman for the detailed response. I would like the hash generated when I use “make package” command, not “make install”. I can see that my hgHash.cmake is included, but it does not run on “make package”.
Thanks,
Sasha
From: Roman Bolshakov [mailto:roolebo at gmail.com]
Sent: Wednesday, February 18, 2015 8:23 PM
To: Shyrokov, Sasha
Cc: cmake at cmake.org
Subject: Re: [CMake] How to force package target generate a file before proceeding
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
On Wed, Feb 18, 2015 at 12:55 AM, Shyrokov, Sasha <Sasha-Shyrokov at idexx.com<mailto: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150219/4a6728b1/attachment.html>
More information about the CMake
mailing list