文章目录
1、编译生成so、bin
通过此工程编译生成so\bin文件
2、将so\bin打包到rpm中
###### 1.生成可执行文件、库文件 #########
cmake_minimum_required(VERSION 3.15)project(compute)
set(target zls_bin)
set(target2 libcompute.so)
# 依赖的头文件
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB include_file "${PROJECT_SOURCE_DIR}/include/*.h")# 文件搜索
file(GLOB SRC "${PROJECT_SOURCE_DIR}/src/*.c")# 设置生成库文件的路径(静态库\动态库都可行)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)# 设置生成可执行文件的路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)MESSAGE("PROJECT_NAME:${PROJECT_NAME}")
MESSAGE("SRC:${SRC}")
MESSAGE("LIBRARY_OUTPUT_PATH:${LIBRARY_OUTPUT_PATH}")
MESSAGE("EXECUTABLE_OUTPUT_PATH:${EXECUTABLE_OUTPUT_PATH}")
MESSAGE("include_file:${include_file}")# 生成静态库文件
#add_library(${PROJECT_NAME} STATIC ${SRC})# 生成动态库文件
add_library(${PROJECT_NAME} SHARED ${SRC})# 生成可执行文件(方式一:直接包含源文件方式)
# add_executable(target main.c ${SRC})# 生成可执行文件(方式二:链接静态库文件)
## 包含静态库路径
# link_directories(${PROJECT_SOURCE_DIR}/lib)
## 链接静态库文件(target 依赖静态库compute)
# link_libraries(compute)
# add_exec