In general, bitbake parses all the recipes found in the meta-layer include paths and for each one, if there is source code to to fetch (for example from a Git repository online), it fetches the code and put it in the build/tmp build directory.

If you find yourself committing your meta-data for your project's Yocto build like I do, then there's often a scenario where the meta-data is in the same git tree as the source code for your application binary.  How do you make a bitbake recipe which doesn't need to clone the code from an external repository and instead runs the build "out of tree" (for example in a location such as "${WORKDIR}/../../../../../../my_application/src")?

It's a little tricky to work it out, here's an example of what such a recipe looks like.

# This file is the Company C++ application recipe which is designed to launch on Linux os boot.

# Look in a way out of tree folder to find files such as a CMakeLists.txt file.
FILESEXTRAPATHS_prepend := "${THISDIR}/../../../../../../company/src:"

SUMMARY = "Application"

# Bring some extra files, perhaps a boot script
SRC_URI += "file://some_special_file_found_in_meta_data_folder/"

# This software is tooled with CMake, tell bitbake
inherit pkgconfig cmake

# Runtime dependencies
RDEPENDS_${PN} += " protobuf"

# Build dependencies
DEPENDS += " protobuf"

# Interesting source directory choice here, because we are building out of tree
# bitbake cleans the source before doing a build so the folder set as ${S} will be
# deleted in each build.  When you're building out of tree like this, you don't want bitbake deleteing source controlled files because then you will be forced to do a git checkout for example to restore them.  We don't want to have to git->checkout again so we 
# set {S} to the temporary build output folder and then override build steps to compile from a relative reference.
S = "${THISDIR}../../../../../../company/src/CMakeTarget/build"
B = "${S}"

# For a while the compilation of this particular recipe was failing due to default security flags which are set
# for a project's CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when using default cmake settings, specifically:
# -fstack-protector-strong
# -Wformat
# -Wformat-security
# -Werror=format-security
# Googling for yocto errors surrounding the "D_FORTIFY_SOURCE" flag landed me on 
# notes found in poky/meta/...../ which has comments that explains the issue.
# So for now, remove all security flags for this recipe
SECURITY_CFLAGS_pn-fsg-app = ""

# Specify a configure step which moves to the correct directory before building.
do_configure() {

    echo "Override default configure step..."
    # Move to where the CMakeLists is located.
    cd "${S}/../"
    # Fully clean the environment, this script blows away the CMakeCache for example.

    echo Current dir is = ${PWD}

    cmake CMakeLists.txt

    echo "Override default configure step... DONE"

do_compile() {

    echo "Override default compile step..."
    cd "${S}/../"
    echo "Override default compile step... DONE"


do_install() {

    install -d ${D}/home/company

    install -m 0755 ${B}/company_app.elf ${D}/home/company/company_app.elf
    #set permissions and execution on binaries and scripts
    chmod +x -R ${D}/home/company/

There might be other ways to do this which I'm not seeing (in fact, there must be because the above seems a little hackey).  For example, we could run a do_fetch_prepend() step which produces a zip archive of the source needed and then let bitbake work with that.  But this runs into other problems.  For example, what happens if you include headers for protobuf in your source code which are relative referenced to a folder which contains a git submodule for protobuf (ie, to the folder company/src/../../lib/protocolbuffers/protobuf) then said zip archive would also need this folder and it gets a bit trickier.

In general I've found that tooling the bitbake recipe to just run correctly in an "out of Yocto tree" build works really well.  Bitbake is none the wiser, it just follows the directions found in the recipe and produces your output binary!  Have your cake and eat it too!