From 02fec5c637169b5e9127fbd9d754f2b364452383 Mon Sep 17 00:00:00 2001 From: ZtRXR Date: Sat, 15 Jun 2024 22:54:28 +0800 Subject: [PATCH] add pybind11_add_module --- src/pymake/cmake.py | 10 +++++++++- tests/generate_pybind11.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pymake/cmake.py b/src/pymake/cmake.py index 134d9f4..c0425bf 100644 --- a/src/pymake/cmake.py +++ b/src/pymake/cmake.py @@ -56,4 +56,12 @@ class cmake: def add_subdirectory(self,path:str)->Self: self.__write_stack__.append(f"add_subdirectory({path})") - return self \ No newline at end of file + return self + def pybind11_add_module(self, project_name:str=var(project_name), *source:str)->Self: + """ + cmake_minimum_required(VERSION 3.5...3.27) + project(example LANGUAGES CXX) + add_subdirectory(pybind11) + pybind11_add_module(example example.cpp) + """ + self.__write_stack__.append(f"pybind11_add_module({project_name} {args_to_str(source)})") diff --git a/tests/generate_pybind11.py b/tests/generate_pybind11.py index 0fc6472..f0a289c 100644 --- a/tests/generate_pybind11.py +++ b/tests/generate_pybind11.py @@ -3,5 +3,6 @@ from pymake import cmake ( cmake("3.15") + # TODO .write() ) \ No newline at end of file