2021-08-23 15:48:55 +00:00
|
|
|
|
|
|
|
# 3.13+ so that we can add link libraries to parent targets
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS OR NOT BUILD_STATIC_DEPS OR NOT STATIC_LINK)
|
2022-08-12 22:57:00 +00:00
|
|
|
message(FATAL_ERROR "macOS builds require a full static build; perhaps use the contrib/mac.sh script to build?")
|
2021-08-23 15:48:55 +00:00
|
|
|
endif()
|
|
|
|
|
2022-08-06 18:12:29 +00:00
|
|
|
# god (steve jobs) made apple so that man may suffer
|
2021-08-23 15:48:55 +00:00
|
|
|
find_library(FOUNDATION Foundation REQUIRED)
|
|
|
|
find_library(NETEXT NetworkExtension REQUIRED)
|
|
|
|
find_library(COREFOUNDATION CoreFoundation REQUIRED)
|
|
|
|
|
|
|
|
target_link_libraries(lokinet-util PUBLIC ${FOUNDATION})
|
|
|
|
|
2021-09-01 18:10:08 +00:00
|
|
|
target_sources(lokinet-platform PRIVATE vpn_platform.cpp vpn_interface.cpp route_manager.cpp context_wrapper.cpp)
|
2021-08-25 23:28:58 +00:00
|
|
|
|
|
|
|
add_executable(lokinet-extension MACOSX_BUNDLE
|
|
|
|
PacketTunnelProvider.m
|
2021-08-31 23:15:48 +00:00
|
|
|
DNSTrampoline.m
|
2022-07-28 16:07:38 +00:00
|
|
|
)
|
|
|
|
|
2021-09-02 22:07:40 +00:00
|
|
|
enable_lto(lokinet-extension)
|
2021-08-25 23:28:58 +00:00
|
|
|
|
|
|
|
# -fobjc-arc enables automatic reference counting for objective-C code
|
|
|
|
# -e _NSExtensionMain because the appex has that instead of a `main` function entry point, of course.
|
2022-06-22 21:56:35 +00:00
|
|
|
target_compile_options(lokinet-extension PRIVATE -fobjc-arc)
|
|
|
|
if(MACOS_SYSTEM_EXTENSION)
|
|
|
|
target_compile_definitions(lokinet-extension PRIVATE MACOS_SYSTEM_EXTENSION)
|
|
|
|
target_compile_definitions(lokinet-util PUBLIC MACOS_SYSTEM_EXTENSION)
|
|
|
|
else()
|
|
|
|
target_link_options(lokinet-extension PRIVATE -e _NSExtensionMain)
|
|
|
|
endif()
|
2021-08-25 23:28:58 +00:00
|
|
|
|
2022-06-22 21:56:35 +00:00
|
|
|
if(MACOS_SYSTEM_EXTENSION)
|
|
|
|
set(bundle_ext systemextension)
|
|
|
|
set(product_type com.apple.product-type.system-extension)
|
|
|
|
else()
|
|
|
|
set(bundle_ext appex)
|
|
|
|
set(product_type com.apple.product-type.app-extension)
|
|
|
|
endif()
|
2021-08-23 15:48:55 +00:00
|
|
|
|
2022-07-28 16:07:38 +00:00
|
|
|
target_link_libraries(lokinet-extension PRIVATE
|
|
|
|
lokinet-amalgum
|
|
|
|
${COREFOUNDATION}
|
|
|
|
${NETEXT})
|
|
|
|
|
2021-08-23 15:48:55 +00:00
|
|
|
set_target_properties(lokinet-extension PROPERTIES
|
|
|
|
BUNDLE TRUE
|
2022-06-22 21:56:35 +00:00
|
|
|
BUNDLE_EXTENSION ${bundle_ext}
|
|
|
|
OUTPUT_NAME org.lokinet.network-extension
|
|
|
|
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/contrib/macos/lokinet-extension.Info.plist.in
|
|
|
|
XCODE_PRODUCT_TYPE ${product_type}
|
2021-08-23 15:48:55 +00:00
|
|
|
)
|
|
|
|
|
2022-06-22 21:56:35 +00:00
|
|
|
if(CODESIGN AND CODESIGN_EXT_PROFILE)
|
|
|
|
add_custom_command(TARGET lokinet-extension
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
${CODESIGN_EXT_PROFILE}
|
|
|
|
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/embedded.provisionprofile
|
2021-08-23 15:48:55 +00:00
|
|
|
)
|
2022-06-22 21:56:35 +00:00
|
|
|
endif()
|