IVGCVSW-7031 Generate static execute network

 * Build ExecNet lib dependencies as object libs except libarmnn
 * Disable PIPE when building static ExecNet
 * Remove multiple definition from AsyncExecutionCallback
 * Disable DynamicBackend for ExecNet Static build
 * Disable inference  tests for TfLiteParser and ONNX during static ExecNet
 * Remove Tensorflow Parser if condition
 * Add Disable thread macro to InferenceModel
 * Don't compile dynamic backend symbols in Runtime.cpp for Baremetal and
   Exenet Static

Signed-off-by: Ryan OShea <ryan.oshea3@arm.com>
Change-Id: If41c063eab5f05b3df0a6e064924a36a177f116a
diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake
index dd20e15..6f3fee4 100644
--- a/cmake/GlobalConfig.cmake
+++ b/cmake/GlobalConfig.cmake
@@ -1,5 +1,5 @@
 #
-# Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+# Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
 # Copyright 2020 NXP
 # SPDX-License-Identifier: MIT
 #
@@ -42,6 +42,19 @@
 option(BUILD_SHARED_LIBS "Determines if Armnn will be built statically or dynamically.
                           This is an experimental feature and not fully supported.
                           Only the ArmNN core and the Delegate can be built statically." ON)
+option(EXECUTE_NETWORK_STATIC " This is a limited experimental build that is entirely static.
+                                It currently only supports being set by changing the current CMake default options like so:
+                                BUILD_TF_LITE_PARSER=1/0
+                                BUILD_ARMNN_SERIALIZER=1/0
+                                ARMCOMPUTENEON=1/0
+                                ARMNNREF=1/0
+                                ARMCOMPUTECL=0
+                                BUILD_ONNX_PARSER=0
+                                BUILD_ARMNN_TFLITE_DELEGATE=0
+                                BUILD_TIMELINE_DECODER=0
+                                BUILD_BASE_PIPE_SERVER=0
+                                BUILD_UNIT_TESTS=0
+                                BUILD_GATORD_MOCK=0" OFF)
 
 include(SelectLibraryConfigurations)
 
@@ -137,6 +150,21 @@
 
 include(CMakeFindDependencyMacro)
 
+
+if(EXECUTE_NETWORK_STATIC)
+    add_definitions(-DARMNN_DISABLE_SOCKETS
+                    -DBUILD_SHARED_LIBS=0
+                    -DARMNN_EXECUTE_NETWORK_STATIC)
+endif()
+
+if(BUILD_BARE_METAL)
+    add_definitions(-DARMNN_BUILD_BARE_METAL
+            -DARMNN_DISABLE_FILESYSTEM
+            -DARMNN_DISABLE_PROCESSES
+            -DARMNN_DISABLE_THREADS
+            -DARMNN_DISABLE_SOCKETS)
+endif()
+
 if (NOT BUILD_PIPE_ONLY)
   # cxxopts (Alternative to boost::program_options)
   find_path(CXXOPTS_INCLUDE cxxopts/cxxopts.hpp PATHS third-party NO_CMAKE_FIND_ROOT_PATH)
@@ -149,11 +177,19 @@
   include_directories(SYSTEM "${GHC_INCLUDE}")
 endif()
 
+if(NOT BUILD_SHARED_LIBS)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib)
+endif()
+
 # pthread
 if (NOT BUILD_BARE_METAL)
 find_package(Threads)
 endif()
 
+if (EXECUTE_NETWORK_STATIC)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static -pthread")
+endif()
+
 # Favour the protobuf passed on command line
 if(BUILD_ONNX_PARSER)
     find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd"
@@ -388,7 +424,7 @@
     add_definitions(-DARMNN_STREAMLINE_ENABLED)
 endif()
 
-if(NOT BUILD_BARE_METAL)
+if(NOT BUILD_BARE_METAL AND NOT EXECUTE_NETWORK_STATIC)
 if(HEAP_PROFILING OR LEAK_CHECKING)
     find_path(HEAP_PROFILER_INCLUDE gperftools/heap-profiler.h
             PATHS ${GPERFTOOLS_ROOT}/include
@@ -445,13 +481,5 @@
     endif()
 endif()
 
-if(BUILD_BARE_METAL)
-    add_definitions(-DARMNN_BUILD_BARE_METAL
-                    -DARMNN_DISABLE_FILESYSTEM
-                    -DARMNN_DISABLE_PROCESSES
-                    -DARMNN_DISABLE_THREADS
-                    -DARMNN_DISABLE_SOCKETS)
-endif()
-
 # ArmNN source files required for all build options
 include_directories(SYSTEM third-party)