This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
forked from svpcom/wfb-ng
-
Notifications
You must be signed in to change notification settings - Fork 7
/
WBLib.cmake
81 lines (69 loc) · 2.88 KB
/
WBLib.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# Defines WB_TARGET_LINK_LIBRARIES
# which can then be used to integrate wifibroadcast into your project
cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_STANDARD 17)
#if(WIFIBROADCAST_LIBRARIES_ALREADY_BUILD)
#if(get_property(source_list GLOBAL PROPERTY source_list_property))
# message(STATUS "WIFIBROADCAST_LIBRARIES_ALREADY_BUILD")
# return()
#endif()
if (TARGET wifibroadcast)
message(STATUS "WIFIBROADCAST_LIBRARIES_ALREADY_BUILD")
return()
endif()
#find_library(WIFIBROADCAST_LIB wifibroadcast)
#if(WIFIBROADCAST_LIB)
# message(STATUS "wifibroadcast already here")
# return()
#endif()
# Build and include wifibroadcast
# ----------------------------------
#add_library( radiotap
# SHARED
# ${CMAKE_CURRENT_LIST_DIR}/src/external/radiotap/radiotap.c
# )
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
#add_library( fec
# SHARED
# ${CMAKE_CURRENT_LIST_DIR}/src/external/fec/fec.cpp
# )
# Well, let's just build everything together
add_library(wifibroadcast
STATIC
# radiotap and fec
${CMAKE_CURRENT_LIST_DIR}/src/external/radiotap/radiotap.c
${CMAKE_CURRENT_LIST_DIR}/src/external/fec/fec.cpp
# the couple of non-header-only files for wifibroadcast
${CMAKE_CURRENT_LIST_DIR}/src/WBReceiver.cpp
${CMAKE_CURRENT_LIST_DIR}/src/WBTransmitter.cpp
)
## FEC Optimizations begin ---------------------------------
set(WIFIBROADCAST_FEC_OPTIMIZATION_FLAGS_X86 -mavx2 -faligned-new=256)
set(WIFIBROADCAST_FEC_OPTIMIZATION_FLAGS_ARM -mfpu=neon -march=armv7-a -marm)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_MAVX2)
if(COMPILER_SUPPORTS_MAVX2)
message(STATUS "WB FEC has MAVX2")
#target_compile_options(wifibroadcast PRIVATE ${WIFIBROADCAST_FEC_OPTIMIZATION_FLAGS_X86})
endif()
check_cxx_compiler_flag("-mfpu=neon" COMPILER_SUPPORTS_NEON)
if(COMPILER_SUPPORTS_NEON)
message(STATUS "WB FEC has NEON")
#target_compile_options(wifibroadcast PRIVATE ${WIFIBROADCAST_FEC_OPTIMIZATION_FLAGS_ARM})
endif()
## FEC Optimizations end ---------------------------------
# We need pcap and libsodium to build wifibroadcast
include(${CMAKE_CURRENT_LIST_DIR}/cmake/FindPCAP.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/FindSodium.cmake)
target_include_directories(wifibroadcast PUBLIC ${sodium_INCLUDE_DIR})
target_include_directories(wifibroadcast PUBLIC ${PCAP_INCLUDE_DIR})
target_link_libraries(wifibroadcast PUBLIC ${PCAP_LIBRARY})
target_link_libraries(wifibroadcast PUBLIC ${sodium_LIBRARY_RELEASE})
# for some reason, we also need to manually link pthread
find_package(Threads REQUIRED)
target_link_libraries(wifibroadcast PUBLIC Threads::Threads)
SET(WB_TARGET_LINK_LIBRARIES wifibroadcast)
SET(WB_INCLUDE_DIRECTORES ${CMAKE_CURRENT_LIST_DIR}/src)
include_directories(${CMAKE_CURRENT_LIST_DIR}/src/HelperSources)
# ----------------------------------