cmake_minimum_required(VERSION 3.16) function( dualBoot BL_TYPE ) if( BL_TYPE MATCHES "bootloader" ) target_link_options( ${PROJECT_NAME} PUBLIC "-Wl,--defsym,BL=1" ) elseif( BL_TYPE MATCHES "application" ) target_link_options( ${PROJECT_NAME} PUBLIC "-Wl,--defsym,APP=1" ) else() message( FATAL_ERROR "### Unknown bootloader type: ${BL_TYPE}" ) endif() endfunction() project( foo1 ) add_executable( ${PROJECT_NAME} main.cpp ) dualBoot ( application ) #------------------------------------------------------------------------------ project( foo2 ) add_executable( ${PROJECT_NAME} main.cpp ) dualBoot ( bootloader ) #------------------------------------------------------------------------------