Skip to content

Commit 47de165

Browse files
committed
TST: add test package depending on a cmake subproject
1 parent 2daa991 commit 47de165

File tree

8 files changed

+102
-0
lines changed

8 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2024 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
cdef extern from "cmaketest.hpp":
6+
cdef cppclass Test:
7+
Test(int) except +
8+
int add(int)
9+
10+
11+
def sum(int a, int b):
12+
t = new Test(a)
13+
return t.add(b)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-FileCopyrightText: 2024 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
project('cmake-subproject', ['c', 'cpp', 'cython'], version: '1')
6+
7+
dep = dependency('cmaketest')
8+
9+
py = import('python').find_installation()
10+
11+
py.extension_module(
12+
'cmakesubproject',
13+
'cmakesubproject.pyx',
14+
dependencies: dep,
15+
override_options: ['cython_language=cpp'],
16+
install: true,
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
[build-system]
6+
build-backend = 'mesonpy'
7+
requires = ['meson-python']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: 2024 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
[wrap-file]
6+
method = cmake
7+
8+
[provide]
9+
cmaketest = cmaketest_dep
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-FileCopyrightText: 2024 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
cmake_minimum_required(VERSION 3.5)
6+
7+
project(cmaketest)
8+
set(CMAKE_CXX_STANDARD 14)
9+
10+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
11+
12+
add_library(cmaketest SHARED cmaketest.cpp)
13+
14+
include(GenerateExportHeader)
15+
generate_export_header(cmaketest)
16+
17+
install(TARGETS cmaketest)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: 2024 The meson-python developers
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include "cmaketest.hpp"
6+
7+
Test::Test(int x) {
8+
this->x = x;
9+
}
10+
11+
int Test::add(int y) const {
12+
return x + y;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-FileCopyrightText: 2024 The meson-python developers
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#pragma once
6+
#include "cmaketest_export.h"
7+
8+
class CMAKETEST_EXPORT Test {
9+
private:
10+
int x;
11+
public:
12+
Test(int x);
13+
int add(int y) const;
14+
};

tests/test_wheel.py

+12
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,15 @@ def test_custom_target_install_dir(package_custom_target_dir, tmp_path):
362362
'package/generated/one.py',
363363
'package/generated/two.py',
364364
}
365+
366+
367+
@pytest.mark.skipif(sys.platform not in {'linux', 'darwin'}, reason='Not supported on this platform')
368+
def test_cmake_subproject(wheel_cmake_subproject):
369+
artifact = wheel.wheelfile.WheelFile(wheel_cmake_subproject)
370+
assert wheel_contents(artifact) == {
371+
'cmake_subproject-1.dist-info/METADATA',
372+
'cmake_subproject-1.dist-info/RECORD',
373+
'cmake_subproject-1.dist-info/WHEEL',
374+
f'.cmake_subproject.mesonpy.libs/libcmaketest{LIB_SUFFIX}',
375+
f'cmakesubproject{EXT_SUFFIX}',
376+
}

0 commit comments

Comments
 (0)