Skip to content

Commit

Permalink
Add initial bits to compile hostap project.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Nov 10, 2023
1 parent 1e0fa58 commit 3c76273
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 0 deletions.
58 changes: 58 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ project(netremote
VERSION 0.0.1
)

# Conditional inclusion of OS-dependent source trees.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(BUILD_FOR_LINUX TRUE)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(BUILD_FOR_WINDOWS TRUE)
else ()
MESSAGE(FATAL_ERROR "No supported target OS detected, SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
endif()

MESSAGE(STATUS "Target OS ${CMAKE_SYSTEM_NAME} detected")

# Option determining whether the hostapd client library should be built from
# source, or a pre-built, packaged version discovered on the system.
option(
BUILD_HOSTAP_EXTERNAL
"Build hostap project from built-in external source"
ON
)

# Set language configutation options. The C++ standard used must be the lowest
# common denominator for all the OS-dependent projects. In practice, since this
# project must build under the Windows build system (build.exe), its toolchain
Expand All @@ -27,9 +46,11 @@ set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)

include(CheckPIESupported)
include(CTest)
include(ExternalProject)
include(GNUInstallDirs)
include(grpc)
include(protoc)
include(hostap)

# Enable verbose output until project is bootstrapped.
set(CMAKE_VERBOSE_MAKEFILE ON)
Expand Down Expand Up @@ -108,6 +129,43 @@ if (CMAKE_BUILD_TYPE MATCHES "(Release|RelWithDebInfo|MinSizeRel)")
add_compile_definitions(_FORTIFY_SOURCE=2)
endif()

# Common source directories
set(NETREMOTE_DIR_SRC ${CMAKE_CURRENT_LIST_DIR}/src)
set(NETREMOTE_DIR_LINUX ${CMAKE_CURRENT_LIST_DIR}/linux)
set(NETREMOTE_DIR_WINDOWS ${CMAKE_CURRENT_LIST_DIR}/windows)

# Add common, global compile definitions.
add_compile_definitions(
MAGIC_ENUM_RANGE_MIN=0
MAGIC_ENUM_RANGE_MAX=255
)

# Conditional inclusion of OS-dependent source trees.
if (BUILD_FOR_LINUX)
add_subdirectory(linux)
elseif (BUILD_FOR_WINDOWS)
# Make public version of wil available.
set(WIL_BUILD_TESTS OFF CACHE INTERNAL "Turn off wil tests")
set(WIL_BUILD_PACKAGING OFF CACHE INTERNAL "Turn off wil packaging")

find_package(wil CONFIG REQUIRED)

# Add Windows-specific global compile definitions.
add_compile_definitions(
_UNICODE
UNICODE
NOMINMAX
WIN32_LEAN_AND_MEAN
)

# Allow more than default number of sections in object files.
add_compile_options(
/bigobj
)

add_subdirectory(windows)
endif()

add_subdirectory(protocol)
add_subdirectory(src)
add_subdirectory(tests)
13 changes: 13 additions & 0 deletions cmake/hostap.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

if (BUILD_HOSTAP_EXTERNAL)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../external/hostap)
else()
find_library(LIBWPA_CLIENT
NAMES libwpa_client.so
REQUIRED)
endif()

if(LIBWPA_CLIENT)
set(LIBWPA_CLIENT_TARGET ${LIBWPA_CLIENT})
MESSAGE(STATUS "Found wpa client: ${LIBWPA_CLIENT}")
endif()
2 changes: 2 additions & 0 deletions external/hostap/.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_CTRL_IFACE=y
CONFIG_BUILD_WPA_CLIENT_SO=y
23 changes: 23 additions & 0 deletions external/hostap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

find_program(MAKE_EXE
NAMES gmake nmake make
REQUIRED
)

set(HOSTAP_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/hostap-prefix/src/hostap/wpa_supplicant)

ExternalProject_Add(hostap
GIT_REPOSITORY "http://w1.fi/hostap.git"
GIT_TAG "hostap_2_10"
CONFIGURE_COMMAND cp -n ${CMAKE_CURRENT_SOURCE_DIR}/.config ${HOSTAP_PREFIX}/.config
BINARY_DIR ${HOSTAP_PREFIX}
BUILD_COMMAND QUIET=1 ${MAKE_EXE} libwpa_client.so
INSTALL_DIR ${HOSTAP_PREFIX}
INSTALL_COMMAND QUIET=1 DESTDIR=${HOSTAP_PREFIX} ${MAKE_EXE} install
)

set(LIBWPA_CLIENT
${HOSTAP_PREFIX}/libwpa_client.so
CACHE FILEPATH
"wpa client shared object"
)
1 change: 1 addition & 0 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(hostap-controller)
16 changes: 16 additions & 0 deletions linux/hostap-controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

add_library(hostap-controller SHARED "")

if (BUILD_HOSTAP_EXTERNAL)
add_dependencies(hostap-controller hostap)
endif()

target_sources(hostap-controller
PRIVATE
Placeholder.cxx
)

target_link_libraries(hostap-controller
INTERFACE
${LIBWPA_CLIENT_TARGET}
)
4 changes: 4 additions & 0 deletions linux/hostap-controller/Placeholder.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

#include <cstddef>

#include <wpa_ctrl.h>
Empty file added windows/CMakeLists.txt
Empty file.

0 comments on commit 3c76273

Please sign in to comment.