[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.

CMakeLists.txt的写法的更多相关文章

  1. opencv的CMakeLists.txt与makefile写法

    opencv的CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(my_run_name) find_package(OpenCV R ...

  2. 怎么写自己的CMakeLists.txt

    一. 为什么要使用cmake 理论上说,任意一个C++程序都可以用g++来编译.但当程序规模越来越大时,一个工程可能有许多个文件夹和源文件,这时输入的编译命令将越来越长.通常一个小型C++项目可能含有 ...

  3. CMake之CMakeLists.txt编写入门

    自定义变量 主要有隐式定义和显式定义两种. 隐式定义的一个例子是PROJECT指令,它会隐式的定义< projectname >_BINARY_DIR和< projectname & ...

  4. 简单CMakeLists.txt文件

    #CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(server) #添加包含目录 include_directories(./in ...

  5. CMAKE 生成VS2008静态库工程 与 CMAKE使用,CMakeLists.txt编写总结

    cmake -G"Visual Studio 9 2008 Win64" 以上命令得用cd命令切换到顶层CMakeLists.txt的当前目录,才能生效 以下是CMakeLists ...

  6. Android Studio Linking an external C++ project 时候 报Invalid file name. Expected: CMakeLists.txt

    Android Studio 右键Linking an external C++ project 时候 报Invalid file name. Expected: CMakeLists.txt错误 查 ...

  7. CMake Intro - CMakeLists.txt

    Notes:  directory structure:  cmake, cmake/Tutorial, cmake/Tutorial/MathLibs 1. File lists in cmake/ ...

  8. 使用CMakeLists.txt 判断编译器是否支持C++11

    #将下面的内容添加到CMakeLists.txt当中include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11&quo ...

  9. Cmake知识----编写CMakeLists.txt文件编译C/C++程序

    1.CMake编译原理 CMake是一种跨平台编译工具,比make更为高级,使用起来要方便得多.CMake主要是编写CMakeLists.txt文件,然后用cmake命令将CMakeLists.txt ...

随机推荐

  1. 【381】python 获取列表中重复元素的索引值

    参考:获取python的list中含有重复值的index方法_python_脚本之家 核心思想:建立字典,遍历列表,把列表中每个元素和其索引添加到字典里面 cc = [1, 2, 3, 2, 4] f ...

  2. vmware搭建lnmp环境配置域名

    找到nginx配置文件,修改server_name 然后找到/etc/hosts文件 修改成如下 之后在Windows本地的C盘的hosts文件中添加解析 好了,这样就可以访问了 通往牛逼的路上,在意 ...

  3. VMware安装RHEL5.5后修改分辨率设置

    1.进入桌面后,点击System -> Administration -> Display,选择Hardware,点击Monitor Type后面的Configure(默认是autocon ...

  4. [Redis]Redis的快速配置使用(图)

    --------------------------------------------------------------------------------------------------- ...

  5. sp_executesql 或者 EXECUTE 执行动态sql的权限问题

    当 sp_executesql 或 EXECUTE 语句执行字符串时,字符串将作为它的自包含批处理执行.SQL Server 会将字符串中的一个或多个 Transact-SQL 语句编译为独立于批处理 ...

  6. html中,纯数字或纯英文的一串字符超出父容器不会折行显示,如何解决?

    这种情况在软件使用过程中一般不会出现,只有测试人员在测试的时候手比较贱会给你弄一个这种数据,当然这也算是bug吧. 如图:“经营范围”的值严重超出父容器长度,并且没有像“服务信息”一样折行显示.这种情 ...

  7. javascript 中Array.prototype.sort 函数的用法

    来源:http://www.jb51.net/article/5769.htm JavaScript中对变量的操作都是通过引用方式,而对数组也一样. 前两天想要对一个数组进行复制,一直苦于找不到办法( ...

  8. spring boot 访问jsp 弹出下载

    在pom.xml中加入以下jar 包 <!-- 引入Spring Boot 内嵌的Tomcat对jsp的解析包--><dependency> <groupId>or ...

  9. Monkey测试结果分析【转】

    转自[http://www.douban.com/note/257030241/] Monkey测试结果分析 一. 初步分析方法: Monkey测试出现错误后,一般的差错步骤为以下几步: 1. 找到是 ...

  10. 学JS的心路历程-JS支持面向对象?(一)

    昨天在看Prototype看到JS支持面向对象,被前辈问到说那什么是面向对象?JS是面向对象语言吗? 便开始了一连串艰辛爬文过程,今天就来看一下两者有什么差异吧(rgwyjc)! 首先面向对象有三大特 ...