Cmake笔记

最简单的,只有一个源文件的 CMakeList.txt: cmake_minimum_required (VERSION 2.8) project (learn_cmake) add_executable(hello hello.cpp) $ mkdir build $ cd build/ $ cmake .. $ make 定义变量 set(SRC_LIST 1.c 2.c 3.c) add_executable(app ${SRC_LIST}) 通过EXECUTABLE_PUTPUT_PATH可以指定输出路径: set(HOME /home/xyc) set(EXECUTABLE_OUTPUT_PATH ${HOME}/bin) 搜索文件 方式 1:aux_source_directory 方式 2:file file(GLOB/GLOB_RECURSE 变量名 要搜索的文件路径和文件类型) file(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) GLOB: 将指定目录下搜索到的满足条件的所有文件名生成一个列表,并将其存储到变量中。 GLOB_RECURSE:递归搜索指定目录,将搜索到的满足条件的文件名生成一个列表,并将其存储到变量中。 包含头文件 include_directories(path) 动态库/静态库 制作静态库 add_library(库名称 STATIC 源文件1 [源文件2] ...) # 指定静态库输出路径 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 制作动态库 add_library(库名称 SHARED 源文件1 [源文件2] ...) # 指定动态库输出路径 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) # 动态库默认是有执行权限的,可以通过这种方式。 链接静态库 # 指明库路径 link_directories(${PROJECT_SOURCE_DIR}/lib) # 链接库 link_libraries(calc) # 可以是全名libxxx....

2024-08-12 · 1 min

Vim, Tmux, and Vim plugins

Basic Command-line :e {name of file} open file for editing :ls show open buffers :help {topic} open help :help :w opens help for the :w command :help w opens help for the w movement Movement Movements in Vim are also called “nouns”. Basic movement: hjkl (left, down, up, right) Words: w (next word), b (beginning of word), e (end of word) Lines: 0 (beginning of line), ^ (first non-blank character), $ (end of line) Screen: H (top of screen), M (middle of screen), L (bottom of screen) Scroll: Ctrl-u (up), Ctrl-d (down) File: gg (beginning of file), G (end of file) Line numbers: :{number}<CR> or {number}G (line {number}) Misc: % (corresponding item) Find: f{character}, t{character}, F{character}, T{character} find/to forward/backward {character} on the current line , / ; for navigating matches Search: /{regex}, n / N for navigating matches Edits Vim’s editing commands are also called “verbs”...

2023-12-13 · 5 min

正则表达式

References RegexOne github正则表达式 需要转义的特殊字符: * . ? + $ ^ [ ] ( ) { } | \ / Tutorials Lesson 1 The 123s \d any single digit character \D any single non-digit character Lesson 2: The Dot . any single character \. period Lesson 3: Matching specific characters [abc] only a, b, c single character Lesson 4: Excluding specific characters [^abc] not a, b or c Lesson 5: Character ranges [a-z] characters a to z...

2023-01-12 · 2 min