Code Monkey home page Code Monkey logo

pymake's Introduction

介绍

一个用python脚本的方式书写cmake的python库

如何安装

从release中安装

pip install <file name>

自行编译

pip install poetry
poetry install
poetry build
pip install ./dist/pymake-0.1.0-py3-none-any.whl

如何使用

生成一个用于GLFW编程的CMakeLists

from pymake import *

(
    cmake("3.20")
    .set(cmake_cxx_standard,"20")
    .set(cmake_cxx_flags,o3)
    .set(cmake_export_compile_cmmands,on)
    .project("test_glfw")
    .file("SRC",glob_recurse,"source/*.cpp","source/*.c")
    .add_executable(var(project_name),var("SRC"))
    .target_link_libraries("glfw3",var(project_name),public)
    .target_link_libraries("GL",var(project_name),public)
    .write()
)

自动生成如下

cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS -O3)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(test_glfw VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX)
file(GLOB_RECURSE SRC  source/*.cpp source/*.c)
add_executable(${PROJECT_NAME}  ${SRC})
target_link_libraries(${PROJECT_NAME} PUBLIC glfw3)
target_link_libraries(${PROJECT_NAME} PUBLIC GL)

生成一个库文件

from pymake import *

(
    cmake("3.20")
    .set(cmake_export_compile_cmmands,"ON")
    .set(cmake_cxx_flags,o3)
    .set(cmake_cxx_standard,"17")
    .project(name="say_hello")
    .add_library(var(project_name),static,"main.cpp")
    .target_include_directories(var(project_name),public,"include")
    .write()
)
python make.py

将会生成CMakeLists.txt如下

cmake_minimum_required(VERSION 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS -O3)
set(CMAKE_CXX_STANDARD 17)
project(say_hello VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX)
add_library(${PROJECT_NAME} STATIC  main.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC  include)

pymake's People

Contributors

ztrxr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.