Skip to content

Commit a5d96df

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

File tree

8 files changed

+78
-0
lines changed

8 files changed

+78
-0
lines changed

Diff for: tests/packages/cmake-subproject/cmakesubproject.pyx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cdef extern from "cmaketest.hpp":
2+
cdef cppclass Test:
3+
Test(int) except +
4+
int add(int)
5+
6+
7+
def sum(int a, int b):
8+
t = new Test(a)
9+
return t.add(b)

Diff for: tests/packages/cmake-subproject/meson.build

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
project('cmake-subproject', ['c', 'cpp', 'cython'], version: '1')
2+
3+
dep = dependency('cmaketest')
4+
5+
py = import('python').find_installation()
6+
7+
py.extension_module(
8+
'cmakesubproject',
9+
'cmakesubproject.pyx',
10+
dependencies: dep,
11+
override_options: ['cython_language=cpp'],
12+
install: true,
13+
)

Diff for: tests/packages/cmake-subproject/pyproject.toml

+7
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,5 @@
1+
[wrap-file]
2+
method = cmake
3+
4+
[provide]
5+
cmaketest = cmaketest_dep
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
project(cmaketest)
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
7+
8+
add_library(cmaketest SHARED cmaketest.cpp)
9+
10+
include(GenerateExportHeader)
11+
generate_export_header(cmaketest)
12+
13+
install(TARGETS cmaketest)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "cmaketest.hpp"
2+
3+
Test::Test(int x) {
4+
this->x = x;
5+
}
6+
7+
int Test::add(int y) const {
8+
return x + y;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
#include "cmaketest_export.h"
3+
4+
class CMAKETEST_EXPORT Test {
5+
private:
6+
int x;
7+
public:
8+
Test(int x);
9+
int add(int y) const;
10+
};

Diff for: 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/libexample{LIB_SUFFIX}',
375+
f'cmakesubproject{EXT_SUFFIX}',
376+
}

0 commit comments

Comments
 (0)