开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
标签 (37)
master
0.5.8
0.5.7
0.5.6
0.5.5
5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.22
0.4.21
0.4.20
0.4.19
0.4.18
0.4.17
0.4.16
0.4.15
0.4.14
0.4.13
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
贡献代码
同步代码
对比差异 通过 Pull Request 同步
同步更新到分支
通过 Pull Request 同步
将会在向当前分支创建一个 Pull
Request,合入后将完成同步
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

cpputils-cmake.el v0.5.8

http://stable.melpa.org/packages/cpputils-cmake-badge.svg

Perfect syntax check (Flymake) and code-completion if you use Flymake

  • auto-complete
  • company-mode
  • semantic
  • "M-x compile"
  • "M-x ff-find-other-file" (if you press `C-x C-o` in C/C++ file, ff-find-other-file will open correct header file under cursor)
  • Please note cpputils-cmake is independent on those plugins. Only CMake is required.

    Tested at Emacs 23.4, 24.3, 24.4

    Install

    Easy way

    cpputils-cmake is available at Manual way

    Download and place cpputils-cmake.el somewhere (say ~/.emacs/lisp), add below code into your .emacs:

    (add-to-list 'load-path "~/.emacs.d/lisp/")
    (require 'cpputils-cmake)
    

    Usage

    Insert below code into your .emacs:

    (add-hook 'c-mode-common-hook
     (lambda ()
     (if (derived-mode-p 'c-mode 'c++-mode)
     (cppcm-reload-all)
     )))
    ;; OPTIONAL, somebody reported that they can use this package with Fortran
    (add-hook 'c90-mode-hook (lambda () (cppcm-reload-all)))
    ;; OPTIONAL, avoid typing full path when starting gdb
    (global-set-key (kbd "C-c C-g")
     '(lambda ()(interactive) (gud-gdb (concat "gdb --fullname " (cppcm-get-exe-path-current-buffer)))))
    ;; OPTIONAL, some users need specify extra flags forwarded to compiler
    (setq cppcm-extra-preprocss-flags-from-user '("-I/usr/src/linux/include" "-DNDEBUG"))
    

    Quick start:

    • Step 1, The build directory should have the same name as value of cppcm-build-dirname. It is "build" by default. Make sure the build is located somewhere in the directory hierarchy from C++ file
    • Step 2, Go to build directory to run cmake and make at least once. The compile should be successful!

    If your project don’t use default path from CMake, check the section "Customize target path" in FAQ for the solution.

    Demo (OPTIONAL)

    Let’s start by creating a "hello world" C++ project:

    mkdir -p hello/src;printf "#include <stdio.h>\nint main(void) {\nprintf(\"hello world\");\nreturn 0;\n}" > hello/src/main.cpp;printf "cmake_minimum_required(VERSION 2.6)\nadd_executable(main main.cpp)" > hello/src/CMakeLists.txt
    

    flymake

    https://cloud.githubusercontent.com/assets/184553/5368660/cbc0c70c-805c-11e4-8723-a2ae752a549d.png

    flycheck

    https://cloud.githubusercontent.com/assets/184553/5368798/ca25c044-805e-11e4-9859-805601784519.png

    M-x compile

    https://cloud.githubusercontent.com/assets/184553/5368693/43295ad4-805d-11e4-9125-f21209c8bd88.png

    You can also `M-x cppcm-compile` to compile the current excutable only.

    gdb

    Press hotkey `C-c C-g` (I suppose you’ve copied my setup).

    gud-gdb starts and the binary "~/your-projects-blah-blah/hello/build/main" is loaded automatically.

    auto-complete

    You also need install auto-complete-clang. https://cloud.githubusercontent.com/assets/184553/5369140/721c9648-8063-11e4-9ab4-75f0e8ea88c8.png

    company-mode

    https://cloud.githubusercontent.com/assets/184553/5368579/c03fec24-805b-11e4-8fce-b611b2621318.png

    company-c-headers

    https://cloud.githubusercontent.com/assets/184553/5368489/e7b8ecf2-805a-11e4-8b06-818b96fb2049.png

    Open header file

    Press the hotkey `C-x C-o` or `M-x ff-find-other-file`. The corresponding header is opened.

    FAQ

    Avoid scanning system header files

    Scanning is light weight enough so below code is optional:

    (add-hook 'c-mode-common-hook
     (lambda ()
     (if (derived-mode-p 'c-mode 'c++-mode)
     (if (not (or (string-match "^/usr/local/include/.*" buffer-file-name)
     (string-match "^/usr/src/linux/include/.*" buffer-file-name)))
     (cppcm-reload-all))
     )))
    

    Get executable’s full path

    The command "cppcm-get-exe-path-current-buffer" will copy current executable into kill ring AND OS clipboard.

    You need install `xsel` under Linux to support OS clipboard.

    This could be useful if you need access the executable’s directory.

    You can yank (paste) the full path to eshell or minibuffer and press "M-backspace" to get the directory name.

    Reload cpputils-cmake

    You can always `M-x cppcm-reload-all` any time in C/C++ files.

    There is also `cppcm-reload-all-hook` which will be called after `cppcm-reload-all`. This give you a chance to tweak or override the setup if and only if you are Emacs Lisp expert. Most users don’t need tweak these global variables.

    Here is the list of global variables third party plugins use:

    variable name plugin
    ac-clang-flags auto-complete-clang
    company-clang-arguments company-mode
    cc-search-directories ff-find-other-file
    flycheck-clang-include-path flycheck
    semantic-dependency-system-include-path semantic
    company-c-headers-path-system company-c-headers

    Compile only current target

    "M-x cppcm-compile".

    Please press "C-h v cppcm-compile-list" for other compile options.

    Make clean && make

    "M-x cppcm-recompile"

    Customize target path

    For example, if the CMakeLists.txt contains something like this:

    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
    

    cpputils-cmake cannot find the target (executable or library).

    It will then call the variable cppcm-get-executable-full-path-callback which could be a function object.

    Here is a sample:

    (setq cppcm-get-executable-full-path-callback
     (lambda (path type tgt-name)
     ;; path is the supposed-to-be target's full path
     ;; type is either add_executabe or add_library
     ;; tgt-name is the target to built. The target's file extension is stripped
     (message "cppcm-get-executable-full-path-callback called => %s %s %s" path type tgt-name)
     (let* ((dir (file-name-directory path))
     (file (file-name-nondirectory path)))
     (cond
     ((string= type "add_executable")
     (setq path (concat dir "bin/" file)))
     ;; for add_library
     (t (setq path (concat dir "lib/" file)))
     ))
     ;; return the new path
     (message "cppcm-get-executable-full-path-callback called => path=%s" path)
     path))
    

    You can insert above code into ~/.emacs!

    Macro and included cmake file

    cpputils-cmake assumes that CMakeLists.txt contains a rule to create executable.

    *The rule is either "add_executable" or "add_library"*.

    Included file and macro in CMakeLists.txt will be ignored.

    A sample CMakeLists.txt we can handle:

    project(proj1)
    set(VAR2 "a2")
    set(VAR1 a1-${VAR2})
    set(TGT hello-${PROJECT_NAME}-${VAR1}")
    add_executable(${TGT} ${SOURCES})
    

    The executable’s name will be "hello-proj1-a1-a2".

    Stop creating Makefiles for flymake

    Insert below code into ~/.emacs:

    (setq cppcm-write-flymake-makefile nil)
    

    Credits

    Bug Report

    Check License

    Copyright (C) 2012 Chen Bin

    Author: Chen Bin <chenbin DOT sh AT gmail DOT com> Keywords: flymake IntelliSense cmake

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program. If not, see /redguardtoo/cpputils-cmake

    README
    取消

    发行版

    暂无发行版

    贡献者

    全部

    近期动态

    不能加载更多了
    编辑仓库简介
    简介内容
    主页
    马建仓 AI 助手
    尝试更多
    代码解读
    代码找茬
    代码优化
    Emacs Lisp
    1
    https://gitee.com/redguardtoo/cpputils-cmake.git
    git@gitee.com:redguardtoo/cpputils-cmake.git
    redguardtoo
    cpputils-cmake
    cpputils-cmake
    master
    点此查找更多帮助

    搜索帮助

    评论
    仓库举报
    回到顶部
    登录提示
    该操作需登录 Gitee 帐号,请先登录后再操作。
    立即登录
    没有帐号,去注册

    AltStyle によって変換されたページ (->オリジナル) /