[CMake] Add pre-existing object file to linker line?
Trevor Kellaway
tkellaway at asl-electronics.co.uk
Sun May 27 17:44:36 EDT 2007
Bill,
> >> You want to create your own rules for CMAKE_(LANG)_COMPILE_OBJECT:
> It should be like this:
> "command ..."
> "command2 .."
> "command3 .."
Thanks, as you say you can have multiple commands. Alas, I've fallen
down another hole which rules this solution out.
For any lurkers there are a few caveats:
1) The command invoked must have native style slashes, under Windows
forward slashes in the command caused it to be ignored.
2) Any variable arguments can't be lists, as they cause a line split,
which is then interpreted as another command. The solution is to undo
the list:
FOREACH (_arg ${MY_LIST})
SET (MY_ARGS "${MY_ARGS} ${_arg}")
ENDFOREACH (_arg ${MY_LIST})
"command ${_arg} <SOURCE>"
3) Be aware that the command's current directory will be in the binary
tree.
Because of (3) I can't use this solution, as I need to run the command
in the source directory.
The ADD_CUSTOM_COMMAND solution is still the best (I can also the have
source file specific args which CMAKE_(LANG)_COMPILE_OBJECT won't
support), if only I could determine the object file directory.
I notice that GET_SOURCE_FILE_PROPERTIES has a LOCATION property that
returns the source file location. How hard would it be to add the same
for an object file based on cmGetSourceFilePropertyCommand?
Your assistance is much appreciated.
- TrevK
More information about the CMake
mailing list