Fix build error on gcc version 7.x 35/208335/1
authorDaedong Park <daedong.park@samsung.com>
Thu, 18 Apr 2019 01:11:39 +0000 (10:11 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 24 Jun 2019 00:48:11 +0000 (09:48 +0900)
- Add missing standard library header
- Rebuild google test 1.7.0

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/5434c42da3c3d0deec5104aa022fce51e86660f1
(cherry picked from 5434c42da3c3d0deec5104aa022fce51e86660f1)

Change-Id: Ia416aedec5c338088066b75667cec80f745969dc
Signed-off-by: Daedong Park <daedong.park@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
extlibs/gtest/SConscript
resource/include/OCUtilities.h

index d127ccf..df306f4 100644 (file)
@@ -6,6 +6,7 @@
 ##
 
 import os
+import shutil
 
 Import('env')
 
@@ -22,7 +23,26 @@ gtest_url = 'http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec
 
 if target_os in targets_need_gtest:
        print '*** Checking for installation of google unit test 1.7.0 ***'
-       if not os.path.exists(os.path.join(gtest_dir, 'configure')):
+       env_lib_path = env.get('LIBPATH')
+       if gtest_lib_dir in env_lib_path:
+               print '*** Found google unit test, set environments ***'
+               gtest_env.AppendUnique(LIBPATH = [gtest_dotlib_dir])
+               gtest_env.PrependUnique(CPPPATH = [os.path.join(gtest_dir, 'include')])
+               gtest_env.AppendENVPath('LD_LIBRARY_PATH', gtest_dotlib_dir)
+               if 'g++' in gtest_env.get('CXX'):
+                       gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
+                       gtest_env.AppendUnique(CXXFLAGS = ['-Wall'])
+                       if target_os not in ['android']:
+                               gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
+                               gtest_env.PrependUnique(LIBS = ['pthread'])
+               gtest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
+               if target_os in ['windows']:
+                       gtest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
+               Return('gtest_env')
+       else:
+               print '*** Prepare to build google unit test 1.7.0 ***'
+               if os.path.exists(gtest_dir):
+                       shutil.rmtree(gtest_dir)
                # If the gtest zip file is not already present, download it
                if not os.path.exists(gtest_zip_file):
                        gtest_zip = gtest_env.Download(gtest_zip_file, gtest_url)
@@ -74,6 +94,7 @@ elif target_os in ['linux']:
                        # Run make on gtest
                        print 'Making google unit test'
                        gtest_env.Configure(gtest_dir, 'make')
+               env.AppendUnique(LIBPATH = [gtest_lib_dir])
 
 elif target_os == 'msys_nt':
        if os.path.exists(gtest_dir):
index 85039d0..2339be2 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef OC_UTILITIES_H_
 #define OC_UTILITIES_H_
 
+#include <functional>
 #include <map>
 #include <vector>
 #include <memory>