当前位置:网站首页>Cmake tutorial series -02- generating binaries using cmake code
Cmake tutorial series -02- generating binaries using cmake code
2022-06-30 02:36:00 【Ordinary people who like playing basketball】
List of articles
1.Cmake Installation
- Reference resources :Cmake Installation and upgrade (Ubuntu)
2.Win10 Next use CMake GUI
Win10 The installation files :
The created directory and code are as follows :
- CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(sample CXX)
add_library(sample sample.cpp)
add_executable(sample_exe sample_exe.cpp)
- sample.cpp
#include <iostream>
int print_hello_world()
{
std::cout << "hello world!" << std::endl;
return 0;
}
- The directory structure is as follows : Pay attention to creating one more build The directory stores intermediate files and final binary files

Click on “Configure
- Mine vs yes 2019, stay Configure I chose

Click on “Configure” Dexter “Generate”.
Click on “Generate” Dexter “Open Projrct”.
- It can be seen that for Visual Studio The configuration of has been completely generated , At this point, you only need to build ALL_BUILD Library can be generated sample And executables sample_exe


2.win Use the command line to build the project
- Reference resources :cmake(1)
Use the code file above , Open the command line , And enter the following command :
E:\CmakeTest>cmake.exe -S E:\\CmakeTest -B E:\\CmakeTest\build -G "Visual Studio 16 2019" -A x64
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The CXX compiler identification is MSVC 19.29.30141.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: E:/CmakeTest/build
Execute the following command to generate the library file and binary program :
E:\CmakeTest>cmake --build E:\\CmakeTest\build
be used for .NET Framework Of Microsoft (R) Build engine version 16.11.2+f32259642
copyright (C) Microsoft Corporation. All rights reserved .
Checking Build System
sample_exe.cpp
sample.vcxproj -> E:\CmakeTest\build\Debug\sample.lib
sample_exe.cpp
sample_exe.vcxproj -> E:\CmakeTest\build\Debug\sample_exe.exe
Building Custom Rule E:/CmakeTest/CMakeLists.txt
3. Several important command line arguments
-S
- top CMakeLists.txt( contain project Statement ) Location path .
-B
- Store temporary compiled binary files (.obj、.ilk etc. ) The configuration file path corresponding to the compiler .
-G
- Compiler name
-A
- Architecture name
-D
- Use this variable to add to cmake Pass in various parameters . Include options and overrides cmake Various default variable values provided .
--toolchain
- cmake toolchain File path .
--install-prefix
- The binary storage path of the installation .
--trace / --trace-expand
- Used during commissioning , Used to print executed cmake Code and line number . Otherwise, only the function is output message The content in .
--build
- Use cmake Directly call the compiler to compile the project .
--config
- Select the project configuration type to compile .
--install
Install the compiled binaries to CMAKE_INSTALL_PREFIX in .
Reference resources :CMake Tutorial series -02- Use cmake Code generation binary
边栏推荐
- 代码签名、驱动签名的常见问题解答
- Heap sort
- 归并排序
- [on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact
- Differences among digicert, SECTIONO and globalsign code signing certificates
- Implementation of Sanzi chess with C language
- Two methods of SSL certificate format conversion
- Alphassl digital certificate
- [dry goods sharing] the latest WHQL logo certification application process
- 最小栈详解
猜你喜欢

Playful palette: an interactive parametric color mixer for artists

Sitelock nine FAQs

Precautions for purchasing wildcard SSL certificate

2.< tag-动态规划和0-1背包问题>lt.416. 分割等和子集 + lt.1049. 最后一块石头的重量 II

Implementation of Sanzi chess with C language

主流CA吊销俄罗斯数字证书启示:升级国密算法SSL证书,助力我国网络安全自主可控

JMeter obtains cookies across thread groups or JMeter thread groups share cookies

Creating exquisite skills in maker Education

SSL证书格式转化的两种方法

Several key points recorded after reviewing redis design and Implementation
随机推荐
Several key points recorded after reviewing redis design and Implementation
SQL injection -day17
DHU programming exercise
Global and Chinese market of relay lens 2022-2028: Research Report on technology, participants, trends, market size and share
Sitelock nine FAQs
Xunwei NXP itop-imx6 development platform
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation
Le Code autojs peut - il être chiffré? Oui, présentation des techniques de chiffrement autojs
How do PMP candidates respond to the new exam outline? Look!
What files does a CA digital certificate contain? How to view SSL certificate information?
并发请求下如何防重复提交
Recommendations for agileplm database parameter optimization
dhu编程练习
最小栈详解
Implementation of Sanzi chess with C language
Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share
Raii memory management
DigiCert Smart Seal是什么?
PMP考生如何应对新考纲?看过来!
Seven common errors of SSL certificate and their solutions