entity-manager: static library

Define static library entity_manager_lib without the main.cpp. This is
to facilitate unit testing down the line, since tests do have their own
entry point and would conflict with main() function in main.cpp.

By defining a library, a test does not have to compile parts of EM
again, and instead only links against the static library.

Tested: build/src/entity_manager/libentity-manager.a is built.
build/src/entity_manager/entity-manager is also built.

Change-Id: Id4bfbe38f9cef5f380b29fc591dfd4535dd931af
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/meson.build b/src/entity_manager/meson.build
index a0fb7ec..0ea941a 100644
--- a/src/entity_manager/meson.build
+++ b/src/entity_manager/meson.build
@@ -6,7 +6,9 @@
     cpp_args_em += ['-DENABLE_RUNTIME_VALIDATE_JSON=false']
 endif
 
-executable(
+em_deps = [boost, nlohmann_json_dep, phosphor_logging_dep, sdbusplus, valijson]
+
+entity_manager_lib = static_library(
     'entity-manager',
     'entity_manager.cpp',
     'configuration.cpp',
@@ -20,15 +22,16 @@
     'utils.cpp',
     'log_device_inventory.cpp',
     '../utils.cpp',
+    cpp_args: cpp_args_em,
+    dependencies: em_deps,
+)
+
+executable(
+    'entity-manager',
     'main.cpp',
     cpp_args: cpp_args_em,
-    dependencies: [
-        boost,
-        nlohmann_json_dep,
-        phosphor_logging_dep,
-        sdbusplus,
-        valijson,
-    ],
+    dependencies: em_deps,
+    link_with: entity_manager_lib,
     install: true,
     install_dir: installdir,
 )