In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to use Cmake to manage a project's cross-platform C++ application. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Cross-platform C++ application for managing projects using Cmake
MSDN reference documentation: https://docs.microsoft.com/zh-cn/cpp/build/cmake-projects-in-visual-studio?view=msvc-160
Summary of CMake modification compared with VS parameters: https://blog.csdn.net/xum2008/article/details/7268761?source=1
Using CMake to manage projects, and using standard C++ as the development language, you can create completely cross-platform C++ applications.
1) create a CMake project
You can create a new cmake project from IDE, or you can open an existing cmake project.
To open an existing cmake project, import the cmake configuration from [File] [Open] [CMake]:
To create a new cmake project, select the cmake project from the new one. From VS2019's project explanation, we can see that CMake exists as a cross-platform management tool, not just a Linux project.
2) switch to CMake view, which is very important, because the default is folder view, so it is not convenient to generate sub-projects separately.
Switch to the solution view, locate the button, and click once:
Select the view that appears, and then double-click the selected view type. Here, select the CMake target view and enter the CMake development view:
Here is the CMake target view. Right-click a project to add a new target (that is, add a new subproject), build all, clean up, etc., and click a project to have a similar action menu:
Explain what the CMake cache means: if you choose to build the cache, CMake will parse the CMakeLists.txt file and generate the CMake project view; there must be an exe build project and a dll build project, and if you clear these caches, only the CMakeLists.txt file will be left.
It is important to note that in the output bar, you need to select a different output source to see the CMake process. Most of the default is to generate the output source. If you need to know the CMake process, you can switch to the CMake source.
3) add a dynamic library project named Common:
/ / common.h#pragma once#ifdef _ WIN32#define COMMON_EXPORT _ declspec (dllexport) # else#define COMMON_EXPORT#endif / / _ WIN32namespace BGI {namespace Common {COMMON_EXPORT void add (int v1, int v2);}} / / common.cpp#include # include "Common.h" using namespace std Namespace BGI {namespace Common {static void threadproc (int* value) {for (int I = 0; I < 10; iTunes +) {* value + = 1 Std::this_thread::sleep_for (std::chrono::milliseconds);}} void add (int v1, int v2) {thread T1 (threadproc, & v1); thread T2 (threadproc, & v2) T1.join (); t2.join (); cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.