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