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
)