'ARGN' prints empty on command line console
Cmake 3.22.1 For the following code:
set(TEMP_VAR "It is a temp varaible 1")
set(TEMP_VAR2 "It is a temp varaible 2")
function( fn_name var var2 )
message( "${var} value is = ${${var}}" )
message( "${var2} value is = ${${var2}}" )
message( "ARGN: ${ARGN}" ) # all variable name
message( "ARGC: ${ARGC}" )
message( "ARG0: ${ARGV0}" )
message( "ARG1: ${ARGV1}" )
endfunction()```
fn_name(TEMP_VAR TEMP_VAR2)
I am getting following output:
TEMP_VAR value is = It is a temp varaible 1
TEMP_VAR2 value is = It is a temp varaible 2
ARGN:
ARGC: 2
ARG0: TEMP_VAR
ARG1: TEMP_VAR2
So, the ARGN is printed as empty, but when I removed the parameters from the function signature, the ARGN prints the expected result.
set(TEMP_VAR "It is a temp varaible 1")
set(TEMP_VAR2 "It is a temp varaible 2")
function( fn_name )
message( "ARGN: ${ARGN}" ) # all variable name
message( "ARGC: ${ARGC}" )
message( "ARG0: ${ARGV0}" )
message( "ARG1: ${ARGV1}" )
endfunction()
fn_name(TEMP_VAR TEMP_VAR2)
Output:
ARGN: TEMP_VAR;TEMP_VAR2
ARGC: 2
ARG0: TEMP_VAR
ARG1: TEMP_VAR2
as I didn't find info from the Documentation. It looks like a bug for me.