首页 > 其他分享 >CMake 快速入门教程 All In One

CMake 快速入门教程 All In One

时间:2023-01-18 14:33:06浏览次数:62  
标签:functions CMake directories 入门教程 https include 快速 math

CMake 快速入门教程 All In One

CMake

CMake is an open-source, cross-platform family of tools designed to build, test and package software.
CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.
The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.

CMake 是一个开源的跨平台工具系列,旨在构建、测试和打包软件。
CMake 用于使用简单的平台和编译器独立配置文件来控制软件编译过程,并生成可在您选择的编译器环境中使用的本机 makefile工作区
CMake 工具套件是由 Kitware 创建的,旨在响应 ITK 和 VTK 等开源项目对强大的跨平台构建环境的需求。

https://cmake.org/

docs

include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])

https://cmake.org/cmake/help/latest/command/include_directories.html

target_include_directories(<target> [SYSTEM] [AFTER|BEFORE]
  <INTERFACE|PUBLIC|PRIVATE> [items1...]
  [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])

https://cmake.org/cmake/help/latest/command/target_include_directories.html#command:target_include_directories

shit docs 完全看不懂呀

https://cmake.org/examples/

target_include_directories (Hello PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

image

CMakeLists.txt

# ???
# add_library (MATH_FUNCTIONS math_functions.c)
# add_library (math_functions math_functions.c)
# add_library (math_functions ./mf/math_functions.c)
// add_library (add ./mf/math_functions.c)

# ❌ 不好使呀
include_directories(mf)
include_directories(BEFORE mf ${CMAKE_CURRENT_SOURCE_DIR})

vscode

搭建 C 语言开发环境 errors

# tree

// math_test.c
#include <stdio.h>

// 使用 自定义的头文件
#include "math_functions.h"

int main(){
  int a = 2;
  int b = 3;
  int sum = add(a, b); 
  printf("a=%d, b=%d, a+b=%d\n", a, b, sum);
}


/* 

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/xgqfrms-mm/Desktop/c-demos/math_test.c).C/C++(1696)

cannot open source file "math_functions.h"C/C++(1696)


 */

image

https://stackoverflow.com/questions/45583473/include-errors-detected-in-vscode

https://code.visualstudio.com/docs/cpp/faq-cpp#_what-is-the-difference-between-includepath-and-browsepath

(

标签:functions,CMake,directories,入门教程,https,include,快速,math
From: https://www.cnblogs.com/xgqfrms/p/17059729.html

相关文章

  • Labview视觉一键尺寸测量仪,多产品,多尺寸,快速编辑, 测量,导出结果
    Labview视觉一键尺寸测量仪,多产品,多尺寸,快速编辑,测量,导出结果​​查看资料来源​​......
  • Labview ,非标自动化软件通用程序框架,程序模块化新增,快速开发
    Labview,非标自动化软件通用程序框架,程序模块化新增,快速开发,只需配置表格,逻辑判断,循环跳转,变量新建,都在表格内实现,程序不需要改动,快速设备开发,自动化设备编写程序周期由2周......
  • VScode和cmake的组合拳
    cmake的基本使用1.cmake的常用指令cmake是一个跨平台的安装编译软件,可以用简单的语法规则描述所有平台的安装编译过程,下面介绍cmake的常用指令cmake_minimum_requir......
  • 简单几步快速完成爬虫任务
    #一、引入seleniumfromseleniumimportwebdriverfromtimeimportsleep#fromselenium.webdriver.chrome.optionsimportOptions#importxlrdimportcsvimportos#固定c......
  • 【jQuery超快速入门教程】上篇
    ......
  • 机械CAD中如何快速绘制对刀塞尺?
    在机械CAD制图过程中,当需要绘制对刀塞尺时,该如何操作?浩辰CAD机械软件集机械绘图、机构设计、数据管理于一体,提供了丰富的夹具库,可以一键绘制对刀塞尺,接下来的机械CAD制图教......
  • 如何使用 ST05 事物码,快速找到访问指定数据库表的 ABAP 代码试读版
    在实际项目开发过程中,ABAP顾问可能会经常接到这类需求:调研SAP标准产品某个功能的具体实现位置,在此基础上做增强开发。比如下图是SAPCRM产品主数据管理应用的搜索页......
  • D&C--快速排序
    分而治之->递归式问题解决方法工作原理:1,找出简单的基线条件2,确定如何缩小问题规模,使其符合基线条件。快速排序算法:1,取一个基准值,大于基准值的位于一个数组,小于基准值......
  • Nginx 快速入门
    一、Nginx快速入门1、Nginx概述1.1介绍​Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/PoP3)代理服务器。其特点是占有内存少,并发能力强......
  • Spring Cache 快速入门
    一、SpringCache快速入门1、SpringCache简介什么是SpringCache?SpringCache是一个框架,实现了基于注解的缓存功能,只需要简单地加一个注解,就能实现缓存功能。Spr......