[CMake] FILE command and generating files.

Tanner Lovelace lovelace-cmake at wayfarer.org
Fri Apr 1 16:50:34 EST 2005


Greetings,

I think this should be simple, but it just doesn't seem to be
working for me and a web search has failed me so here's another
question for the list.

I'm trying to generate a file using a program that takes a list
of files (a header file and some source files) as input.
I tried doing this:

# Get full paths to the input files and put them into tmp.txt
FILE(WRITE tmp.txt "${PROJ_SOURCE_DIR}/include/msgs.h")
FOREACH(c_file ${STATIC_SRCS} ${BASE_SRCS})
  FILE(APPEND tmp.txt "${CMAKE_CURRENT_SOURCE_DIR}/${c_file}")
ENDFOREACH(c_file)
ADD_CUSTOM_COMMAND(output.txt ALL
  ${CMAKE_BINARY_DIR}/bin/command -f tmp.txt)

My problem, however, is that the file commands don't seem to
do anything at all.  Do I need to add them to a custom command
or perhaps make a .cmake file that gets executed by the makefile?

Also, is there a better way to get full paths to the files?  The
source varables are defined like this:

SET(STATIC_SRCS
file1.c
file2.c
win32/file3.c
[...etc...]
)

So I can pass them directly into the library target I'm
also creating in this directory.  However, I couldn't think
of an easy way to transform that into full paths to the files.

Any help would be appreciated.

Thanks very much.

Cheers,
Tanner Lovelace


More information about the CMake mailing list