From adc8dd2aa84827534b7c9ccb604486446f8ec8fc Mon Sep 17 00:00:00 2001 From: "MARINA\\jpmug" Date: Wed, 31 May 2023 04:25:18 -0400 Subject: [PATCH] Additional things. 1. Googletests subdir was added. This requires GTest to be installed. If it is not installed, it's skipped 2. Moved some local variables to the main file to prevent duplicate library_finds and problems that can occur with local calculations. --- googletest/meson.build | 13 +++++++++++++ meson.build | 18 ++++++++++++++++++ test/meson.build | 29 ++++------------------------- 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 googletest/meson.build diff --git a/googletest/meson.build b/googletest/meson.build new file mode 100644 index 0000000..a839782 --- /dev/null +++ b/googletest/meson.build @@ -0,0 +1,13 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +gtest = cpp.find_library('gtest', required: false) +gtest_main = cpp.find_library('gtest_main', required: false) + +if gtest.found() and gtest_main.found() + feature_support_test = executable('Feature-Support-Test', 'feature_support_test.cpp', + dependencies : [gtest, gtest_main, dep_dxheaders, d3d12_lib, dxcore_lib], + cpp_args : test_compile_opts, + c_args : test_compile_opts) + test('Feature-Support-Test', feature_support_test) +endif diff --git a/meson.build b/meson.build index 0523ef6..4d64645 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,23 @@ project('DirectX-Headers', 'cpp', version : '1.610.0', default_options : ['cpp_std=c++14']) +cpp = meson.get_compiler('cpp') +compiler_id = cpp.get_id() +d3d12_lib = cpp.find_library('d3d12') +#dxcore is not available in Mingw-w64 +if compiler_id == 'msvc' + dxcore_lib = cpp.find_library('dxcore') +else + dxcore_lib = cpp.find_library('dxcore', required: false) +endif +test_compile_opts = [] +if host_machine.system() == 'windows' + test_compile_opts = ['-DUNICODE', '-D_WIN32_WINNT=0x0A00'] +endif +if (compiler_id == 'gcc') or (compiler_id == 'clang') + test_compile_opts += ['-Wno-unused-variable'] +endif + inc_dirs = [include_directories('include', is_system : true)] install_inc_subdirs = [''] compile_options = [] @@ -36,6 +53,7 @@ if meson.version().version_compare('>=0.54.0') endif if not meson.is_subproject() and get_option('build-test') + subdir('googletest') subdir('test') endif diff --git a/test/meson.build b/test/meson.build index 92274ef..8bb3003 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,36 +1,15 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -cpp = meson.get_compiler('cpp') -d3d12_lib = cpp.find_library('d3d12') - -compiler_id = cpp.get_id() - -#dxcore is not available in Mingw-w64 -if compiler_id == 'msvc' - dxcore_lib = cpp.find_library('dxcore') -else - dxcore_lib = cpp.find_library('dxcore', required: false) -endif - -t_compile_opts = [] -if host_machine.system() == 'windows' - t_compile_opts = ['-DUNICODE', '-D_WIN32_WINNT=0x0A00'] -endif - -if (compiler_id == 'gcc') or (compiler_id == 'clang') - t_compile_opts += ['-Wno-unused-variable'] -endif - headers_test = executable('DirectX-Headers-Test', 'test.cpp', dependencies : [dep_dxheaders, d3d12_lib, dxcore_lib], - cpp_args : t_compile_opts, - c_args : t_compile_opts) + cpp_args : test_compile_opts, + c_args : test_compile_opts) test('DirectX-Headers-Test', headers_test) headers_features_test = executable('DirectX-Headers-Check-Feature-Support-Test', 'feature_check_test.cpp', dependencies : [dep_dxheaders, d3d12_lib, dxcore_lib], - cpp_args : t_compile_opts, - c_args : t_compile_opts) + cpp_args : test_compile_opts, + c_args : test_compile_opts) test('DirectX-Headers-Check-Feature-Support-Test', headers_features_test)