[EMAIL PROTECTED] wrote:
PROJECT ( test_project )
ADD_CUSTOM_COMMAND (
        OUTPUT file.txt
        COMMAND cp /etc/passwd file.txt
)
ADD_CUSTOM_TARGET ( file_target DEPENDS file.txt )
INSTALL ( FILES file.txt DESTINATION /tmp )

I need to create file "file.txt" and install it. But installation doesn't affect dependency, so file.txt will never be created. That file isn't c code, so it can't be included to any executable or library to create dependency.

What is the right syntax to create and install that file, please?
You were pretty close. You only really missed 2 things:

1. The `ALL' option in ADD_CUSTOM_TARGET. In the CMake docs for ADD_CUSTOM_TARGET:

 > If the ALL option is specified it indicates  that  this
 > target  should  be  added to the default build target so that it
 > will be run every time (the command cannot be called  ALL).

2. INSTALL should probably have a specific path to your generated file. CMake didn't pick up on it unless I gave a more specific path.

3. ADD_CUSTOM_TARGET can contain embedded commands.

Here's a CMakeLists.txt that I used:

PROJECT(test NONE)
ADD_CUSTOM_TARGET(
  "file.txt" ALL
  COMMAND "touch" ARGS "file.txt"
  VERBATIM
)
INSTALL(
  FILES "${CMAKE_BINARY_DIR}/file.txt"
  DESTINATION "/tmp"
)

-- Jack
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to