CMake -- A minimal project

A minimal project

# 说明最低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)