diff options
| -rw-r--r-- | test cases/common/14 configure file/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | unittests/allplatformstests.py | 41 |
2 files changed, 51 insertions, 0 deletions
diff --git a/test cases/common/14 configure file/CMakeLists.txt b/test cases/common/14 configure file/CMakeLists.txt new file mode 100644 index 000000000..6a894b0f8 --- /dev/null +++ b/test cases/common/14 configure file/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.12) + +project("configure file test" LANGUAGES C) + +set("var1" "foo") +set("var2" "bar") +configure_file("config7.h.in" "config7.h") + +set("var" "foo") +configure_file("config10.h.in" "config10.h") diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index c441b3982..8f56611d1 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -222,6 +222,47 @@ class AllPlatformTests(BasePlatformTests): confdata.values = {'VAR': (['value'], 'description')} self.assertRaises(MesonException, conf_str, ['#mesondefine VAR'], confdata, 'meson') + def test_cmake_configuration(self): + if self.backend is not Backend.ninja: + raise SkipTest('ninja backend needed to configure with cmake') + + cmake = ExternalProgram('cmake') + if not cmake.found(): + raise SkipTest('cmake not available') + + cmake_version = cmake.get_version() + if not version_compare(cmake_version, '>=3.13.5'): + raise SkipTest('cmake is too old') + + with tempfile.TemporaryDirectory() as tmpdir: + srcdir = os.path.join(tmpdir, 'src') + + shutil.copytree(os.path.join(self.src_root, 'test cases', 'common', '14 configure file'), srcdir) + self.init(srcdir) + + cmake_builddir = os.path.join(srcdir, "cmake_builddir") + self.assertNotEqual(self.builddir, cmake_builddir) + self._run([cmake.path, '-G', 'Ninja', '-S', srcdir, '-B', cmake_builddir]) + + header_list = [ + 'config7.h', + 'config10.h', + ] + + for header in header_list: + meson_header = "" + cmake_header = "" + + with open(os.path.join(self.builddir, header), encoding='utf-8') as f: + meson_header = f.read() + + cmake_header_path = os.path.join(cmake_builddir, header) + with open(os.path.join(cmake_builddir, header), encoding='utf-8') as f: + cmake_header = f.read() + + self.assertTrue(cmake_header, f'cmake generated header {header} is empty') + self.assertEqual(cmake_header, meson_header) + def test_absolute_prefix_libdir(self): ''' Tests that setting absolute paths for --prefix and --libdir work. Can't |
