Linux下生成动态库的CMake方法

目录结构如下:

 

Linux下生成动态库的CMake方法_第1张图片

CMAKE_MINIMUM_REQUIRED (VERSION 2.8.3)

SET(PROJECT_NAME readmap)

PROJECT(${PROJECT_NAME})

set(CMAKE_BUILD_TYPE "Release")

set(CMAKE_CXX_FLAGS "-g -std=c++11")

#-DEIGEN_USE_MKL_ALL")

set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g")

find_package(PROJ4 REQUIRED) #配置proj.4库

find_package(Eigen3 REQUIRED)

# Include dirs

INCLUDE_DIRECTORIES(

  ${PROJ4_INCLUDE_DIRS}

  ${EIGEN3_INCLUDE_DIRS}

  include

)

AUX_SOURCE_DIRECTORY(src DIR_SRCS)

SET(readmap ${DIR_SRCS})

#此行生产可执行文件

ADD_EXECUTABLE(${PROJECT_NAME} ${readmap})

#此行生成动态库

#add_library(${PROJECT_NAME} SHARED ${DIR_SRCS})

#SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/usr/lib)

#此行调用第3方库Proj.4库

target_link_libraries(readmap ${PROJ4_LIBRARIES})

你可能感兴趣的:(工具使用)