随笔分类 -  CMakeLists

使用cmake管理项目的模板和参数说明
摘要:使用cmake管理项目的模板和参数说明 ** 假定名为MyCmakeTest,目录结构如下 MyCmakeTest ├── cmake │ ├── modules │ │ ├── Findffmpeg.cmake │ │ ├── FindGRPC.cmake │ │ └── FindProtobuf 阅读全文
posted @ 2024-09-25 16:36 林西索 阅读(216) 评论(0) 推荐(0)
配置环境变量,使CMakeLists.txt可直接使用Android NDK工具链编译项目
摘要:配置环境变量,使CMakeLists.txt可直接使用Android NDK工具链编译项目 下载NDK ** 下载时注意对应自己需要的版本 ** 官网下载https://developer.android.google.cn/ndk/downloads?hl=en#:~:text=Select%20 阅读全文
posted @ 2024-09-24 15:33 林西索 阅读(707) 评论(0) 推荐(0)
CMakeListx.txt --- include_directories和target_include_directories命令
摘要:1. include_directories 语法 include_directories ([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...]) 作用 将指定目录添加到编译器的头文件搜索路径之下,指定的目录被解释成当前源码路径的相对路径。 参数 默认情况下,includ 阅读全文
posted @ 2024-05-04 14:30 林西索 阅读(1215) 评论(0) 推荐(0)
CMakeLists.txt --- install使用
摘要:例: cmake_minimum_required(VERSION 3.9) project(test) set(CMAKE_BUILD_TYPE Debug) add_library(haha test.cpp) install(TARGET haha DESTINATION /home/linx 阅读全文
posted @ 2024-05-04 14:20 林西索 阅读(986) 评论(0) 推荐(0)
CMakeLists.txt --- 导入接口库(预编译库)
摘要:以接口库的方式导入预编译库 cmake_minimum_required(VERSION 3.9) project(test) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall -pthread ") set( 阅读全文
posted @ 2024-05-04 12:44 林西索 阅读(187) 评论(0) 推荐(0)
CMake --- .cmake文件的编写(find_package)
摘要:.cmake文件的编写 1.ffmepgConfig.cmake编写 if(CMAKE_VERSION VERSION_LESS 3.10) message(FATAL_ERROR "CMake 3.10 is required by Findffmpeg.cmake") endif() set(f 阅读全文
posted @ 2024-04-30 14:55 林西索 阅读(474) 评论(0) 推荐(0)
CMakeLists --- 指定安装目录 CMAKE_INSTALL_PREFIX
摘要:cmake指定make install时的安装目录:通过设置 CMAKE_INSTALL_PREFIX 的值来控制。 有两种方法: 1.在执行cmake时,指定安装目录: cmake -DCMAKE_INSTALL_PREFIX=/xxx/x .. 2.直接在CMakeLists.txt中设置 se 阅读全文
posted @ 2023-06-16 17:59 林西索 阅读(4008) 评论(0) 推荐(0)
CMakeLists --- 设置rpath_link方法 编译报错try using -rpath or -rpath-link)
摘要:指令:add_link_options("LINKER:-rpath-link,${THIRD_LIBS_DIR}") THIRD_LIBS_DIR:需要链接的库的目录 作用:编译生成一个可执行文件时,依赖一个动态库A,动态库A同时又依赖动态库B.如果我们没有显示集成动态库B时,链接器会去-rpat 阅读全文
posted @ 2023-06-16 17:52 林西索 阅读(1622) 评论(0) 推荐(0)
CMakeLists --- install和uninstall
摘要:install 假设生成了以下几个文件:静态库target1,动态库target2,可执行文件target3 1.安装文件至指定位置 #只安装静态库 install(TARGETS target1 LIBRARY DESTINATION lib ) #安装静态库,动态库,可执行文件 install( 阅读全文
posted @ 2023-05-31 19:17 林西索 阅读(933) 评论(0) 推荐(0)
CMakeLists --- 字符串查找替换
摘要:一.字符串的查找和替换 1.查找 string(FIND <string> <substring> <output_variable> <result> [REVERSE]) 使用说明: 从给定的string字符串中查找子字符串substring,返回子字符串在string中的位置如果提供了REVE 阅读全文
posted @ 2023-05-30 19:32 林西索 阅读(624) 评论(0) 推荐(0)
CMake --- 国内镜像
摘要:https://cmake.org/files/ 阅读全文
posted @ 2023-05-30 17:16 林西索 阅读(12349) 评论(0) 推荐(5)
CMakeLists --- add_subdirectory 添加子目录
摘要:命令格式: #添加一个子目录并构建该子目录。 add_subdirectory (source_dir [binary_dir] [EXCLUDE_FROM_ALL])#source_dir:子项目的CMakeLists.txt所在的目录#binary_dir:子项目产物的生成目录#EXCLUDE_ 阅读全文
posted @ 2023-05-25 18:51 林西索 阅读(624) 评论(0) 推荐(0)
CMakeLists --- 自定义变量,添加宏-add_definitions()函数
摘要:转载:https://blog.csdn.net/qq_35699473/article/details/115837708 引言 其实这个函数在安装一些库的时候,它的CMakeLists里面就有这样的函数。典型的就是opencv了。 opencv安装时候有一些指令也是针对这个函数的,比如安装命令( 阅读全文
posted @ 2023-04-28 15:32 林西索 阅读(2668) 评论(0) 推荐(0)
CMakeLists --- 交叉编译模板
摘要:#交叉编译模板 cmake_minimum_required (VERSION 3.8) set(PROJECT_NAME "demo")project(${PROJECT_NAME}) #编译选项option(32MOD "32or64" OFF) #设置编译器#编译器的路径需要配置到环境变量,不 阅读全文
posted @ 2022-08-21 16:15 林西索 阅读(434) 评论(0) 推荐(0)
CMakeLists --- 模板(常用指令)
摘要:# CMakeList.txt: Demo cmake_minimum_required (VERSION 3.8) set(PROJECT_NAME "demo")project(${PROJECT_NAME}) #编译选项option(32MOD "32or64" OFF) #设置生成程序的位数 阅读全文
posted @ 2022-08-21 16:13 林西索 阅读(516) 评论(0) 推荐(0)
CMakeLists --- 指定生成程序的位数
摘要:添加选项 生成32位程序: set(CMAKE_CXX_FLAGS -m32) set(CMAKE_C_FLAGS -m32) 64位: set(CMAKE_CXX_FLAGS -m64) set(CMAKE_C_FLAGS -m64) ps:如果不指定,会根据系统的版本来确定生成。 需要安装32位 阅读全文
posted @ 2022-08-02 19:27 林西索 阅读(1083) 评论(0) 推荐(0)
CMakeLists --- 指定链接顺序(error adding symbols: DSO missing from command line)
摘要:转载 https://www.cnblogs.com/Hocker/p/8269506.html https://www.cnblogs.com/OCaml/archive/2012/06/18/2554086.html#sec-1-1 关于链接库的顺序问题,我看了下链接库的顺序问题一文,正常的情况 阅读全文
posted @ 2022-08-02 19:15 林西索 阅读(635) 评论(0) 推荐(0)