-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: add test package depending on a cmake subproject
- Loading branch information
Showing
8 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPDX-FileCopyrightText: 2024 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
cdef extern from "cmaketest.hpp": | ||
cdef cppclass Test: | ||
Test(int) except + | ||
int add(int) | ||
|
||
|
||
def sum(int a, int b): | ||
t = new Test(a) | ||
return t.add(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-FileCopyrightText: 2024 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
project('cmake-subproject', ['c', 'cpp', 'cython'], version: '1') | ||
|
||
dep = dependency('cmaketest') | ||
|
||
py = import('python').find_installation() | ||
|
||
py.extension_module( | ||
'cmakesubproject', | ||
'cmakesubproject.pyx', | ||
dependencies: dep, | ||
override_options: ['cython_language=cpp'], | ||
install: true, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2021 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
[build-system] | ||
build-backend = 'mesonpy' | ||
requires = ['meson-python'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SPDX-FileCopyrightText: 2024 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
[wrap-file] | ||
method = cmake | ||
|
||
[provide] | ||
cmaketest = cmaketest_dep |
17 changes: 17 additions & 0 deletions
17
tests/packages/cmake-subproject/subprojects/cmaketest/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-FileCopyrightText: 2024 The meson-python developers | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(cmaketest) | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
add_library(cmaketest SHARED cmaketest.cpp) | ||
|
||
include(GenerateExportHeader) | ||
generate_export_header(cmaketest) | ||
|
||
install(TARGETS cmaketest) |
13 changes: 13 additions & 0 deletions
13
tests/packages/cmake-subproject/subprojects/cmaketest/cmaketest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-FileCopyrightText: 2024 The meson-python developers | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "cmaketest.hpp" | ||
|
||
Test::Test(int x) { | ||
this->x = x; | ||
} | ||
|
||
int Test::add(int y) const { | ||
return x + y; | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/packages/cmake-subproject/subprojects/cmaketest/cmaketest.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-FileCopyrightText: 2024 The meson-python developers | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
#include "cmaketest_export.h" | ||
|
||
class CMAKETEST_EXPORT Test { | ||
private: | ||
int x; | ||
public: | ||
Test(int x); | ||
int add(int y) const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters