GTest integration with meson

1,492 views
Skip to first unread message

Șiclovan Sebastian-Ioan

unread,
Feb 9, 2022, 7:35:56 AM2/9/22
to The Meson Build System
Hello Guys,

How can i integrate GTest with meson ? 

I managed to download only the "google test release- 1.10.0" zip using the gtest.wrap file.
what are the next steps ?

Thanks,
Sebastian





Abdullah Alattar

unread,
Feb 10, 2022, 5:58:26 AM2/10/22
to Șiclovan Sebastian-Ioan, The Meson Build System
Hello.
execute the following steps:

- mkdir gtest_project && cd gtest_project
- meson init --language=cpp    
- mkdir subprojects
- meson wrap install gtest  
- meson.build should be like this :
# ------------------------------------------------
project('gtest_project', 'cpp',
  version : '0.1',
  default_options : ['warning_level=3',
                     'cpp_std=c++14'])

gtest_dep = dependency('gtest', fallback : ['gtest', 'gtest_dep'])

exe = executable('gtest_project', 'gtest_project.cpp',
  dependencies : [gtest_dep],
  install : true)

test('basic', exe)
# ------------------------------------------------
- meson build && cd build && ninja

Hope that helps

--
You received this message because you are subscribed to the Google Groups "The Meson Build System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mesonbuild+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mesonbuild/02f1e0fd-82ef-492e-8b51-063fef6214d8n%40googlegroups.com.

Șiclovan Sebastian-Ioan

unread,
Feb 10, 2022, 3:45:35 PM2/10/22
to The Meson Build System
Thanks,

But today I solved it like this:

""
  gtest_proj = subproject('gtest') 

  gtest_dep = gtest_proj.get_variable('gtest_dep') 
  gmock_dep = gtest_proj.get_variable('gmock_dep') 
  gtest_dep = dependency('gtest', main : true, required : false) 
  gmock_dep = dependency('gmock', main : true, required : false) 

  gtest_lib = static_library('gtest', install : true)
  gmock_lib = static_library('gmock', install: true) 

  tests_src = [ 'tests/phx_server_test.cpp' ]
     e = executable('LOGIC-BOARDS-DEV-TESTS',
                    sources : tests_src, 
                    dependencies : [THREAD_DEP, gtest_dep, gmock_dep],  
                    link_with : [gtest_lib, gmock_lib])
""

Mark as solved,
Reply all
Reply to author
Forward
0 new messages