[CMake] How is ARGN passed to a macro
Torsten Robitzki
Torsten at Robitzki.de
Wed Nov 21 07:15:01 EST 2018
Hi,
I’ve stumbled over following behavior and now I’m searching for the rules, that explains that behavior:
test.cmake:
macro(check_argn)
message("in macro check_argn ARGN: ${ARGN}")
if(ARGN)
foreach(item IN LISTS ARGN)
message("ARG: ${item}")
endforeach(item)
message("ARGN: ${ARGN}")
endif()
endmacro()
function(f1 a)
message("in function ARGN: ${ARGN}")
check_argn()
endfunction()
f1(1)
f1(1 2)
This will yield the following output:
$ cmake -P ./test.cmake
in function ARGN:
in macro check_argn ARGN:
in function ARGN: 2
in macro check_argn ARGN:
ARG: 2
ARGN:
I would expect ARGN to behave exactly the same in the macro, as in the function, but apparently there is a difference. Can someone of you explain that to me?
TIA and kind regards,
Torsten
More information about the CMake
mailing list