cmake

风格不统一 提交于 2020-11-14 05:04:14

1.cmake_minimum_required(VERSION 3.7.1) cmake最低版本

2.project

Sets the name of the project, and stores it in the variable PROJECT_NAME. When called from the top-level CMakeLists.txt also stores the project name in the variable CMAKE_PROJECT_NAME.

3.set(SOURCE_FILES main.c)

SOURCE_FILES代替文件main.c

4.message(STATUS "This is BINARY dir " ${PROJECT_BINARY_DIR})

${PROJECT_BINARY_DIR}:CMakeLists.txt所在目录,在终端会打印如下内容:

This is BINARY dir /home/zzz/WorkSpace/Program/learning-cmake/hello-world

5.add_executable(hello-world ${SOURCE_FILES})

hello-world:最后生成可执行文件名称

6.add_subdirectory(src)

添加一个子目录去编译

7.add_library(hello_dynamic SHARED ${LIBHELLO_SRC}

用源文件生成动态库

8.add_library(hello_static STATIC ${LIBHELLO_SRC}

用源文件生成静态库

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!