提供一个基本的cmakelists.txt文件

 

project(ftptest)

message("----------cmake ${PROJECT_NAME}----------start")

# 设置构建类型为Release
# set(CMAKE_BUILD_TYPE Release)

set(CMAKE_VERBOSE_MAKEFILE ON)
#set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -rdynamic -O0 -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wreturn-type -fdata-sections -ffunction-sections -fstack-protector-strong -fPIC")
## -Wno-unused-variable

include_directories(/usr/include)
include_directories(/usr/local/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

link_directories(/usr/local/lib/)
link_directories(/usr/lib)
link_directories(/usr/lib32)
link_directories(/usr/lib64)
link_directories(/usr/local/lib64)

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

# 添加需要链接的库
set(OPENSSLLIB
    ssl
    crypto
)

set(POCOLIB
    PocoNet
    PocoNetSSL
    PocoCrypto
    PocoUtil
    PocoJSON
    PocoXML
    PocoFoundation
)

set(LIBS
    ${OPENSSLLIB}
    ${POCOLIB}
    pthread
)


# 添加源文件
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)

# 添加可执行文件
add_executable(${PROJECT_NAME}  ${SOURCES})

target_link_libraries(${PROJECT_NAME} ${LIBS})
message("----------cmake ${PROJECT_NAME}----------end")

 

posted @ 2024-11-07 10:29  He_LiangLiang  阅读(3)  评论(0编辑  收藏  举报