blob: 2adff1c71e397326498fd2ee582727230facce0d [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001cmake_minimum_required(VERSION 2.6)
2
3PROJECT(nginx-util CXX)
4SET(CMAKE_CXX_STANDARD 17)
5
6INCLUDE(CheckFunctionExists)
7
8ADD_DEFINITIONS(-Os -Wall -Werror -Wextra -g3)
9ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations -Wshadow)
10
11SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
12
13FIND_PATH(uci_include_dir uci.h)
14FIND_LIBRARY(uci NAMES uci)
15INCLUDE_DIRECTORIES(${uci_include_dir})
16
17FIND_PATH(ubox_include_dir libubox/blobmsg.h)
18FIND_LIBRARY(ubox NAMES ubox)
19INCLUDE_DIRECTORIES(${ubox_include_dir})
20
21IF(UBUS)
22
23ADD_COMPILE_DEFINITIONS(VERSION=${VERSION})
24
25FIND_PATH(ubus_include_dir libubus.h)
26FIND_LIBRARY(ubus NAMES ubus)
27INCLUDE_DIRECTORIES(${ubus_include_dir})
28
29ADD_EXECUTABLE(nginx-ssl-util nginx-util.cpp)
30TARGET_LINK_LIBRARIES(nginx-ssl-util ${uci} ${ubox} ${ubus} pthread ssl crypto pcre)
31INSTALL(TARGETS nginx-ssl-util RUNTIME DESTINATION bin)
32
33ADD_EXECUTABLE(nginx-ssl-util-nopcre nginx-util.cpp)
34TARGET_COMPILE_DEFINITIONS(nginx-ssl-util-nopcre PUBLIC -DNO_PCRE)
35TARGET_LINK_LIBRARIES(nginx-ssl-util-nopcre ${uci} ${ubox} ${ubus} pthread ssl crypto)
36INSTALL(TARGETS nginx-ssl-util-nopcre RUNTIME DESTINATION bin)
37
38ELSE()
39
40ADD_COMPILE_DEFINITIONS(VERSION=0)
41
42CONFIGURE_FILE(test-px5g.sh test-px5g.sh COPYONLY)
43CONFIGURE_FILE(test-nginx-util.sh test-nginx-util.sh COPYONLY)
44CONFIGURE_FILE(test-nginx-util-root.sh test-nginx-util-root.sh COPYONLY)
45CONFIGURE_FILE(../files/nginx.config config-nginx-ssl COPYONLY)
46CONFIGURE_FILE(../files/uci.conf.template uci.conf.template COPYONLY)
47
48ADD_EXECUTABLE(px5g px5g.cpp)
49TARGET_LINK_LIBRARIES(px5g ssl crypto)
50INSTALL(TARGETS px5g RUNTIME DESTINATION bin)
51
52ADD_EXECUTABLE(nginx-ssl-util-noubus nginx-util.cpp)
53TARGET_COMPILE_DEFINITIONS(nginx-ssl-util-noubus PUBLIC -DNO_UBUS)
54TARGET_LINK_LIBRARIES(nginx-ssl-util-noubus ${uci} ${ubox} pthread ssl crypto pcre)
55INSTALL(TARGETS nginx-ssl-util-noubus RUNTIME DESTINATION bin)
56
57ADD_EXECUTABLE(nginx-ssl-util-nopcre-noubus nginx-util.cpp)
58TARGET_COMPILE_DEFINITIONS(nginx-ssl-util-nopcre-noubus PUBLIC -DNO_PCRE -DNO_UBUS)
59TARGET_LINK_LIBRARIES(nginx-ssl-util-nopcre-noubus ${uci} ${ubox} pthread ssl crypto)
60INSTALL(TARGETS nginx-ssl-util-nopcre-noubus RUNTIME DESTINATION bin)
61
62ENDIF()