CMakeLists.txt的写法

[1]ADD_LIBRARY: Add a library to the project using the specified source files.要求CMake根据指定的源文件生成库文件 .

?  ADD_LIBRARY(libname [SHARED | STATIC | MODULE]
[EXCLUDE_FROM_ALL]   source1 source2 ... sourceN)Adds a
library target.

SHARED, STATIC or MODULE keywords are used to set the
library type. If the keyword MODULE appears, the library type is set to
MH_BUNDLE on systems which use dyld. On systems without dyld, MODULE is
treated like SHARED. If no keywords appear as the second argument, the
type defaults to the current value of BUILD_SHARED_LIBS. If this
variable is not set, the type defaults to STATIC.

If EXCLUDE_FROM_ALL is given the target will not be built by default. It will be built only if the user explicitly builds the target or another target that requires the target depends on it.

[2]INCLUDE_DIRECTORIES: Add include directories to the build.添加查找头文件的路径

? INCLUDE_DIRECTORIES([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)Add the
given directories to those searched by the compiler for include files.
By default the directories are appended onto the current list of
directories. This default behavior can be changed by
setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. By using BEFORE or
AFTER you can select between appending and prepending, independent from
the default. If the SYSTEM option is given the compiler will be told
that the directories are meant as system include
directories on some platforms.

[3]LINK_DIRECTORIES: Specify directories in which to search for libraries.添加库文件的搜索路径

LINK_DIRECTORIES(directory1 directory2 ...)

[4]TARGET_LINK_LIBRARIES: Link a target to given libraries.为每个目标分别指定需要链接的库文件(指定部分目标专用的库文件)

TARGET_LINK_LIBRARIES(target library1  <debug | optimized> library2   ...)Specify a list of libraries to be linked into the specified target. The debug and optimized strings may be used to indicate that the next library listed is to be used only for that specific type of build

[5]LINK_LIBRARIES: Link libraries to all targets added later.为所有目标统一指定需要的库文件(指定所有目标都用的库文件)

LINK_LIBRARIES(library1 <debug | optimized> library2 ...)This is
an old CMake command for linking libraries. Use TARGET_LINK_LIBRARIES
unless you have a good reason for every target to link to the same set
of libraries.

Specify a list of libraries to be linked into any following targets (typically added with the ADD_EXECUTABLE or ADD_LIBRARY calls). This command is passed down to all subdirectories. The debug and optimized strings may be used to indicate that the next library listed is to be used only for that specific type of build.

时间: 2024-11-13 09:39:54

CMakeLists.txt的写法的相关文章

linux CMakeLists.txt 语法

CMake入门教程 参考文献:http://www.ibm.com/developerworks/cn/linux/l-cn-cmake/index.html 官方网址:http://www.cmake.org/ 下载网址:http://www.cmake.org/download/ 当前版本:3.1rc3 本文基于CMake 2.8版本编写. CMake 是一个跨平台的,开源的构建系统(BuildSystem).CMake 可以通过 CMakeLists.txt 文件来产生特定平台的标准的构建

简单CMakeLists.txt文件

#CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(server) #添加包含目录 include_directories(./include) #添加源文件 aux_source_directory(./src DIR_SRC) #添加头文件 SET(HEADERS include/hello.h ) #可执行文件 add_executable( ${PROJECT_NAME} ${DIR_SRC} ${HEADERS})

ROS中的CMakeLists.txt

在ROS的编程过程中,如果CMakeLists.txt如果写不好,编译就很难成功.如果看不懂CMakeLists.txt那么很多错误你也不知道时什么回事.所以深入了解它是很有必要的.现在我们就来看看它. 我们使用cmake进行程序编译的时候,会根据CMakeLists.txt这个文件进行一步一步的处理,然后形成一个MakeFile文件,系统再通过这个文件的设置进行程序的编译. 我们可以先寻找一些cmake方面的东西进行一定的了解.ROS中的CMakeLists.txt也是基于普通的cmake的.

cmake 学习-cmakelists.txt

#设置库的路径,电脑里有qt4以及qt5,使用qt5时 设置qt5的环境变量(路径). 1 set(CMAKE_PREFIX_PATH $ENV{QTDIR}) 2 #设定工程名称 3 Project(proname) 4 #设置CMake最低版本要求 5 cmake_minimum_required(VERSION 3.6.0) 6 7 #设置需要用到的Qt模块 8 9 FIND_PACKAGE(Qt5Core) #包含qt5core的头文件 10 include_directories(${

《Cmake 实践》[初试 cmake – cmake 的 helloworld] CMakeLists.txt错误

书中所写CMakeLists.txt截图: 构建时报错: 原因:最后一行引用SRC_LIST变量需要添加${}符号,正确的代码如下: 再次构建成功

ros项目 CMakeLists.txt中添加自己的库路径

原创博文,转载请标明出处:http://www.cnblogs.com/yongpan/p/6657400.html 在 ros 功能包中要使用第三方的动态库,将其放在系统默认库路径和使用绝对路径均不可取,这样的话可移植性较差,将该功能包移到其它电脑时要重新配置依赖库的路径,太麻烦了. 于是找到下面这个方法,解决了ROS功能包中添加库路径的问题. 注:此法针对 ros catkin编译. 在ROS功能包下的CMakeLists.txt 中添加 如下代码: link_directories( ${

CMakeLists.txt编辑器--emacs

本文来自多方查询,目前我还是第一次使用emacs,所以有很多问题在emacs高手看来可能会比较幼稚,但是这并不影响我把这个神之编辑器以及怎样用这个神之编辑器写CMakeLists.txt的方法分享出来 一.安装 此处不现说明 二.禁止备份+行号显示 刚刚安装好的emacs会自动创建备份文件,可以在家目录中新建一个.emacs 文件,加入以下内容 ;;禁止备份 (setq make-backup-files nil) 参考自:http://blog.csdn.net/flytomysky/arti

ROS知识(8)----CMakeLists.txt文件编写的理解

ROS(Indigo)编程必须要理解CMakeList.txt的编写规则,教程地址:catkin/CMakeLists.txt,官网有相关的教程,中文的翻译版本写的很不错,教程地址:ROS中的CMakeLists.txt

CMakeLists.txt

CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程).他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake. CMake 使用方法 CMake的所有的语句都写在一个叫:CMakeLists.txt的文件中.当CMakeLists.txt文件确定后,可以用ccmake命令对相关 的变量值进行配置.这个命令必须指向CMakeLists.txt所在的目录.配置完成之后,应用cmake命令生成相