Cmake交叉编译编译动态库

cmakelists.txt写法如下
 
编译指令:cmake -DCMAKE_CXX_COMPILER:FILEPATH=/home/wangwc/CompilerCollection/RuiXinWei/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ …
 
aux_source_directory:遍历./ITA_LIB目录的文件存放到ITA_LIB_DIR中。
 
add_library:编译动态库
 
add_compile_options:忽略编译警号
 
动态库编译
 
cmake_minimum_required(VERSION 3.0.0)
project(ITA_LIB VERSION 0.1.0)
 
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
 
file(GLOB_RECURSE ITA_SRC1 ./*.cpp)
file(GLOB_RECURSE ITA_SRC1 ./InfraredImage/*.cpp)
 
SET (ALL_SRCS 
${ITA_SRC1}
${ITA_SRC1}
)
 
add_library(ITA SHARED  ${ALL_SRCS})
 
 
cmake_minimum_required(VERSION 3.0.0)
project(ITA_LIB VERSION 0.1.0)
 
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
 
#会遍历匹配目录的所有文件以及子目录下面的文件
#file(GLOB_RECURSE ITA_SRC ./*.cpp)
 
aux_source_directory(. ITA_SRC1)
aux_source_directory(./InfraredImage ITA_SRC2)
SET (ALL_SRCS 
${ITA_SRC1}
${ITA_SRC2}
)
#MESSAGE(STATUS  "ITA_SRC1 = ${ITA_SRC1}.")
#MESSAGE(STATUS  "ITA_SRC2 = ${ITA_SRC2}.")
add_library(ITA SHARED  ${ALL_SRCS})
 
posted @ 2023-07-11 11:31  阿风小子  阅读(79)  评论(0编辑  收藏  举报