使用CMake编写CMakeLists.txt文件

target

Targets represent executables, libraries, and utilities built by CMake. Every add_library, add_executable, and add_custom_target command creates a target. For example, the follwing command will create a target named foo that is a static library, with foo1.c and foo2.c as source file

add_library(foo STATIC foo1.c foo2.c)

可以通过变量BUILD_SHARED_LIBS指定需要编译库的类型。

Source Files

可以设置一些源文件的属性,比如编译选项。

变量

通过set commands进行设置。

The first command the toplevel CMakeLists file should have is the PROJECT command. This command both names the project and optionally specifies what languages will

be used by it.

project (projectname [CXX] [C] [Java] [NONE])

If no languages are specified then CMake defaults to supporting C and C++.

The project will contain all targets that are in the CMakeLists.txt file, and any of its subdirectories as specified by the add_subdirectory command.



你可能感兴趣的:(cmake,cmake)