junxnone / cmake Goto Github PK
View Code? Open in Web Editor NEWThis project forked from kitware/cmake
Mirror of CMake upstream repository
Home Page: https://gitlab.kitware.com/cmake/cmake
License: Other
This project forked from kitware/cmake
Mirror of CMake upstream repository
Home Page: https://gitlab.kitware.com/cmake/cmake
License: Other
enable_testing()
声明命名空间
CMake/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h
Lines 2 to 6 in 0876d54
使用命名空间
CMake/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx
Lines 10 to 19 in 0876d54
子项目声明为 INTERFACE
CMake/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt
Lines 5 to 7 in 0876d54
父项目不再需要包含子项目头文件
CMake/Help/guide/tutorial/Step4/CMakeLists.txt
Lines 30 to 32 in 0876d54
设置安装文件及位置
Tutorial
到 binTutorialConfig.h
到 includeCMake/Help/guide/tutorial/Step5/CMakeLists.txt
Lines 34 to 37 in 0876d54
lib 安装
lib
include
CMake/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
Lines 10 to 11 in 0876d54
TestCase
开启测试功能
定义单个 TestCase
Runs
Tutorial 25
测试帮助信息(设置 Test-Usage Pass 规则)
CMake/Help/guide/tutorial/Step5/CMakeLists.txt
Lines 46 to 49 in 0876d54
定义函数进行批量测试
CMake/Help/guide/tutorial/Step5/CMakeLists.txt
Lines 52 to 57 in 0876d54
CMake/Help/guide/tutorial/Step5/CMakeLists.txt
Lines 60 to 66 in 0876d54
测试结果 (make test
or ctest
)
$ make test
Running tests...
Test project /home/xxx/CMake/Help/guide/tutorial/Step5/build
Start 1: Runs
1/9 Test #1: Runs ............................. Passed 0.00 sec
Start 2: Usage
2/9 Test #2: Usage ............................ Passed 0.00 sec
Start 3: Comp4
3/9 Test #3: Comp4 ............................ Passed 0.00 sec
Start 4: Comp9
4/9 Test #4: Comp9 ............................ Passed 0.00 sec
Start 5: Comp5
5/9 Test #5: Comp5 ............................ Passed 0.00 sec
Start 6: Comp7
6/9 Test #6: Comp7 ............................ Passed 0.00 sec
Start 7: Comp25
7/9 Test #7: Comp25 ........................... Passed 0.00 sec
Start 8: Comp-25
8/9 Test #8: Comp-25 .......................... Passed 0.00 sec
Start 9: Comp0.0001
9/9 Test #9: Comp0.0001 ....................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 9
Total Test time (real) = 0.03 sec
$ctest -R Usage
$ctest -V -R Usage
添加 cpack
CMake/Help/guide/tutorial/Step8/CMakeLists.txt
Lines 68 to 74 in 0876d54
生成三种打包文件
中间文件夹 _CPack_Packages
_CPack_Packages
└── Linux
├── STGZ
│ ├── Tutorial-1.0-Linux
│ │ ├── bin
│ │ │ └── Tutorial
│ │ ├── include
│ │ │ ├── MathFunctions.h
│ │ │ └── TutorialConfig.h
│ │ └── lib
│ │ └── libMathFunctions.a
│ └── Tutorial-1.0-Linux.sh
├── TGZ
│ ├── Tutorial-1.0-Linux
│ │ ├── bin
│ │ │ └── Tutorial
│ │ ├── include
│ │ │ ├── MathFunctions.h
│ │ │ └── TutorialConfig.h
│ │ └── lib
│ │ └── libMathFunctions.a
│ └── Tutorial-1.0-Linux.tar.gz
└── TZ
├── Tutorial-1.0-Linux
│ ├── bin
│ │ └── Tutorial
│ ├── include
│ │ ├── MathFunctions.h
│ │ └── TutorialConfig.h
│ └── lib
│ └── libMathFunctions.a
└── Tutorial-1.0-Linux.tar.Z
适配 APPLE??
CMake/Help/guide/tutorial/Step12/CMakeLists.txt
Lines 26 to 30 in 0876d54
生成 config file
CMake/Help/guide/tutorial/Step12/CMakeLists.txt
Lines 97 to 102 in 0876d54
CMake/Help/guide/tutorial/Step12/CMakeLists.txt
Lines 111 to 115 in 0876d54
生成 version file
CMake/Help/guide/tutorial/Step12/CMakeLists.txt
Lines 104 to 108 in 0876d54
检查是否存在 log
& exp
函数
如果没有添加 m
library, 再检查一次,并把 m
library 添加到 target link library
CMake/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
Lines 10 to 22 in 0876d54
添加 编译器定义
CMake/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
Lines 25 to 28 in 0876d54
### flags.make
CXX_DEFINES = -DHAVE_EXP -DHAVE_LOG
### CMakeCache.txt
//Have symbol exp
HAVE_EXP:INTERNAL=1
//Have symbol log
HAVE_LOG:INTERNAL=1
CMake/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
Lines 14 to 18 in 0876d54
CMake/Help/guide/tutorial/Step11/CMakeLists.txt
Lines 11 to 16 in 0876d54
设置 本项目需要的最小 cmake 版本
设置 项目名称 & 版本号
设置 C++ 标准
C++11
CMake/Help/guide/tutorial/Step2/CMakeLists.txt
Lines 7 to 8 in 0876d54
配置从 cmake 配置中生成 头文件定义
TutorialConfig.h.in
TutorialConfig.h
(生成后放在 build
目录下)头文件模板
CMake/Help/guide/tutorial/Step2/TutorialConfig.h.in
Lines 2 to 3 in 0876d54
生成的头文件
#define Tutorial_VERSION_MAJOR 1
#define Tutorial_VERSION_MINOR 0
生成可执行文件
添加头文件搜索路径
build
路径= PRIVATE + INTERFACE
CMake/Help/guide/tutorial/Step2/CMakeLists.txt
Lines 19 to 21 in 0876d54
target 输出目录
CMake/Help/guide/tutorial/Step10/CMakeLists.txt
Lines 12 to 14 in 0876d54
????
CMake/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
Lines 38 to 40 in 0876d54
windows dllexport ??
CMake/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
Lines 45 to 47 in 0876d54
windows declspec ??
CMake/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h
Lines 2 to 14 in 0876d54
自定义编译选项
使用编译选项作为条件
CMake/Help/guide/tutorial/Step3/CMakeLists.txt
Lines 18 to 22 in 0876d54
编译选项变量生成到 头文件中在模板文件中的定义
生成的头文件
#define USE_MYMATH
/* #undef USE_MYMATH */
libMathFunctions.a
定义生成0~10 内的查找表 程序
生成查找表 Table.h
CMake/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
Lines 5 to 9 in 0876d54
### MathFunctions/Table.h
double sqrtTable[] = {
0,
1,
1.41421,
1.73205,
2,
2.23607,
2.44949,
2.64575,
2.82843,
3,
0};
链接查找表文件
CMake/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
Lines 12 to 15 in 0876d54
使用查找表
CMake/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
Lines 17 to 20 in 0876d54
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.