当前位置:网站首页>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
边栏推荐
- Digicert、Sectigo、Globalsign代码签名证书的区别
- 重看《Redis设计与实现》后记录几个要点
- Implementation of Sanzi chess with C language
- 微信小程序页面跳转以及参数传递
- True love forever valentine's Day gifts
- 选购通配符SSL证书注意事项
- Weekly recommended short video: why is the theory correct but can not get the expected results?
- C语言 pivot_root的Invalid argument错误解决方案
- Network neuroscience -- a review of network Neuroscience
- matlab代码运行教程(如何运行下载的代码)
猜你喜欢

三层交换机和二层交换机区别是什么

Implementation of Sanzi chess with C language

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

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

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

AutoJS代码能加密吗?YES,AutoJS加密技巧展示
![[Postgres] Postgres database migration](/img/45/7074aa766640160a3b6f00b109cb2f.png)
[Postgres] Postgres database migration

选购通配符SSL证书注意事项

Pytoch learning (II)

打造创客教育中精湛技艺
随机推荐
RAII内存管理
What files does a CA digital certificate contain? How to view SSL certificate information?
有流量,但没有销售?增加网站销量的 6 个步骤
选择排序
What are the requirements for NPDP product manager international certification examination?
每周推荐短视频:为什么理论正确但得不到预期结果?
Vs realize quick replacement function
PMP考生如何应对新考纲?看过来!
新考纲下的PMP考试有多难?全面解析
PR second training notes
What is a dangling pointer- What is a dangling pointer?
Global and Chinese market of subscription revenue management software 2022-2028: Research Report on technology, participants, trends, market size and share
五个最便宜的通配符SSL证书品牌
如何使用SMS向客户传递服务信息?指南在这里!
Raii memory management
C语言 pivot_root的Invalid argument错误解决方案
2022护网行动在即,关于护网的那些事儿
Matlab code running tutorial (how to run the downloaded code)
Jupyter notebook显示k线图集合
Le Code autojs peut - il être chiffré? Oui, présentation des techniques de chiffrement autojs