blob: 863c047c65cb97fdca9d2b05d88d74ea938d2dad [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')
Patrick Williamsfffd9832025-02-01 08:38:36 -05006 gtest_proj = cmake.subproject('googletest', required: false)
Zane Shelleyfefc0162021-12-20 17:29:46 -06007 if gtest_proj.found()
8 gtest_dep = declare_dependency(
9 dependencies: [
10 dependency('threads'),
11 gtest_proj.dependency('gtest'),
12 gtest_proj.dependency('gtest_main'),
Patrick Williamsfffd9832025-02-01 08:38:36 -050013 ],
Zane Shelleyfefc0162021-12-20 17:29:46 -060014 )
15 gmock_dep = gtest_proj.dependency('gmock')
16 else
Patrick Williamsfffd9832025-02-01 08:38:36 -050017 assert(
18 not get_option('tests').allowed(),
19 'Googletest is required if tests are enabled',
20 )
Zane Shelleyfefc0162021-12-20 17:29:46 -060021 endif
22endif
23
Zane Shelleyad103b92019-07-31 15:57:54 -050024# build simulator
25subdir('simulator')
26
Ben Tynera8126fd2019-08-01 19:40:07 -050027# supporting files that need compiled/linked
Patrick Williamsfffd9832025-02-01 08:38:36 -050028test_src = ['../src/util/hei_bit_string.cpp', '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 Shelley72b755f2022-01-18 17:06:22 -060035 'test-util-hash',
Zane Shelley200c3452019-09-26 11:46:30 -050036]
Ben Tynera8126fd2019-08-01 19:40:07 -050037
Zane Shelleyfefc0162021-12-20 17:29:46 -060038foreach g : gtests
Patrick Williamsfffd9832025-02-01 08:38:36 -050039 test(
40 g,
41 executable(
42 g.underscorify(),
43 g + '.cpp',
44 test_src,
45 dependencies: gtest_dep,
46 include_directories: incdir,
47 ),
48 )
Zane Shelleyfefc0162021-12-20 17:29:46 -060049endforeach
Paul Greenwooddc47e0a2019-11-01 16:22:57 -050050