blob: 612851793928fb8bbd93db6a60a5381d89c70fe8 [file] [log] [blame]
William A. Kennington IIIbb259732021-05-05 12:35:01 -07001gtest = dependency('gtest', main: true, disabler: true, required: false)
2gmock = dependency('gmock', disabler: true, required: false)
3if not gtest.found() or not gmock.found()
Patrick Williamsa385d892025-02-01 08:37:40 -05004 gtest_opts = import('cmake').subproject_options()
5 gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'})
6 gtest_proj = import('cmake').subproject(
7 'googletest',
8 options: gtest_opts,
9 required: false,
10 )
11 if gtest_proj.found()
12 gtest = declare_dependency(
13 dependencies: [
14 dependency('threads'),
15 gtest_proj.dependency('gtest'),
16 gtest_proj.dependency('gtest_main'),
17 ],
18 )
19 gmock = gtest_proj.dependency('gmock')
20 else
21 assert(not get_option('tests').allowed(), 'Googletest is required')
22 endif
William A. Kennington IIIbb259732021-05-05 12:35:01 -070023endif
24
25tests = [
Brad Bishop59061732019-10-07 15:48:37 -040026 'average_unittest',
Brad Bishop59061732019-10-07 15:48:37 -040027 'env_unittest',
Brad Bishop59061732019-10-07 15:48:37 -040028 'fanpwm_unittest',
Brad Bishop59061732019-10-07 15:48:37 -040029 'hwmon_unittest',
Brad Bishop59061732019-10-07 15:48:37 -040030 'hwmonio_default_unittest',
Brad Bishop59061732019-10-07 15:48:37 -040031 'sensor_unittest',
William A. Kennington IIIbb259732021-05-05 12:35:01 -070032]
33
34foreach t : tests
35 test(
36 t,
37 executable(
38 t.underscorify(),
39 t + '.cpp',
40 'gpio.cpp',
41 implicit_include_directories: false,
Patrick Williamsa385d892025-02-01 08:37:40 -050042 dependencies: [hwmon_dep, gtest, gmock],
43 ),
44 )
William A. Kennington IIIbb259732021-05-05 12:35:01 -070045endforeach