Settled on using the 3. approach, like avahi.bb does.
Addding the FILES
lines to the recipe, the main123
file will not be installed when using IMAGE_INSTALL:append = " mwe-so"
. If some user of the recipe wants the files, they have to do additionally install the package named mwe-optional-files
SUMMARY = "mwe stackoverflow"
LICENSE = "CLOSED"
LICENSE:mwe-optional-files = "CLOSED"
FILESEXTRAPATHS:prepend := "${THISDIR}:"
SRC_URI += "file://CMakeLists.txt"
SRC_URI += "file://main.c"
SRC_URI += "file://main2.c"
S = "${WORKDIR}"
inherit cmake pkgconfig
PACKAGES =+ "mwe-optional-files"
PROVIDES =+ "mwe-optional-files"
FILES:{PN} = "whatever files you want normally installed"
FILES:mwe-optional-files = "/usr/local/bin/main123/mwe"