This series of articles is translated from the official cmake tutorial: [cmake tutorial](
).
Sample program address: [github.com/rangaofei/t...](
)
I won't just stay in the official tutorial. As an Android Developer, I really don't have linux c program development experience. I hope the big guys will forgive me. The tutorial is completed under macos, and I have tested most Linux, and I will mark out if there are special instructions. This tutorial is based on cmake-3.10.2, and I think you have installed cmake.
If we want to distribute our project to others so that they can install and use it. We want to provide executable files or source files on various platforms and build installation packages that support binary installation and package management features, such as cygwin, debian, rpm, etc. to achieve this, we will use CPack to create platform specific security packages similar to those described in CPack's Chapter packaging Specifically, we need to add a few lines of code at the bottom of the root directory CMakeLists.txt:
# build a CPack driven installer package include (InstallRequiredSystemLibraries) set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") include (CPack)
First, we need to add InstallRequiredSystemLibraries. This module will include any runtime libraries required by the current platform project. Next, we will add some CPack variables, such as the license and version information of the project. Finally, we will add the CPack module, which will set the installer using the newly defined variables and some other properties of the system. We will execute external Build and view what the generated files are:
~/Desktop/Tutorial/Step6/build/ tree -L 1 . ├── CMakeCache.txt ├── CMakeFiles ├── CPackConfig.cmake ├── CPackSourceConfig.cmake ├── CTestTestfile.cmake ├── Makefile ├── MathFunctions ├── TutorialConfig.h └── cmake_install.cmake
Note that two of the generated files, cpackconfig.cmake and cpacksourceconfig.cmake, are of great use later.
The next step is to build the project in the normal way, and then run CPack on it. To build a binary version, you can run:
cpack --config CPackConfig.cmake
Below is the log:
CPack: Create package using STGZ CPack: Install projects CPack: - Run preinstall target for: Tutorial CPack: - Install project: Tutorial CPack: Create package CPack: - package: /Users/saka/Desktop/Tutorial/Step6/build/Tutorial-1.0.1-Darwin.sh generated. CPack: Create package using TGZ CPack: Install projects CPack: - Run preinstall target for: Tutorial CPack: - Install project: Tutorial CPack: Create package CPack: - package: /Users/saka/Desktop/Tutorial/Step6/build/Tutorial-1.0.1-Darwin.tar.gz generated.
You can see from the log that two packaged files tutorial-1.0.1-darwin.sh and tutorial-1.0.1-darwin.tar.gz are generated. Check the directory:
~/Desktop/Tutorial/Step6/build/ tree -L 1 . ├── CMakeCache.txt ├── CMakeFiles ├── CPackConfig.cmake ├── CPackSourceConfig.cmake ├── CTestTestfile.cmake # epilogue * Tiktok Kwai is now popular with short videos. NDK Module development is becoming more and more important. More and more enterprises need this talent, and more people learn this. Audio and video development is often difficult, and this difficult technology is NDK The technology inside. * Audio and video/HD big picture/artificial intelligence/live broadcast/Tiktok and so on, which are the most closely related to users, and the most relevant technologies in our life, have been looking for the ultimate technology landing platform. windows System, and now it is a mobile system, and in the mobile system Android The majority is the premise, so AndroidNDK Technology is already a necessary skill for us. * We should study well NDK,About C/C++,jni,Linux In addition, audio and video codec technology, streaming media protocol, ffmpeg These are the necessary skills for audio and video development, and * OpenCV/OpenGl/These are also the necessary knowledge of image processing. The following are the data I collected and some pictures I made in those years, because I felt that video would be a big trend in those years. So I made some preparations in advance. Now I'll share it with you. **[CodeChina Open source projects:< Android Summary of study notes+Mobile architecture video+Real interview questions for large factories+Project practice source code]( )** ![](https://img-blog.csdnimg.cn/img_convert/06ba1a351e2ced61156d1decb07172ee.png) ![](https://img-blog.csdnimg.cn/img_convert/27a8c7f1d27e7c46e028c53c75d83d8d.png) > **This article has been[tencent CODING Open source hosting project:< Android Summary of study notes+Mobile architecture video+Real interview questions for large factories+Project practice source code](https://ali1024.coding.net/public/P7/Android/git), self-study resources and series of articles are constantly updated** video+Real interview questions for large factories+Project practice source code](https://ali1024.coding.net/public/P7/Android/git), self-study resources and series of articles are constantly updated**