当前位置: 首页 > 软件库 > 开发工具 > >

cmake-ide

Use Emacs as a C/C++ IDE
授权协议 BSD-3-Clause License
开发语言 C/C++
所属分类 开发工具
软件类型 开源软件
地区 不详
投 递 者 邹嘉荣
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

cmake-ide

Coverage StatusMelpa Status

CppCon 2015 Lightning talk on cmake-ide:

CppCon 2015 Lightning talk on cmake-ide

Introduction

cmake-ide is a package to enable IDE-like features on Emacs forCMake projects. It also supports non-CMakeprojects as long as acompilation databaseis generated out-of-band.This includes autocompletion and on-the-flysyntax checking in Emacs for CMake projects with minimalconfiguration. It uses other packages to do its heavy lifting, in acombination of:

cmake-ide will set variables and call functions for the installeddependent packages.

It works by running CMake in Emacs in order to obtain the necessarycompiler flags to pass to the other tools. Since allthe dependencies are specified in the CMake scripts, there is noneed to maintain a parallel dependency tracking system for Emacs.Just ask CMake.

Features

  • Sets variables for auto-complete-clang, flycheck and others for a CMakeproject automagically. Hardly any configuration necessary.
  • Automatically reruns CMake when a file is saved. Great when usingCMake file globs to pick up newly created files, but needscmake-ide-build-dir to be set.
  • cmake-ide-delete-file allows you to have the same convenience whendeleting files. I can't figure out a better way to do this. Obviouslysimply deleting the file means having to run CMake again manually forit to register the change in the list of files to be compiled.
  • If cmake-ide-build-dir is set, it is considered to be the builddirectory to run CMake in. Additionally, this will causecmake-ide-compile to compile the project there. It automaticallydetects Ninja and Make builds and sets the compile commandaccordingly. The command to use can be customised by settingthe cmake-compile-command variable.
  • cmake-ide can make usage ofrtags for findingdefinitions, also using clang. If (require 'rtags) is called beforecmake-ide-setup, it will automatically start the rtags server (rdm)and call rc -J to index the project files for 0-config "jump todefinition" and everything else rtags offers. This only works if bothrdm and rc and in the system path or if cmake-ide-rdm-executableand cmake-ide-rc-executable are customized correctly.

Build Pool Directories and Persistent Naming of Automatic Build Directories

cmake-ide can automatically create build directories for you -- either in the system'stmp-directory or under cmake-ide-build-pool-dir (if set). By default, all automaticallycreated build directories (no matter where created) will have temporary and unique names,that will change with each new session and are thus not reusable. You can, however, bysetting cmake-ide-build-pool-use-persistent-naming use a reproducible naming scheme thatis based on the project's path and will not change as long as the project's path is thesame. This way, you can reuse the build directory.

By using both cmake-ide-build-pool-dir and cmake-ide-build-pool-use-persistent-naming,you can fully do away with the need to configure a build directory per project with directorylocal variables (for example).

Non-CMake projects

Use .dir-locals.el to set the cmake-ide-project-dir and cmake-ide-build-dir variables(use absolute paths).

.dir-locals.el:((nil . ((cmake-ide-build-dir . "/path/to/build/dir")(cmake-ide-project-dir . "/path/to/project/dir"))))

If a file called compile_commands.json exists in cmake-ide-build-dir,it will work just as well as for CMake projects. Bear (https://github.com/rizsotto/Bear)can be used to generate a compile_commands.json from a make command.

Installation

Install from MELPA or MELPA Stable with:

M-x package-install RET cmake-ide.

Usage

Add this to your .emacs / init.el:

(require 'rtags) ;; optional, must have rtags installed
(cmake-ide-setup)

If cmake-ide-flags-c or cmake-ide-flags-c++ are set, they will beadded to ac-clang-flags and company-clang-arguments. Thesevariables should be set. Particularly, they should contain the systeminclude paths (e.g. '("-I/usr/include/c++/4.9.1" "..."). For asystem with gcc, you can get this information by running gcc -v -xc++ /dev/null -fsyntax-only (it's the same prerequisite forauto-complete-clang to work, since that's how clang itself works).

And... that's it. It works by calling cmake and parsing the resultingJSON file with compiler flags. Set cmake-ide-build-dir to where yourproject is being built and you won't have to call CMake manually again (exceptfor the first time to specify options). Best done withdirectory local variables.

Related Projects:

  • 对于 cmake ,一直理解为项目构建工具,知道遇到 --build 才发现,cmake 还统一了各个平台的编译阶段。下面摘抄知乎上大神的理解: 简单说一下cmake项目构建过程: 1、首先,使用命令行:‘cmake <source tree>’,比如:cmake .. ,在你的构建目录(外部构建方式)下生成了项目文件 project files,官方文档中又叫 build tree / bina

  • cmake --build . 该命令的含义是:执行当前目录下的构建系统,生成构建目标。 cmake项目构建过程简述: 1. 首先,使用命令行:‘cmake <source tree>’,比如:cmake .. ,在你的构建目录(外部构建方式)下生成了项目文件project files, 官方文档中又叫build tree/binary tree,这其中就包括,比如:Makefile,还有一些其他

  • 文档:cmake-generators(7) — CMake 3.23.1 Documentation 1.简介 CMake 生成器负责编写原生构建系统文件。 必须为构建树选择确切的生成器以确定要使用的本机构建系统。 可以选择额外生成器作为某些命令行构建工具生成器的变体,以生成辅助 IDE 的项目文件。 生成器决定了以下内容: 生成构建脚本:makefile、vcxproj 运行构建的 shell

  • 简介¶ 在使用 CMake 过程中,我们经常面临的一个问题是如何与其他人共享设置以获取配置项目的常用方法。这样做可以更好的支持 CI 构建,也可以使大多编译项目的人可以便捷的使用相同配置进行构建。 CMake (译者注:v3.19以上版本)支持两个主要配置文件: CMakePresets.json 和 CMakeUserPresets.json,用来支持用户指定常用配置选项并与他人共享。CMake

  • 提供信息的变量 CMAKE_AR 静态库归档工具的名称。 它指定创建归档库或静态库的程序的名称。 CMAKE_ARGC 在脚本模式下传递给CMake的命令行参数数。 当以-P脚本模式运行时,CMake将此变量设置为命令行参数的数量。参见【CMAKE_ARGV0】, 1, 2… CMAKE_ARGV0 在脚本模式下传递给CMake的命令行参数。 当以-P脚本模式运行时,CMake将该变量设置为第一个

  • 应用场景: 编译如opencv,或者重新编译pcl的vtk库支持Qt等,安装的VS版本过高,需要使用低版本VS编译工具。 问题描述 工作中使用到PCL,需要重新编译vtk库支持Qt可视化,由于我安装的是vs2022,pcl1.12的all-in-one安装包用vs2019编译的,因此vtk的库需要用vs2019编译工具进行编译,网上给的大部分解决方案都是降低VS的版本,得不偿失。 解决方案: 这里

  • 前言 用 CMake 来构建 C/C++ 项目是业内的主流做法。最近,我们的项目代码做了一些拆分和合并:引入其他仓库代码,并且将公共部分拆分以供多个仓库同时使用。为此,就得修改项目中的 CMake 以满足需求。 在做这件事情时,过程是相当痛苦的,修改的难度超过了我的预期。这份痛苦的回忆,让我陷入了沉思:这 CMake 咋这么不好使,是我的使用姿势不对吗?CMake 的最佳实践是啥? 在经过一番搜索

  • Cmake-Cookbook 相关资料整理: 原仓库:https://github.com/dev-cafe/cmake-cookbook 陈晓伟对CMake-Cookbook的中文翻译:https://github.com/xiaoweiChen/CMake-Cookbook CMake-Cookbook中文目录 官方文档: https://cmake.org/cmake/help/v3.12/

  • cmake -G的G应该是Generator的意思,该语句可以设置IDE,比如Xcode cmake -D 是用来设置编译器的 举两个使用的例子: //设置CC和CXX的环境变量 CC=gcc-4.2 CXX=/usr/bin/g++-4.2 cmake -G "Your Generator" path/to/your/source cmake -G "Your Generator" -D CM

  • 1.构建系统介绍 构建系统描述如何使用构建工具从其源代码构建项目的可执行文件和库,以自动化该过程。例如,一个构建系统可能是与命令行生成工具一起使用的Makefile,或者是集成开发环境(IDE)的项目文件。为了避免维护多个这样的构建系统,一个项目可以使用用CMake语言编写的文件抽象地指定它的构建系统。 源代码树 —— 源代码顶级目录 包含项目提供的源文件的顶级目录。该项目使用cmake-lang

  • CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。只是 CMake 的组态档取名为 CMakeLists.txt。Cmake 并不直接建构出最终的软件,而是产生标准的建构档(如 Unix 的 Makefile 或 Windows V

 相关资料
  • CMake 是一个跨平台的自动化构建系统,它使用一个名为 CMakeLists.txt 的文件来描述构建过程,可以产生标准的构建文件,如 Unix 的 Makefile 或Windows Visual C++ 的 projects/workspaces 。文件 CMakeLists.txt 需要手工编写,也可以通过编写脚本进行半自动的生成。CMake 提供了比 autoconfig 更简洁的语法。

  • 对于iOS项目的Cmake集成,没有很好的教程。互联网上找到的信息很少,但信息滞后。我有一个C项目,我想为我的iOS项目交叉编译它。我真的不是C和Cmake主题的专家。尽管如此,我还是关注了一个博客,这正是我想要的。 如博客中所述,我使用工具链来执行 Cmake 命令 它生成了<代码>。目录中的xcodeproj。 按照指示,我将生成的Xcode解决方案包含到我的主要iOS项目中,并将C项目添加到

  • ?> Hello world,世界 你好 本节选择了一个最简单的例子 Helloworld 来演练一下 cmake 的完整构建过程,本节并不会深入的探讨 cmake,仅仅展示一个简单的例子,并加以粗略的解释。我们选择了Everest Linux 作为基本开发平台,因为这个只有一张 CD 的发行版本,包含了 gcc4.2/gtk/qt3/qt4等完整的开发环境,同时,系统默认集成了 cmake 最新

  • 本文向大家介绍C++ 使用CMake生成构建环境,包括了C++ 使用CMake生成构建环境的使用技巧和注意事项,需要的朋友参考一下 示例 CMake可以从单个项目定义为几乎所有编译器或IDE生成构建环境。以下示例将演示如何将CMake文件添加到跨平台的“ Hello World” C ++代码。 CMake文件始终被命名为“ CMakeLists.txt”,并且应该已经存在于每个项目的根目录中(可

  • cmake-conan CMake wrapper for the Conan C and C++ package manager. This cmake module allows to launch conan install from cmake. The branches in this repo are: develop: PR are merged to this branch. La

  • CMake Cookbook This repository collects sources for the recipes contained in theCMake Cookbookpublished by Packt and authored by Radovan Bast andRoberto Di Remigio Contributing Testing Table of conten