<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>I have spent a few hours trying to solve what seems like a simple
problem.</p>
<p>I need to generate a file with some dependencies and install it.</p>
<p> If I want cmake to figure out how to compile and link it, I can</p>
<blockquote>
<p>add_executable(mytarget mytarget.c)<br>
install(TARGETS mytarget DESTINATION bin)</p>
</blockquote>
<p>I also know that if I get cmake to configure a file, I can
install it:</p>
<blockquote>
<p>configure_file (<br>
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in<br>
${CMAKE_CURRENT_BINARY_DIR}/config.h )<br>
intall(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h<br>
DESTINATION include )</p>
</blockquote>
<p>But what if I have a tool of my own that will generate the file?
I know I can:</p>
<blockquote>
<p>add_custom_command(<br>
OUTPUT mygeneratedfile<br>
COMMAND mytool -o mygeneratedfile<br>
DEPENDS mysourcefile<br>
)</p>
</blockquote>
<p>and this works well *provided* that mygeneratedfile is in turn a
source file for another derivation, but I cannot follow that with:</p>
<blockquote>
<p>install(FILES mygeneratedfile DESTINATION bin)</p>
</blockquote>
<p>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)</p>
<p>Am I missing something?<br>
</p>
<p>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?</p>
<p><br>
</p>
</body>
</html>