Coder Social home page Coder Social logo

rendu-cxx-template's Introduction

概述

RenduCore是一个modern c++项目。 先从项目结构开始。使用rendu-cxx-template模版。 rendu-cxx-template是c++的cmake构建模版。 模版 :https://github.com/FRBoiling/rendu-cxx-template 目前包含cmake,dep,example,rendu,test,tool模块,后续添加 配置文件,脚本等模块。 模版目的是简化项目构建配置,以达到开发过程中尽量减少编写cmake,只关注c++代码实现的目的。 模版结构如下图所示

image.png

简介

cmake模块

cmake项目框架通用cmake封装

image.png

deps模块

一些外部依赖库

image.png

rendu模块

源代码(就是实际开中自己写的代码) 包括以下4个模块。commom,core,example,genrev

image.png

common模块

通用模块。基础的通用代码模块

image.png

core模块

项目核心,不同项目有各自的不同的实现

image.png

example模块

例子模块

image.png

genrev模块

生成项目版本信息

image.png 从项目中的revision_data.h.in.cmake文件生成版本内容代码(revision_data.h)

tests模块

unittest单元测试模块

image.png

使用

这个框架只需要添加对映模块的文件夹和代码即可,几乎不用关心cmake代码。 以下为概要(详细说明参照后续)

添加第三方依赖

源码方式引入

在dep文件夹添加对应第三方库源码 比如:fmt库,只需添加类似如下

set(target_name fmt)
rendu_add_library(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-dependency-interface
    DEPS
)

添加单元测试

tests文件夹中添加单元测试的cpp代码(依赖googletest单元测试) 比如:enum单元测试

image.png

set(target_name enum)
rendu_add_test(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-core-interface
    DEPS
    dep::magic_enum
    rendu::test
    DEFINES
    LINKOPTS
)

添加例子程序

example文件夹中添加例子程序代码。 例如:argparse的example 可执行文件如下。

set(target_name argparse)
rendu_add_executable(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-core-interface
    DEPS
    dep::argparse
    dep::magic_enum
    DEFINES
    LINKOPTS
)

添加项目相关核心代码

rendu文件夹中添加功能代码

1、添加通用实现库

common文件夹中通用代码

set(target_name common)
rendu_add_library(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-core-interface
    DEPS
)

2、添加逻辑实现库

core文件夹中添加实现代码

set(target_name core)
rendu_add_library(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-core-interface
    DEPS
    rendu::common
)

3、添加启动进程

launcher文件夹中添加启动进程代码

set(target_name launcher)
rendu_add_executable(
    DIR
    ${CMAKE_CURRENT_SOURCE_DIR}
    PROJECT
    ${PROJECT_NAME}
    NAME
    ${target_name}
    SETTING
    rendu-core-interface
    DEPS
    rendu::core
    rendu::common
    DEFINES
    LINKOPTS
)

rendu-cxx-template's People

Contributors

frboiling avatar

Stargazers

 avatar  avatar  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.