cmake_minimum_required(VERSION 2.8) project(testoptargmacro) macro(testmacro testarg1 testarg3) message(STATUS "testarg1 = \"${testarg1}\"") message(STATUS "testarg1 = \"${testarg2}\"") message(STATUS "Optional arg = \"${ARGV2}\"") if(${ARGV2}) message(STATUS "Optional arg from if = \"${ARGV2}\"") endif() endmacro(testmacro) testmacro("pipo1" "pipo2") testmacro("pipo3" "pipo4" "pipo5")