Skip to content

Commit fe59ea0

Browse files
committed
build(cmake): add CMake presets, update settings
1 parent 6cac3cb commit fe59ea0

File tree

6 files changed

+112
-15
lines changed

6 files changed

+112
-15
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: black
3030
files: \.py$
31-
args: ['-S', '--line-length=100', '--target-version=py313']
31+
args: ['-S']
3232

3333
# Markdown linting and formatting
3434
- repo: https://github.com/DavidAnson/markdownlint-cli2

.vscode/settings.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
"cmake.configureOnEdit": true,
2020
"cmake.configureOnOpen": true,
2121
"cursorpyright.analysis.extraPaths": [
22-
"build/debug/binding",
23-
"build/release/binding"
22+
"build/debug-python/binding",
23+
"build/release-python/binding",
24+
"build/debug-python-no-tests/binding",
25+
"build/release-python-no-tests/binding",
26+
"build/debug-python-strict/binding",
27+
"build/release-python-strict/binding"
2428
],
2529
"editor.codeActionsOnSave": {
2630
"source.fixAll.clangd": "explicit",

CMakePresets.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,60 @@
9595
"ENABLE_CPPCHECK": "ON",
9696
"WARNINGS_AS_ERRORS": "ON"
9797
}
98+
},
99+
{
100+
"name": "debug-python",
101+
"displayName": "Debug Configuration (Python Bindings)",
102+
"description": "Debug build with Python bindings enabled",
103+
"inherits": "debug",
104+
"cacheVariables": {
105+
"BUILD_PYTHON_BINDINGS": "ON"
106+
}
107+
},
108+
{
109+
"name": "release-python",
110+
"displayName": "Release Configuration (Python Bindings)",
111+
"description": "Release build with Python bindings enabled",
112+
"inherits": "release",
113+
"cacheVariables": {
114+
"BUILD_PYTHON_BINDINGS": "ON"
115+
}
116+
},
117+
{
118+
"name": "debug-python-no-tests",
119+
"displayName": "Debug Configuration (Python Bindings, No Tests & Examples)",
120+
"description": "Debug build with Python bindings enabled, without tests and examples",
121+
"inherits": "debug-no-tests",
122+
"cacheVariables": {
123+
"BUILD_PYTHON_BINDINGS": "ON"
124+
}
125+
},
126+
{
127+
"name": "release-python-no-tests",
128+
"displayName": "Release Configuration (Python Bindings, No Tests & Examples)",
129+
"description": "Release build with Python bindings enabled, without tests and examples",
130+
"inherits": "release-no-tests",
131+
"cacheVariables": {
132+
"BUILD_PYTHON_BINDINGS": "ON"
133+
}
134+
},
135+
{
136+
"name": "debug-python-strict",
137+
"displayName": "Debug Configuration (Python Bindings, Static Analysis + Strict Warnings)",
138+
"description": "Debug build with Python bindings enabled, static analysis and warnings treated as errors",
139+
"inherits": "debug-strict",
140+
"cacheVariables": {
141+
"BUILD_PYTHON_BINDINGS": "ON"
142+
}
143+
},
144+
{
145+
"name": "release-python-strict",
146+
"displayName": "Release Configuration (Python Bindings, Static Analysis + Strict Warnings)",
147+
"description": "Release build with Python bindings enabled, static analysis and warnings treated as errors",
148+
"inherits": "release-strict",
149+
"cacheVariables": {
150+
"BUILD_PYTHON_BINDINGS": "ON"
151+
}
98152
}
99153
],
100154
"buildPresets": [
@@ -139,6 +193,48 @@
139193
"description": "Build release configuration with strict warnings",
140194
"configurePreset": "release-strict",
141195
"jobs": 0
196+
},
197+
{
198+
"name": "debug-python",
199+
"displayName": "Debug Build (Python Bindings)",
200+
"description": "Build debug configuration with Python bindings",
201+
"configurePreset": "debug-python",
202+
"jobs": 0
203+
},
204+
{
205+
"name": "release-python",
206+
"displayName": "Release Build (Python Bindings)",
207+
"description": "Build release configuration with Python bindings",
208+
"configurePreset": "release-python",
209+
"jobs": 0
210+
},
211+
{
212+
"name": "debug-python-no-tests",
213+
"displayName": "Debug Build (Python Bindings, No Tests & Examples)",
214+
"description": "Build debug configuration with Python bindings, without tests and examples",
215+
"configurePreset": "debug-python-no-tests",
216+
"jobs": 0
217+
},
218+
{
219+
"name": "release-python-no-tests",
220+
"displayName": "Release Build (Python Bindings, No Tests & Examples)",
221+
"description": "Build release configuration with Python bindings, without tests and examples",
222+
"configurePreset": "release-python-no-tests",
223+
"jobs": 0
224+
},
225+
{
226+
"name": "debug-python-strict",
227+
"displayName": "Debug Build (Python Bindings, Static Analysis + Strict Warnings)",
228+
"description": "Build debug configuration with Python bindings, static analysis and warnings treated as errors",
229+
"configurePreset": "debug-python-strict",
230+
"jobs": 0
231+
},
232+
{
233+
"name": "release-python-strict",
234+
"displayName": "Release Build (Python Bindings, Static Analysis + Strict Warnings)",
235+
"description": "Build release configuration with Python bindings, static analysis and warnings treated as errors",
236+
"configurePreset": "release-python-strict",
237+
"jobs": 0
142238
}
143239
],
144240
"testPresets": [

binding/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# Python bindings for cpp-demo-project
2-
# This directory contains pybind11 bindings for all C++ modules
3-
4-
cmake_minimum_required(VERSION 3.23)
1+
# Python bindings
52

63
# Ensure pybind11 is available
74
if(NOT TARGET pybind11::pybind11)
@@ -14,13 +11,13 @@ endif()
1411
# Create the main Python module
1512
pybind11_add_module(cpp_features
1613
cpp_features.cpp
17-
shapes_binding.cpp
18-
containers_binding.cpp
1914
algorithms_binding.cpp
15+
containers_binding.cpp
2016
exceptions_binding.cpp
2117
memory_binding.cpp
22-
timing_binding.cpp
2318
random_binding.cpp
19+
shapes_binding.cpp
20+
timing_binding.cpp
2421
)
2522

2623
# Link against all the required libraries

cmake/Dependencies.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ This function:
119119
120120
Dependencies:
121121
- Git (for fetching from GitHub)
122-
- Python 3.8+ development headers
123-
- pybind11 v2.13.0 from https://github.com/pybind/pybind11.git
122+
- Python 3.13+ development headers
123+
- pybind11 v3.0.0 from https://github.com/pybind/pybind11.git
124124
125125
Variables used:
126126
BUILD_PYTHON_BINDINGS - Must be ON to enable pybind11 setup
@@ -134,14 +134,14 @@ function(setup_pybind11_dependency)
134134
return()
135135
endif()
136136

137-
# Find Python first
138137
find_package(
139138
Python3
140139
COMPONENTS
141140
Interpreter
142141
Development
143142
QUIET
144143
)
144+
145145
if(NOT Python3_FOUND)
146146
message(WARNING "Python3 not found. Python bindings will not be built.")
147147
return()
@@ -155,7 +155,7 @@ function(setup_pybind11_dependency)
155155
FetchContent_Declare(
156156
pybind11
157157
GIT_REPOSITORY https://github.com/pybind/pybind11.git
158-
GIT_TAG v2.13.0
158+
GIT_TAG v3.0.0
159159
GIT_SHALLOW TRUE
160160
)
161161

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tests CMakeLists.txt
22

3-
# Check if Catch2 is available
3+
# Ensure Catch2 is available
44
if(NOT TARGET Catch2::Catch2WithMain)
55
if(NOT COMMAND catch_discover_tests)
66
message(

0 commit comments

Comments
 (0)