Nginx与CLion

2021-11-26  本文已影响0人  404Not_Found

我一直没有搞明白如何在CLion用 makefile 管理项目,有时间好好弄一下

1. 生成CLion src 源文件

./configure --prefix=/home/xxxx

2. 创建CMakeLists.txt -- 抄的

project(nginx)
cmake_minimum_required(VERSION 3.1)

INCLUDE_DIRECTORIES(./)
INCLUDE_DIRECTORIES(/usr/include/libxml2)
INCLUDE_DIRECTORIES(./objs)
INCLUDE_DIRECTORIES(./src/core)
INCLUDE_DIRECTORIES(./src/event)
#INCLUDE_DIRECTORIES(./src/event/modules)  # 平台相关不能加入所有的源码
INCLUDE_DIRECTORIES(./src/os/unix)
INCLUDE_DIRECTORIES(./src/http)
INCLUDE_DIRECTORIES(./src/http/modules)
INCLUDE_DIRECTORIES(./src/mail)

aux_source_directory(. SRC_LIST)
aux_source_directory(./src/core SRC_LIST)
aux_source_directory(./src/event SRC_LIST)
#aux_source_directory(./src/event/modules SRC_LIST) # 平台相关不能加入所有的源码
aux_source_directory(./src/os/unix SRC_LIST)
aux_source_directory(./src/http SRC_LIST)
aux_source_directory(./src/http/modules SRC_LIST)


# modify src list
set(SRC_LIST ${SRC_LIST} ./src/event/modules/ngx_epoll_module.c)
set(SRC_LIST ${SRC_LIST} ./objs/ngx_modules.c)

# 此次configure不关心的 源码需要剔除掉
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_darwin_init.c ./src/os/unix/ngx_darwin_sendfile_chain.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_freebsd_init.c ./src/os/unix/ngx_freebsd_sendfile_chain.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_solaris_init.c ./src/os/unix/ngx_solaris_sendfilev_chain.c)
list(REMOVE_ITEM SRC_LIST ./src/core/ngx_thread_pool.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_file_aio_read.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_linux_aio_read.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_thread_cond.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_thread_mutex.c)
list(REMOVE_ITEM SRC_LIST ./src/os/unix/ngx_thread_id.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_dav_module.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_geoip_module.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_degradation_module.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_grpc_module.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_image_filter_module.c)
list(REMOVE_ITEM SRC_LIST ./src/http/modules/ngx_http_stub_status_module.c)

add_executable(${PROJECT_NAME} ${SRC_LIST})

# 引入lib包
TARGET_LINK_LIBRARIES (${PROJECT_NAME} dl pthread crypt ldap lber pcre ssl crypto dl pthread z xml2 xslt exslt)

上一篇 下一篇

猜你喜欢

热点阅读