2018-07-06 04:09:48 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2018-05-02 21:40:01 +02:00
|
|
|
#
|
2023-03-21 15:41:11 +01:00
|
|
|
# Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
|
2018-05-02 21:40:01 +02:00
|
|
|
|
2017-12-05 03:50:36 +01:00
|
|
|
cmake_minimum_required(VERSION 3.4.1)
|
2021-01-23 10:10:39 +01:00
|
|
|
project("WireGuard")
|
2017-12-05 03:50:36 +01:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
|
|
|
|
2019-12-26 14:21:40 +01:00
|
|
|
add_executable(libwg-quick.so wireguard-tools/src/wg-quick/android.c ndk-compat/compat.c)
|
2019-10-04 16:58:58 +02:00
|
|
|
target_compile_options(libwg-quick.so PUBLIC -O3 -std=gnu11 -Wall -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DWG_PACKAGE_NAME=\"${ANDROID_PACKAGE_NAME}\")
|
|
|
|
target_link_libraries(libwg-quick.so -ldl)
|
2017-12-05 03:50:36 +01:00
|
|
|
|
2020-02-03 17:09:45 +01:00
|
|
|
file(GLOB WG_SOURCES wireguard-tools/src/*.c ndk-compat/compat.c)
|
2017-12-05 03:50:36 +01:00
|
|
|
add_executable(libwg.so ${WG_SOURCES})
|
2020-06-07 09:52:21 +02:00
|
|
|
target_include_directories(libwg.so PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/uapi/linux/" "${CMAKE_CURRENT_SOURCE_DIR}/wireguard-tools/src/")
|
2020-02-03 17:09:45 +01:00
|
|
|
target_compile_options(libwg.so PUBLIC -O3 -std=gnu11 -D_GNU_SOURCE -include ${CMAKE_CURRENT_SOURCE_DIR}/ndk-compat/compat.h -DHAVE_VISIBILITY_HIDDEN -DRUNSTATEDIR=\"/data/data/${ANDROID_PACKAGE_NAME}/cache\")
|
2018-02-07 19:19:20 +01:00
|
|
|
|
2023-03-28 18:31:19 +02:00
|
|
|
add_custom_target(libwg-go.so WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libwg-go" COMMENT "Building wireguard-go" VERBATIM COMMAND "${ANDROID_HOST_PREBUILTS}/bin/make"
|
2018-02-07 19:19:20 +01:00
|
|
|
ANDROID_ARCH_NAME=${ANDROID_ARCH_NAME}
|
2018-07-24 14:53:43 +02:00
|
|
|
ANDROID_PACKAGE_NAME=${ANDROID_PACKAGE_NAME}
|
2020-03-29 10:28:41 +02:00
|
|
|
GRADLE_USER_HOME=${GRADLE_USER_HOME}
|
2023-03-21 16:51:18 +01:00
|
|
|
CC=${CMAKE_C_COMPILER}
|
|
|
|
CFLAGS=${CMAKE_C_FLAGS}
|
|
|
|
LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}
|
|
|
|
SYSROOT=${CMAKE_SYSROOT}
|
|
|
|
TARGET=${CMAKE_C_COMPILER_TARGET}
|
2018-02-07 19:19:20 +01:00
|
|
|
DESTDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
2018-10-09 18:26:21 +02:00
|
|
|
BUILDDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../generated-src
|
2018-02-07 19:19:20 +01:00
|
|
|
)
|
|
|
|
# Hack to make it actually build as part of the default target
|
|
|
|
add_dependencies(libwg.so libwg-go.so)
|