Skip to content

Commit 5a0fdc7

Browse files
committed
Init Simple Conan_CMake Example
1 parent 6f1db2d commit 5a0fdc7

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
3+
project(FormatOutput LANGUAGES CXX C)
4+
5+
set(CMAKE_CXX_STANDARD 14)
6+
7+
find_package(fmt REQUIRED)
8+
9+
add_executable(main main.cpp)
10+
target_link_libraries(main PRIVATE fmt::fmt)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "fmt/color.h"
2+
3+
int main()
4+
{
5+
fmt::print(fg(fmt::terminal_color::cyan), "Hello fmt {}!\n", FMT_VERSION);
6+
return 0;
7+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[project]
2+
description = "A simple project showing how to use conan with CPPython"
3+
name = "cppython-conan-cmake-simple"
4+
version = "1.0.0"
5+
6+
license = {text = "MIT"}
7+
8+
authors = [
9+
{name = "Synodic Software", email = "[email protected]"},
10+
]
11+
12+
requires-python = ">=3.13"
13+
14+
dependencies = [
15+
"cppython>=0.1.0",
16+
]
17+
18+
[tool.cppython]
19+
generator-name = "cmake"
20+
provider-name = "conan"
21+
22+
install-path = "install"
23+
24+
dependencies = [
25+
"fmt>=11.0.1",
26+
]
27+
28+
[tool.cppython.generator]
29+
30+
[tool.cppython.provider]
31+
32+
[tool.pdm]
33+
distribution = false
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""TODO"""
2+
3+
import subprocess
4+
5+
from typer.testing import CliRunner
6+
7+
from cppython.console.entry import app
8+
9+
pytest_plugins = ['tests.fixtures.example']
10+
11+
12+
class TestVcpkgCMake:
13+
"""Test project variation of conan and CMake"""
14+
15+
@staticmethod
16+
def test_simple(example_runner: CliRunner) -> None:
17+
"""Simple project"""
18+
result = example_runner.invoke(
19+
app,
20+
[
21+
'install',
22+
],
23+
)
24+
25+
assert result.exit_code == 0, result.output
26+
27+
# Run the CMake configuration command
28+
cmake_result = subprocess.run(['cmake', '--preset=default'], capture_output=True, text=True, check=False)
29+
30+
assert cmake_result.returncode == 0, f'CMake configuration failed: {cmake_result.stderr}'
31+
32+
# Run the CMake build command
33+
build_result = subprocess.run(['cmake', '--build', 'build'], capture_output=True, text=True, check=False)
34+
35+
assert build_result.returncode == 0, f'CMake build failed: {build_result.stderr}'
36+
assert 'Build finished successfully' in build_result.stdout, 'CMake build did not finish successfully'
37+
38+
# Execute the built program and verify the output
39+
program_result = subprocess.run(['build/HelloWorld'], capture_output=True, text=True, check=False)
40+
41+
assert program_result.returncode == 0, f'Program execution failed: {program_result.stderr}'
42+
43+
assert 'Hello, World!' in program_result.stdout, 'Program output did not match expected output'

0 commit comments

Comments
 (0)