cmake记录

cmake_minimum_required(VERSION 3.5)

project(projectname)

#输出目录
#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin/debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin/release)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/lib/debug)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/lib/release)

#set(CMAKE_DEBUG_POSTFIX "_d")
#set(CMAKE_RELEASE_POSTFIX "")

#安装目录
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install CACHE PATH "Install prefix path")


#系统判断
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
    set(env_path ${CMAKE_CURRENT_SOURCE_DIR}/../env_linux)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(env_path ${CMAKE_CURRENT_SOURCE_DIR}/../env_win)
ENDIF()

 

#判断编译类型
IF (${CMAKE_BUILD_TYPE} MATCHES "Release")
    
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
    
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebInfo")
    
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
    
ENDIF()

#增加目录选项
set(Poco_Lib_Path_Debug "default value" CACHE PATH "description" FORCE)

增加子目录
add_subdirectory(./pathname)


file(GLOB Header_files ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Src_files)
add_library(HttpServerBase SHARED
  ${Src_files}
  ${Header_files}
)

#包含头文件
include_directories(${Include_Path})

#库文件路径
target_link_directories(${PROJECT_NAME} PRIVATE "${Lib_Path}")


#链接库文件
target_link_libraries(${PROJECT_NAME}
    PRIVATE
    lib
    )

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值