mirror of
https://dev.iopsys.eu/hal/wifimngr.git
synced 2025-12-20 01:11:11 +08:00
109 lines
2.6 KiB
CMake
109 lines
2.6 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(wifimngr C)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-address-of-packed-member -fstrict-aliasing -ggdb")
|
|
|
|
option(HAS_UBUS "Enable Openwrt UBOX and UBUS support" ON)
|
|
|
|
include(FindPkgConfig)
|
|
pkg_check_modules(nl3 REQUIRED libnl-3.0)
|
|
pkg_check_modules(nl3-genl REQUIRED libnl-genl-3.0)
|
|
find_package(OpenSSL REQUIRED)
|
|
find_library(uci_library NAMES uci)
|
|
find_library(libeasy NAMES easy)
|
|
find_library(libwifiutils NAMES wifiutils)
|
|
find_library(libwifi NAMES wifi-7)
|
|
|
|
include_directories(${nl3_INCLUDE_DIRS} ${nl3-genl_INCLUDE_DIRS})
|
|
link_directories(${nl3_LIBRARY_DIRS} ${nl3-genl_LIBRARY_DIRS})
|
|
|
|
# Generate help.h
|
|
add_custom_command(
|
|
OUTPUT help.h
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/help.json
|
|
-DOUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/help.h
|
|
-P ${CMAKE_SOURCE_DIR}/cmake/generate_help_h.cmake
|
|
DEPENDS help.json
|
|
COMMENT "Generating help.h"
|
|
)
|
|
|
|
add_custom_target(generate_help_h DEPENDS help.h)
|
|
|
|
|
|
# Generate version.h
|
|
execute_process(
|
|
COMMAND date "+%y%V%u-%H%M"
|
|
OUTPUT_VARIABLE VERSION_EXTRA
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND git status *.{c,h} --porcelain
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
OUTPUT_VARIABLE GIT_STATUS
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
if(NOT "${GIT_STATUS}" STREQUAL "")
|
|
set(VERSION_EXTRA "${VERSION_EXTRA}-dirty")
|
|
endif()
|
|
|
|
add_custom_command(
|
|
OUTPUT version.h
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-DVERSION_FILE=${CMAKE_CURRENT_SOURCE_DIR}/VERSION
|
|
-DVERSION_HEADER=${CMAKE_CURRENT_BINARY_DIR}/version.h
|
|
-DVERSION_EXTRA=${VERSION_EXTRA}
|
|
-P ${CMAKE_SOURCE_DIR}/cmake/generate_version_h.cmake
|
|
DEPENDS VERSION
|
|
COMMENT "Generating version.h"
|
|
)
|
|
|
|
add_custom_target(generate_version_h DEPENDS version.h)
|
|
|
|
set(SOURCES
|
|
main.c
|
|
wifimngr.c
|
|
uci.c
|
|
wifimngr_event.c
|
|
wps.c
|
|
debug.c
|
|
)
|
|
|
|
if(HAS_UBUS)
|
|
message(STATUS "UBUS support enabled")
|
|
list(APPEND SOURCES ubus.c)
|
|
add_definitions(-DHAS_UBUS)
|
|
find_library(json NAMES json-c json)
|
|
find_library(blob_library NAMES blobmsg_json)
|
|
find_library(ubox_library NAMES ubox)
|
|
find_library(ubus_library NAMES ubus)
|
|
endif()
|
|
|
|
add_executable(wifimngr ${SOURCES})
|
|
add_dependencies(wifimngr generate_help_h)
|
|
add_dependencies(wifimngr generate_version_h)
|
|
target_include_directories(wifimngr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_link_libraries(wifimngr
|
|
m
|
|
dl
|
|
OpenSSL::SSL
|
|
OpenSSL::Crypto
|
|
${libeasy}
|
|
${libwifiutils}
|
|
${libwifi}
|
|
${json}
|
|
${blob_library}
|
|
${ubox_library}
|
|
${ubus_library}
|
|
${uci_library}
|
|
${nl3_LIBRARIES}
|
|
${nl3-genl_LIBRARIES}
|
|
)
|
|
|
|
install(TARGETS wifimngr
|
|
RUNTIME DESTINATION /usr/sbin)
|