A minimal project
https://github.com/zzu-andrew/linux-sys/tree/dfew/CMake
# 说明最低cmake版本要求
cmake_minimum_required(VERSION 3.2)
# 工程名
project(MyApp)
# 可执行程序名
add_executable(myExe main.cpp)
支持添加多个文件
add_executable(myExe
main.cpp
src1.cpp
src2.cpp
)
命令不区分大小写
add_executable(myExe main.cpp)
ADD_EXECUTABLE(myExe main.cpp)
Add_Executable(myExe main.cpp)
可只填写主版本和次版本
cmake_minimum_required(VERSION major.minor[.patch[.tweak]])
每个CMake工程都应该包含一个project()命令,该命令应该在cmake_minimum_required()命令之后调用。虽然能只给一个工程名,但是最好给出工程的版本信息,方便其他模块能够调用
project(projectName
[VERSION major[.minor[.patch[.tweak]]]]
[LANGUAGES languageName ...]
)
The optional LANGUAGES argument defines the programming languages that should be enabled for the project. Supported values include C, CXX, Fortran, ASM, Java and others. If specifying multiple languages, separate each with a space. In some special situations, projects may want to indicate that no languages are used, which can be done using LANGUAGES NONE.
If no LANGUAGES option is provided, CMake will default to C and CXX.
CMake versions prior to 3.0 do not support the LANGUAGES keyword, but languages can still be specified after the project name using the older form of the command like so:
project(myProj C CXX)
本文详细介绍了使用CMake进行项目配置的方法,包括设置最低版本要求、定义项目名称、添加可执行文件及其源代码,以及如何指定项目支持的编程语言。通过实例展示了CMakeLists.txt文件的编写规范。
2996

被折叠的 条评论
为什么被折叠?



