Fix build error on gcc version 7.x
[platform/upstream/iotivity.git] / extlibs / gtest / SConscript
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):