当前位置:网站首页>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
边栏推荐
- Créer des compétences exquises dans l'éducation des créateurs
- Global and Chinese market of subscription revenue management software 2022-2028: Research Report on technology, participants, trends, market size and share
- 最小栈详解
- 桶排序
- CA数字证书包含哪些文件?如何查看SSL证书信息?
- What is digicert smart seal?
- Enlightenment from the revocation of Russian digital certificate by mainstream CA: upgrade the SSL certificate of state secret algorithm to help China's network security to be autonomous and controlla
- 打造創客教育中精湛技藝
- Insert sort directly
- 【干货分享】最新WHQL徽标认证申请流程
猜你喜欢

Le Code autojs peut - il être chiffré? Oui, présentation des techniques de chiffrement autojs

SQL injection -day17

PR second training notes

每周推荐短视频:为什么理论正确但得不到预期结果?

快速排序

微信小程序页面跳转以及参数传递

Pytoch learning (II)

Insert sort directly

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

What is a self signed certificate? Advantages and disadvantages of self signed SSL certificates?
随机推荐
002 color classification
Global and Chinese markets of liquid optical waveguides 2022-2028: Research Report on technology, participants, trends, market size and share
如何使用SMS向客户传递服务信息?指南在这里!
AutoJS代碼能加密嗎?YES,AutoJS加密技巧展示
直接插入排序
Seven common errors of SSL certificate and their solutions
Vs realize quick replacement function
Heap sort
dhu编程练习
[NPM] solve the problem of error reporting when installing typeorm with NPM
Recommendations for agileplm database parameter optimization
matlab代码运行教程(如何运行下载的代码)
How vscode debugs into standard library files / third-party package source code
Four, forty, fourhundred swatches
dhu编程练习
Alphassl digital certificate
Five cheapest wildcard SSL certificate brands
银行的理财产品一般期限是多久?
微信小程序页面跳转以及参数传递
学术汇报(academic presentation)/PPT应该怎么做?