Fix meson file and remove warnings from compilation

Fixed meson file by applying proper dependency. Removed boost from
subprojects because boost does not support cmake and meson. User
is able to build boost manually or using a script
boost_build_1.74.0.sh and set BOOST_ROOT variable to build files.
Then reruning meson should detect boost dependency with positive
result.

Removed all warnings from compilation by applying a new flag for
boost - BOOST_ALLOW_DEPRECATED_HEADERS, after boost update this
flag should be removed. Changed tmpnam() with temp_directory_path
provided by std::filesystem.

Tested:
 - Built telemetry with success in cases when different components
   are not installed on system: nlohmann, sdbusplus, googletest,
   phosphor-logging.
 - Using BOOST_ROOT variable that points to installation location
   of boost allows to build telemetry wihtout boost installed on
   system.
 - Unit test passed.

Change-Id: I8d430f4c51b7bc6669c8533e1a76c4666efd4fc6
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/meson.build b/meson.build
index 1fc346d..68397c2 100644
--- a/meson.build
+++ b/meson.build
@@ -24,21 +24,22 @@
         '-DBOOST_ASIO_NO_DEPRECATED',
         '-DBOOST_NO_RTTI',
         '-DBOOST_NO_TYPEID',
+        # TODO: Removed below arg after upgrade to Boost 1.75
+        '-DBOOST_ALLOW_DEPRECATED_HEADERS',
         '-Wno-unused-parameter',
     ]),
     language: 'cpp'
 )
 
 boost = dependency(
-  'boost',
-  version: '>=1.74.0',
-  required: false,
-  modules: ['coroutine'])
-
-if not boost.found()
-    subproject('boost', required: false)
-    boost  = declare_dependency(include_directories: 'subprojects/boost_1_74_0')
-endif
+    'boost',
+    version: '>=1.74.0',
+    required: false,
+    modules: ['coroutine'])
+assert(boost.found(),
+       'Missing Boost 1.74.0 or higher, as WA you can set BOOST_ROOT ' +
+       'environemt to point at boost build. To build a boost you can use ' +
+       'script ./scripts/boost_build_1.74.0.sh')
 
 phosphor_logging = dependency('phosphor-logging', required: false)
 if not phosphor_logging.found()
@@ -48,29 +49,20 @@
     )
 endif
 
-sdbusplus = dependency('sdbusplus',required : false)
-if not sdbusplus.found()
-  sdbusplus_proj = subproject('sdbusplus', required: true)
-  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
-endif
-
+sdbusplus = dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep'])
 systemd = dependency('systemd')
 
 if cpp.has_header('nlohmann/json.hpp')
     nlohmann_json = declare_dependency()
 else
-    subproject('nlohmann', required: false)
-    nlohmann_json = declare_dependency(
-        include_directories: [
-            'subprojects/nlohmann/single_include',
-            'subprojects/nlohmann/single_include/nlohmann',
-        ]
-    )
+    nlohmann_json = dependency('nlohmann_json',
+                               fallback: ['nlohmann', 'nlohmann_json_dep'])
 endif
 
 add_project_arguments(
     '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
-    '-DTELEMETRY_MAX_READING_PARAMS=' + get_option('max-reading-parameters').to_string(),
+    '-DTELEMETRY_MAX_READING_PARAMS=' +
+        get_option('max-reading-parameters').to_string(),
     '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
     '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
     language: 'cpp'
diff --git a/scripts/boost_build_1.74.0.sh b/scripts/boost_build_1.74.0.sh
new file mode 100755
index 0000000..074e72c
--- /dev/null
+++ b/scripts/boost_build_1.74.0.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+if [[ ! -d boost_1_74_0 ]]; then
+    wget https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.gz
+    tar xfz boost_1_74_0.tar.gz
+fi
+
+cd boost_1_74_0
+if [[ ! -d build ]]; then
+    ./bootstrap.sh --with-libraries=coroutine
+    ./b2 install --prefix=build
+fi
+
+echo -e "Please, set BOOST_ROOT to `pwd`/build, e.g.:\n" \
+        "export BOOST_ROOT=`pwd`/build"
diff --git a/subprojects/boost.wrap b/subprojects/boost.wrap
deleted file mode 100644
index 1114980..0000000
--- a/subprojects/boost.wrap
+++ /dev/null
@@ -1,4 +0,0 @@
-[wrap-file]
-source_url = https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.gz
-source_filename = boost_1_74_0.tar.gz
-source_hash = afff36d392885120bcac079148c177d1f6f7730ec3d47233aa51b0afa4db94a5
diff --git a/subprojects/nlohmann.wrap b/subprojects/nlohmann.wrap
index 48f3c68..f1c5df4 100644
--- a/subprojects/nlohmann.wrap
+++ b/subprojects/nlohmann.wrap
@@ -1,3 +1,5 @@
-[wrap-git]
-revision = db78ac1d7716f56fc9f1b030b715f872f93964e4
-url = https://github.com/nlohmann/json.git
+[wrap-file]
+source_url = https://github.com/nlohmann/json/releases/download/v3.9.1/include.zip
+source_filename = nlohmann-json-v3.9.1-include.zip
+source_hash = 6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91
+lead_directory_missing = nlohmann-json-v3.9.1
diff --git a/tests/meson.build b/tests/meson.build
index 393f73f..5be01be 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,21 +1,9 @@
-gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
-gmock_dep = dependency('gmock', disabler: true, required: false)
+gtest_dep = dependency('gtest', main: false, required: false, version: '>=1.10.0')
+gmock_dep = dependency('gmock', required: false, version: '>=1.10.0')
 if not gtest_dep.found() or not gmock_dep.found()
-    gtest_proj = import('cmake').subproject('googletest', required: false)
-    if gtest_proj.found()
-        gtest_dep = declare_dependency(
-            dependencies: [
-                dependency('threads'),
-                gtest_proj.dependency('gtest')
-            ]
-        )
-        gmock_dep = gtest_proj.dependency('gmock')
-  else
-        assert(
-            not get_option('tests').enabled(),
-            'Googletest is required if tests are enabled'
-        )
-  endif
+    gtest_proj = import('cmake').subproject('googletest')
+    gtest_dep = gtest_proj.dependency('gtest')
+    gmock_dep = gtest_proj.dependency('gmock')
 endif
 
 test(
diff --git a/tests/src/test_persistent_json_storage.cpp b/tests/src/test_persistent_json_storage.cpp
index cf6abd1..7ddc5b6 100644
--- a/tests/src/test_persistent_json_storage.cpp
+++ b/tests/src/test_persistent_json_storage.cpp
@@ -33,7 +33,8 @@
 
 const interfaces::JsonStorage::DirectoryPath
     TestPersistentJsonStorage::directory =
-        interfaces::JsonStorage::DirectoryPath(std::tmpnam(nullptr));
+        interfaces::JsonStorage::DirectoryPath(
+            std::filesystem::temp_directory_path() / "telemetry-tests");
 
 TEST_F(TestPersistentJsonStorage, storesJsonData)
 {