# set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language
project(recipe-03 LANGUAGES CXX)
# generate a library from sources
#生成静态库
add_library(message
STATIC
Message.hpp
Message.cpp
)
add_executable(hello-world hello-world.cpp)
#将静态库链接到 主函数
target_link_libraries(hello-world message)
cmake 生成静态库 并且 将静态库链接到主函数
于 2022-07-27 12:28:51 首次发布
本文介绍了如何使用CMake 3.5及以上版本创建C++项目,包括设置最小CMake版本,定义项目名、语言,生成静态库message,并将其链接到hello-world可执行程序的过程。
1242

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



