blob: cbe7fbcd70a9814533bcd6e360482ac9a744d5aa [file] [log] [blame]
Zane Shelleyfefc0162021-12-20 17:29:46 -06001# Get the gtest/gmock dependencies.
2gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
3gmock_dep = dependency('gmock', disabler: true, required: false)
4if not gtest_dep.found() or not gmock_dep.found()
5 cmake = import('cmake')
6 gtest_proj = cmake.subproject('googletest',
7 required: false)
8 if gtest_proj.found()
9 gtest_dep = declare_dependency(
10 dependencies: [
11 dependency('threads'),
12 gtest_proj.dependency('gtest'),
13 gtest_proj.dependency('gtest_main'),
14 ]
15 )
16 gmock_dep = gtest_proj.dependency('gmock')
17 else
18 assert(not get_option('tests').enabled(),
19 'Googletest is required if tests are enabled')
20 endif
21endif
22
Zane Shelleyad103b92019-07-31 15:57:54 -050023# build simulator
24subdir('simulator')
25
Ben Tynera8126fd2019-08-01 19:40:07 -050026# supporting files that need compiled/linked
Ben Tyner032bf9e2020-05-06 21:27:54 -050027test_src = ['../src/util/hei_bit_string.cpp',
Zane Shelley7649b8b2020-05-08 20:12:35 -050028 'sim_tracing.cpp']
Ben Tynera8126fd2019-08-01 19:40:07 -050029
30# build g-test framework unit tests
Zane Shelley200c3452019-09-26 11:46:30 -050031gtests = [
32 'bit_string_test',
Zane Shelley6eb61902020-05-15 22:25:58 -050033 'flyweight_test',
34 'operator_register_test',
Zane Shelley200c3452019-09-26 11:46:30 -050035]
Ben Tynera8126fd2019-08-01 19:40:07 -050036
Zane Shelleyfefc0162021-12-20 17:29:46 -060037foreach g : gtests
38 test(g, executable(g.underscorify(), g + '.cpp', test_src,
39 dependencies : gtest_dep,
40 include_directories : incdir))
41endforeach
Paul Greenwooddc47e0a2019-11-01 16:22:57 -050042