[CMake] Setting properties from within a function

Michael Surette mjsurette at gmail.com
Tue Apr 12 01:43:05 EDT 2016


I would like to use set target properties from within a function.  ie

function(MINE TGT DEF)
   target_compile_definitions("${TGT}" "${DEF}")
endfunction(MINE TGT DEF)

This doesn't work.  If I change it to a macro, it does.

macro(MINE TGT DEF)
   target_compile_definitions("${TGT}" "${DEF}")
endmacro(MINE TGT DEF)

Is there a way to extend the scope of TGT in the function so that the 
function variant works?

TIA

Mike



More information about the CMake mailing list