[CMake] Reading settings from generated files
Eric NOULARD
eric.noulard at gmail.com
Mon May 12 15:22:39 EDT 2008
Le Mon, 12 May 2008 15:48:24 +0200,
Andrea Gualano <gualano at imavis.com> a écrit :
> I am cross-compiling for an embedded platform and I have to use a
> third-party tool which, depending on a per-project configuration
> file, does the following:
> - compiles a .o file with some init code
> - generates a file containing a list of libraries to link against
> - generates a file containing some compiler flags
>
> I am quite happy to do this with ADD_CUSTOM_COMMAND, since the
> operation is quite slow so I'd like to do that on make time, and also
> because the third-party tool is automatically rerun if the
> configuration file changes.
>
> Now, the question is: how do I read the generated files to set things
> like CMAKE_C_FLAGS and LINK_DIRECTORIES after the custom command is
> executed?
I'm not sure to understand what you want?
* If you want to get the content of a generated file
you may use FILE(READ ...)
> I could find no way to manipulate files after configuration time.
* if the problem is to read those file after they have been generated
at make time then you may run a cmake script (which use FILE(READ )
inside a ADD_CUSTOM_COMMAND which depends on the OUTPUT of the first
one
something like:
ADD_CUSTOM_COMMAND(...
COMMAND cmake -P yourCMakeScript.cmake
DEPENDS output_file.txt
...)
this way you can execute any [scriptable] CMake command at build time.
however I do not know if _file_ (and not target) dependency works.
It would be easier if you give us excerpt of your CMakeLists.txt
at least the add_custom_command part including file name.
--
Erk
More information about the CMake
mailing list