Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

使用CLion编辑C工程

$
0
0

最近正在研究linux C代码编辑器,确实也不太喜欢SI(windows看代码还行,编辑一般,同步麻烦), 尝试使用CLion,但对makefile工程支持不好,怎么编译还没搞懂, 阅读、编辑还不错,智能提示、语法检查、函数跳转、查引用都挺好用的。

不过要想使用CLion的这些功能需要添加工程中的h文件到CMakeList.txt,

可参考如下脚本(把print结果添到CMakeList.txt里就行)

# !/usr/bin/env python
-*- coding: utf-8 -*- import

fnmatch

import

os

import def

find_file(path, file_exp):

for r, d, f in

os.walk(path):

for n in

fnmatch.filter(f, file_exp):

yield

os.path.join(r, n)

if __name__ == ' __main__ '

:

if len(sys.argv) != 2

:

print ( ' Usage: python get_h_cmakelist.py path_to_your_project '

)

exit(

-1

)

project_path

= sys.argv[1

]

h_dir

= [] for file in find_file(project_path, ' *.h '

):

file_dir

=

os.path.dirname(file)

if file_dir not in

h_dir:

h_dir.append(file_dir)

print ( ' include_directories({0}) ' .format( ' \r\n\t

'

.join(h_dir)))

结果类似

include_directories(E:\ids\suricata-3.1.2\libhtp\htp
E:\ids\suricata-3.1.2\libhtp\test
E:\ids\suricata-3.1.2\libhtp\test\gtest
E:\ids\suricata-3.1.2\src)

本文永久更新链接地址 : http://www.linuxidc.com/Linux/2017-03/141386.htm


Viewing all articles
Browse latest Browse all 9596

Trending Articles