Giter Club home page Giter Club logo

cmakepplang's Introduction

CMakePPLang

https://github.com/CMakePP/CMakePPLang/actions/workflows/deploy_docs.yml/badge.svg?branch=master

CMakePPLang defines the basic extensions of the CMake language which comprise the CMakePP language. Think of this repo as being like the standard C++ library, except for CMake.

Statement of Need

CMake is arguably the de facto build tool for building C and C++ software packages of moderate to large size. Anecdotally we have observed that, as the size of a package grows, so too does the complexity of its build system. Object-oriented programming (OOP) is a popular and established technique for managing complexity in software and we assert that OOP can also be used to manage the complexity of the build system. Unfortunately, CMake is a functional language with no OOP support. Given the ubiquitous nature of CMake-based build systems and tools, the ideal OOP solution is to introduce OOP into CMake via a mechanism which preserves backwards compatibility with standard CMake.

We are not the first to suggest such a solution. To that end, Tobias Becker created the [CMake++](https://github.com/toeb/cmakepp) (formally called cmake-oo) module, which contains a number of CMake extensions including support for OOP. As of this writing, CMake++ seems to be an abandoned project with only two commits since July of 2017, both in 2021. As far as we know there are no other OOP CMake solutions out there.

Before creating CMakePPLang, we considered whether or not to attempt to resurrect CMake++. Looking through the CMake++ repo we were able to find a decent amount of user documentation, but little to no API or developer documentation. Ultimately, we decided that the effort needed to understand CMake++, document it with [CMinx](https://github.com/CMakePP/CMinx), and test it with [CMakeTest](https://github.com/CMakePP/CMakeTest) would be greater than writing a new, ground-up, OOP extension to CMake, and CMakePPLang was born.

Installation Instructions

CMakePPLang is distributed as a CMake module and can thus be included in CMake projects simply by adding:

# Download CMakePP and bring it into scope
include(FetchContent)
FetchContent_Declare(
   cmakepp_lang
   GIT_REPOSITORY https://github.com/CMakePP/cmakepp_lang
)
FetchContent_MakeAvailable(cmakepp_lang)

to your CMakeLists.txt file. CMakePPLang will then be downloaded as part of your project's CMake configuration step. More detailed instructions, can be found here.

If you would like to independently verify CMakePPLang works please see the instructions for running the test suite located in the developer documentation (link).

Example Usage

Once CMakePPLang is installed, it can be used in a CMake file by including it with:

include(cmakepp_lang/cmakepp_lang)

Here we define an Automobile class with the color attribute and a start() member function:

# Begin class definition
cpp_class(Automobile)

   # Define an attribute "color" with the value "red"
   cpp_attr(Automobile color red)

   # Define a function "start" that prints a message
   cpp_member(start Automobile)
   function("${start}" self)
      message("Vroom! I have started my engine.")
   endfunction()

# End class definition
cpp_end_class()

Now, an instance of this class can be created to get the value of the color attribute and call start():

# Create an instance of the class called "my_auto" using the default CTOR
Automobile(CTOR my_auto)

# Access the "color" attribute and save it to the var "my_autos_color"
Automobile(GET "${my_auto}" my_autos_color color)

# Print out the value of the var "my_autos_color"
message("The color of my_auto is: ${my_autos_color}")

# Output: The color of my_auto is: red

# Call the function using our Automobile instance
Automobile(start "${my_auto}")

# Output: Vroom! I have started my engine.

A complete list of CMakePPLang examples can be found here.

API Documentation

Full API documentation can be found here.

Contributing

In short, we try to be a welcoming community. If you have questions, suggestions, bug reports, etc. open an issue and we will address them as soon as possible. If you want to contribute code, that's even better. We recommend you start a draft PR early in the process so we know the contribution is coming and can help you along the way.

CMakePPLang is part of the CMakePP organization, whose contributing guidelines can be found here.

Developer documentation can be found here to help get started with CMakePPLang development.

cmakepplang's People

Contributors

ryanmrichard avatar zachcran avatar blakemulnix avatar autonomicperfectionist 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.