Key Concepts (Mastering CMake)
来源:互联网 发布:mac如何访问共享文件夹 编辑:程序博客网 时间:2024/06/05 06:30
1 Key Concepts (Mastering CMake)
1.1 Main Structures
Keyword
targets, generators and commands, etc.
Source files -> Targets [EXE|LIB]
Directory, Local Generator, Global Generator
Main Structure
1) cmake
- controls the cmake process
- can be created and used in various GUIs
2) cmake has one cmGlobalGenerator
- abstract base class
- child classes responsible for platform-specific build process
3) cmGlobalGenerator has many cmLocalGenerator
- abstract base class
- child classes responsible for platform-specific build file generation
4) cmLocalGenerator has one cmMakefile
Parse CMakeLists.txt and store information from CMakeLists.txt file
- List of targets and variables
- Optional flags
- List of libaries
- List of include pathes
5) cmCommand
- abstract base class
- child classes responsible for implementing all commands in CMake
1.2 Targets
add_library, add_executable and add_custom_target
EX#1
add_library (foo STATIC foo1.c foo2.c)
EX#2
add_library (foo foo.cxx)target_link_libraries (foo bar)add_executable (foobar foobar.cxx)target_link_libraries (foobar foo)
1.3 Source Files [TODO]
1.4 Directories, Generators, Tests, and Properties [TODO]
1.5 Variables and Cache Entries [TODO]
EX#1 Control Flow
set (FOO 1)if (${FOO} LESS 2) set (FOO 2)else (${FOO} LESS 2) set (FOO 3)endif (${FOO} LESS 2)
EX#2 Var Scope
function (foo) message (${test}) # test is 1 here set (test 2) message (${test})endfunction()set (test 1)foo()message (${test})
EX#3 Parent Scrope
function (foo) message (${test}) set (test 2 PARENT_SCOPE) message (${test)}endfunction()set (test 1)foo()message (${test}) # test will now be 2 here
EX#4 List
set (items_to_buy apple orange pear bear)foreach (item ${items_to_buy}) message ("Don't forget to buy one ${item}")endforeach()
EX#5 Option
option (USE_JPEG "Do you want to use the JPEG library")
or
set (USE_JPEG ON CACHE BOOL "include jpge support?")
TYPES: BOOL, PATH, FILEPATH, STRING
1.6 CheatSheet
1.6.1 Useful command:
include_directoriesadd_subdirectoryadd_libraryadd_executabletarget_link_librariesfind_package
1.6.1.1 Generate && Build
Case#1 Visual Studio Win64
>> cd build>> cmake -G "Visual Studio 14 2015 Win64" ..>> cmake --build .
Case#2 Visual Studio Win32
>> cd build>> cmake -G "Visual Studio 14 2015" ..>> cmake --build .
Case#3 Build Specific Target
>> cmake --build . --target HelloWorld
1.7 Reference
[1] CMake 3.0.2 Documetation
0 0
- Key Concepts (Mastering CMake)
- C/C++ key concepts
- CMake 基本语法(Mastering CMake 笔记)
- CMake 策略(Mastering CMake 笔记)
- C/C++ key concepts (1)
- 【译文】Mastering CMake 第二章 开始
- 【译文】Mastering CMake 第三章 关键概念
- 【译文】Mastering CMake(一)之为什么选择CMake
- Concepts
- 40 Key Computer Science Concepts Explained In Layman’s Terms
- A Note on CMake - 3 Key words
- Windows Phone Toolkit MultiselectList in depth | Part1: key concepts and API
- Mastering Ajax
- Mastering Perl
- Mastering Git
- Mastering ElasticSearch
- Mastering Markdown
- Mastering Markdown
- 很全很强大国内值得关注的官方API集合(太幸福啦)
- 《JS高程(3)》DOM扩展-API选择符-第11章笔记(18)
- C++学习一虚函数的实现方式
- 文章标题
- easyui datagrid load 参数表单序列化
- Key Concepts (Mastering CMake)
- springmvc--ResponseStatus注解处理异常
- 【Bzoj1083】繁忙的都市
- nil与null的区别
- 学习Hibernate_04_Hibernate参数设置一览表
- 微信H5video视频问题
- 利用nat123解决微信公众号对接服务器必须为80端口的问题
- Maven中央仓库信息速查
- CSS实现带箭头的DIV