[CMake] Call function from name and list, including empty elements?
Jan Wielemaker
jan at swi-prolog.org
Sat Sep 29 11:59:41 EDT 2018
Hi
I'm converting a big project (SWI-Prolog) to cmake. Still a newbie wrt.
cmake, but quite happy. There is one thing that I can't get done:
install the system using symbolic links to the source tree. This is in
this case really handy for developers.
I've come as far as understanding:
- The generator creates cmake_install.cmake
- make/ninja/... install calls cmake -P cmake_install.cmake
- This calls file(INSTALL ....)
So, I thought I can
- Add a file cmake_ln_install.cmake that
- redefines file()
- includes cmake_install.cmake
To redefine file(), I tried this to see whether this works:
function(file)
message("Calling file(${ARGN})")
_file(${ARGN})
endfunction()
But ... some of the file() calls contain empty strings ("") in the
argument vector. All the rest works fine.
On stack overflow [1], the suggestion was to use "${ARGN}", which
indeed keeps the empty lists and works fine if the receiver is a
function iterating over its argument vector. After downloading
the cmake source it turns out file() is builtin (C++) and complains
to require at least 2 arguments. I tried passing the first two
as file(${arg1} ${arg2} "${ARGN}"), which would (I think) work for
a user function, but doesn't for a builtin.
So, my question is
- Is there a way to redefine a builtin function that passes
empty strings correctly to the original?
- If not, should this be considered a bug ...
Thanks --- Jan
P.s. I'd also like to see the possibility to create symlinks
in cmake, other than calling cmake -E ...
[1] https://stackoverflow.com/questions/52480737/pass-empty-strings-in-cmake
More information about the CMake
mailing list