代码拉取完成,页面将自动刷新
project(HELLO_CMAKE)
set(CMAKE_INSTALL_PREFIX ./install)
set(HEADER_LIBRARY_INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/./Library/)
# 递归获取目录下所有的h文件
file(GLOB_RECURSE LINKLIBRARY_HEADER_FILES ${HEADER_LIBRARY_INCLUDE_DIRECTORY}*.h)
add_subdirectory(HELLO_CMAKE bin)
add_subdirectory(Library bin)
add_subdirectory(LinkLibrary bin)
#添加依赖, 定义编译顺序
add_dependencies(LinkLibrary Library)
#安装动态库和静态库
INSTALL(TARGETS Library_shared
LIBRARY DESTINATION ./lib)
#安装头文件
#获取 Library 的头文件路径, 并将其解析为同源的相对路径
# 例如 : ${PROJECT_SOURCE_DIR}/Library /lib/a.h
# - ${PROJECT_BINARY_DIR}/install/include /lib/a.h
# ${PROJECT_SOURCE_DIR}/Library 与 {PROJECT_BINARY_DIR}/install/include 同源
foreach(header ${LINKLIBRARY_HEADER_FILES})
string(REPLACE ${HEADER_LIBRARY_INCLUDE_DIRECTORY} "" relativeHeader ${header})
string(REGEX REPLACE "[^\\/]*\\.[^\\/\\.]*$" "" relativeHeader ${relativeHeader})
install(FILES ${header} DESTINATION ./include/${relativeHeader})
endforeach()
#安装 LinkLibrary 作为 Example
INSTALL(TARGETS LinkLibrary
RUNTIME DESTINATION ./bin)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。