Code Monkey home page Code Monkey logo

cmaketemplate's Introduction

CMakeTemplate

描述

CMake项目模板

说明

目录说明

  • ./include - 头文件目录
  • ./lib - 库文件目录,外部库文件可放这里,同时项目生成的库文件也会放置在这里
  • ./src - 源文件目录
  • ./clear.sh - 清除已经生成的文件 (包括可执行文件、生成的Makefile文件,但不会清除库文件,需手动操作)
  • ./run.sh - 生成并运行 (默认不传递main函数参数)
  • ./bin - 存放可执行文件
  • ./LICENSE - 许可证,默认Apache License 2.0,可自行修改

请在项目中对应的CMakeLists.txt中添加对应指令以调用外部库。首先查找系统目录,若找不到对应的库,则自动会去./lib下寻找,无需拷贝到./bin中。

添加子项目

./src中添加子项目,并配置CMakeLists.txt文件 例如,在./src创建一个Test2的模块,请在./src/CMakeLists.txt中追加

# ./src/CMakeLists
add_subdirectory(Test2)

请确保./src/Test2/CMakeLists.txt存在,并有大约如下内容,这将生成一个共享库。

# ./src/Test2/CMakeLists.txt
project(Test2)

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC)
include_directories(${CMAKE_SOURCE_DIR}/include)
add_library(${PROJECT_NAME} SHARED ${SRC})

编译&运行

  • Linux或者OSX
sh run.sh

若要清理构建的文件(除库文件外),则可执行

sh clear.sh
  • 对于Windows
mkdir build
cd build
cmake ..
make
.\..\bin\app.exe

cmaketemplate's People

Contributors

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