加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
spencer(陌尘) 提交于 2024-05-02 16:27 . feat: fix cpack
message(STATUS "--------- begin cmake ---------")
# cmake教程:https://www.zhihu.com/column/c_1369781372333240320
# cmake version
cmake_minimum_required(VERSION 3.28.3)
# project name
project(common_util VERSION 1.0.0 LANGUAGES CXX)
# C/C++ standard: C99/C++11
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
# 获取构建目标的CPU架构
message("CMAKE_SYSTEM_NAME:" ${CMAKE_SYSTEM_NAME})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_CL_64)
set(target_arch x64)
else()
set(target_arch x86)
endif()
else()
set(target_arch ${CMAKE_SYSTEM_PROCESSOR})
endif()
message("target_arch:" ${target_arch})
# message("CMAKE_CURRENT_SOURCE_DIR:" ${CMAKE_CURRENT_SOURCE_DIR})
# message("CMAKE_SOURCE_DIR:" ${CMAKE_SOURCE_DIR})
# add sub moudle for common_util
add_subdirectory(src/common_util)
add_subdirectory(src/usage_demo)
# 打包安装
# pack and install
# set pack content
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_SOURCE_DIR}/publish/pkg)
message("CPACK_OUTPUT_FILE_PREFIX:" ${CPACK_OUTPUT_FILE_PREFIX})
install(TARGETS common_util common_util_demo
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
# ARCHIVE DESTINATION pack
)
# install headers for common_util
file(GLOB COMMON_UTIL_HEADERS src/common_util/*.h)
install(FILES ${COMMON_UTIL_HEADERS} DESTINATION include)
# set pack config
include(CPack)
set(CPACK_GENERATOR "ZIP") # pack type
set(CPACK_PACKAGE_NAME "common_util")
set(CPACK_INSTALL_PREFIX "") # path for pack inner
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
message(STATUS "--------- end cmake ---------")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化