Clion 结合主流开发库的cmakelist完整配置

开发环境:ubuntu 18.04 

IDE:Clion 2019

 

这里使用cmakelist配置了一些主流的库文件.

有以下:

opencv4.1.0    json.cpp    boost   eigen

cnpy  zxing

zbar

cmake_minimum_required(VERSION 3.5)
project(KeekoAIRobot)

set(CMAKE_CXX_STANDARD 14)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -DNDEBUG")

#找到opencv的包
set(TARGET_LIBS "/usr/local/include/opencv4/opencv2/")
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

#jsoncpp
set(jsoncpp_include_dir "/usr/local/include")
set(jsoncpp_link_dir "/usr/lib/x86_64-linux-gnu")
include_directories(${jsoncpp_include_dir})
link_directories(${jsoncpp_link_dir})

#boost
find_package(Boost REQUIRED COMPONENTS filesystem)
set(Boost_LIBS boost_filesystem boost_system)

#eigen
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR}${EIGEN3_LIBRARIES})

# cnpy
option(ENABLE_STATIC "Build static (.a) library" ON)

find_package(ZLIB REQUIRED)

include_directories(${ZLIB_INCLUDE_DIRS})

add_library(cnpy SHARED "libs/cnpy/cnpy.cpp")
target_link_libraries(cnpy ${ZLIB_LIBRARIES})
install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

#zbar
set(zbar_include_dir "/usr/local/include")
set(zbar_link_dir "/usr/local/lib")

include_directories(${zbar_include_dir})
link_directories(${zbar_link_dir})
link_libraries(zbar)

#zxing
set(zxing_include_dir "/usr/local/include")
set(zxing_link_dir "/usr/local/lib")

include_directories(${zxing_include_dir})
link_directories(${zxing_link_dir})
link_libraries(zxing)


if(ENABLE_STATIC)
    add_library(cnpy-static STATIC "libs/cnpy/cnpy.cpp")
    set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy")
    install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib)
endif(ENABLE_STATIC)

install(FILES "libs/cnpy/cnpy.h" DESTINATION include)
install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)


#多线程
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")

#添加运行文件
add_executable(KeekoAIRobot
        main.cpp)

#动态链接
#target_link_libraries(pedestrian_detection ${OpenCV_LIBS} )
target_link_libraries(KeekoAIRobot ${OpenCV_LIBS} )
target_link_libraries(KeekoAIRobot jsoncpp)
target_link_libraries(KeekoAIRobot cnpy)
target_link_libraries(KeekoAIRobot zbar)
target_link_libraries(KeekoAIRobot zxing)

# 搜索本目录搜索源码并赋值给变量
#aux_source_directory(. DIR_LIB_SRCS)

# 添加库文件
#add_library(KeekoAILib SHARED ${DIR_LIB_SRCS})
posted @ 2019-08-29 11:42  Xu_Lin  阅读(2068)  评论(0编辑  收藏  举报