2021-07-29 20:40:25 +00:00
|
|
|
|
|
|
|
add_executable(lokinet-vpn lokinet-vpn.cpp)
|
2021-05-14 17:07:44 +00:00
|
|
|
if(APPLE)
|
2021-06-30 11:21:17 +00:00
|
|
|
set(LOKINET_SWIFT_SOURCES lokinet.swift)
|
|
|
|
add_executable(lokinet ${LOKINET_SWIFT_SOURCES})
|
2021-07-29 20:40:25 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Lokinet.modulemap.in ${CMAKE_CURRENT_BINARY_DIR}/swift/LokinetExtension/module.modulemap ESCAPE_QUOTES @ONLY)
|
2021-06-30 11:21:17 +00:00
|
|
|
target_include_directories(lokinet PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/swift)
|
2021-05-14 17:07:44 +00:00
|
|
|
else()
|
|
|
|
add_executable(lokinet lokinet.cpp)
|
2021-06-30 11:21:17 +00:00
|
|
|
add_executable(lokinet-bootstrap lokinet-bootstrap.cpp)
|
|
|
|
enable_lto(lokinet lokinet-vpn lokinet-bootstrap)
|
2021-05-14 17:07:44 +00:00
|
|
|
endif()
|
2019-10-07 10:08:47 +00:00
|
|
|
|
2021-07-29 20:40:25 +00:00
|
|
|
|
2021-03-04 19:02:53 +00:00
|
|
|
if(TRACY_ROOT)
|
|
|
|
target_sources(lokinet PRIVATE ${TRACY_ROOT}/TracyClient.cpp)
|
|
|
|
endif()
|
2019-10-05 15:03:25 +00:00
|
|
|
|
2021-03-04 19:02:53 +00:00
|
|
|
set(should_install ON)
|
|
|
|
set(SETCAP)
|
2020-05-17 19:41:48 +00:00
|
|
|
|
2021-03-04 19:02:53 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
option(WITH_SETCAP "use setcap when installing" ON)
|
|
|
|
if(WITH_SETCAP)
|
|
|
|
find_program(SETCAP NAMES setcap HINTS /sbin /usr/sbin)
|
|
|
|
if(SETCAP)
|
|
|
|
message(STATUS "Found setcap binary: ${SETCAP}")
|
2019-10-05 15:03:25 +00:00
|
|
|
else()
|
2021-03-04 19:02:53 +00:00
|
|
|
message(WARNING "cannot find setcap binary you will not be able use the install targets unless you use -DWITH_SETCAP=OFF")
|
|
|
|
set(should_install OFF)
|
2019-10-05 15:03:25 +00:00
|
|
|
endif()
|
2021-03-04 19:02:53 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-10-05 15:03:25 +00:00
|
|
|
|
2021-06-30 11:21:17 +00:00
|
|
|
if(NOT APPLE)
|
|
|
|
target_link_libraries(lokinet-bootstrap PUBLIC cpr::cpr)
|
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
# because debian sid's curl doesn't link against openssl for some godawful cursed reason
|
|
|
|
target_link_libraries(lokinet-bootstrap PUBLIC OpenSSL::SSL OpenSSL::Crypto)
|
|
|
|
endif()
|
2021-04-16 13:40:36 +00:00
|
|
|
endif()
|
2021-04-15 17:39:45 +00:00
|
|
|
|
2021-07-29 20:40:25 +00:00
|
|
|
set(exetargets lokinet lokinet-vpn)
|
2021-07-27 18:43:48 +00:00
|
|
|
if(NOT APPLE)
|
2021-07-29 20:40:25 +00:00
|
|
|
list(APPEND exetargets lokinet-bootstrap)
|
2021-05-14 17:07:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(exe ${exetargets})
|
2021-03-04 19:02:53 +00:00
|
|
|
if(WIN32 AND NOT MSVC_VERSION)
|
|
|
|
target_sources(${exe} PRIVATE ../llarp/win32/version.rc)
|
2021-06-08 12:14:57 +00:00
|
|
|
target_link_libraries(${exe} PRIVATE -static-libstdc++ -static-libgcc --static -Wl,--pic-executable,-e,mainCRTStartup,--subsystem,console:5.00)
|
2021-03-04 19:02:53 +00:00
|
|
|
target_link_libraries(${exe} PRIVATE ws2_32 iphlpapi)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
target_link_directories(${exe} PRIVATE /usr/local/lib)
|
|
|
|
endif()
|
2021-06-30 11:21:17 +00:00
|
|
|
target_link_libraries(${exe} PUBLIC liblokinet)
|
2021-03-04 19:02:53 +00:00
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
target_link_libraries(${exe} PUBLIC jemalloc)
|
|
|
|
endif()
|
2021-06-30 11:21:17 +00:00
|
|
|
target_include_directories(${exe} PUBLIC "${PROJECT_SOURCE_DIR}")
|
2021-03-04 19:02:53 +00:00
|
|
|
target_compile_definitions(${exe} PRIVATE -DVERSIONTAG=${GIT_VERSION_REAL})
|
|
|
|
add_log_tag(${exe})
|
|
|
|
if(should_install)
|
2021-05-14 17:07:44 +00:00
|
|
|
if(APPLE)
|
2021-07-27 18:43:48 +00:00
|
|
|
install(TARGETS ${exe} BUNDLE DESTINATION "${PROJECT_BINARY_DIR}" COMPONENT lokinet)
|
2021-05-14 17:07:44 +00:00
|
|
|
else()
|
|
|
|
install(TARGETS ${exe} RUNTIME DESTINATION bin COMPONENT lokinet)
|
|
|
|
endif()
|
2021-03-04 19:02:53 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-05-14 17:07:44 +00:00
|
|
|
if(APPLE)
|
2021-07-27 18:43:48 +00:00
|
|
|
|
2021-07-29 17:09:18 +00:00
|
|
|
set(CODESIGN_APP "" CACHE STRING "codesign the macos app using this key identity")
|
2021-07-29 17:26:12 +00:00
|
|
|
set(CODESIGN_APPEX "${CODESIGN_APP}" CACHE STRING "codesign the internal extension using this key identity; defaults to CODESIGN_APP if empty")
|
2021-07-27 18:43:48 +00:00
|
|
|
|
2021-08-25 16:30:30 +00:00
|
|
|
set(mac_icon ${CMAKE_CURRENT_BINARY_DIR}/lokinet.icns)
|
|
|
|
add_custom_command(OUTPUT ${mac_icon}
|
|
|
|
COMMAND ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg ${mac_icon}
|
2021-05-14 17:07:44 +00:00
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh)
|
2021-08-25 16:30:30 +00:00
|
|
|
add_custom_target(icons DEPENDS ${mac_icon})
|
2021-05-14 17:07:44 +00:00
|
|
|
add_dependencies(lokinet icons lokinet-extension)
|
2021-07-29 20:40:25 +00:00
|
|
|
file(DOWNLOAD "https://seed.lokinet.org/lokinet.signed" ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.signed)
|
2021-07-27 18:43:48 +00:00
|
|
|
add_custom_command(TARGET lokinet
|
|
|
|
POST_BUILD
|
2021-07-29 20:40:25 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.signed
|
|
|
|
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/Resources/bootstrap.signed
|
2021-07-29 17:09:18 +00:00
|
|
|
COMMAND mkdir -p $<TARGET_BUNDLE_DIR:lokinet>/Contents/PlugIns
|
2021-07-29 20:40:25 +00:00
|
|
|
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet-extension> $<TARGET_BUNDLE_DIR:lokinet>/Contents/PlugIns/
|
2021-07-27 18:43:48 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/contrib/macos/lokinet.provisionprofile
|
|
|
|
$<TARGET_BUNDLE_DIR:lokinet>/Contents/embedded.provisionprofile
|
|
|
|
)
|
|
|
|
|
2021-05-14 17:07:44 +00:00
|
|
|
set_target_properties(lokinet
|
|
|
|
PROPERTIES
|
|
|
|
MACOSX_BUNDLE TRUE
|
|
|
|
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
|
|
|
|
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
|
2021-06-30 11:21:17 +00:00
|
|
|
MACOSX_BUNDLE_BUNDLE_VERSION "${LOKINET_VERSION}"
|
2021-07-27 18:43:48 +00:00
|
|
|
MACOSX_BUNDLE_LONG_VERSION_STRING "${lokinet_VERSION}"
|
2021-05-14 17:07:44 +00:00
|
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}"
|
2021-06-30 11:21:17 +00:00
|
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER "com.loki-project.lokinet"
|
2021-07-28 14:30:42 +00:00
|
|
|
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/contrib/macos/Info.plist.in"
|
2021-08-25 16:30:30 +00:00
|
|
|
MACOSX_BUNDLE_ICON_FILE "${mac_icon}"
|
2021-07-27 18:43:48 +00:00
|
|
|
MACOSX_BUNDLE_COPYRIGHT "© 2021, The Oxen Project")
|
2021-07-29 17:26:12 +00:00
|
|
|
if (CODESIGN_APP AND CODESIGN_APPEX)
|
|
|
|
message(STATUS "codesigning with ${CODESIGN_APP} (app) ${CODESIGN_APPEX} (appex)")
|
2021-07-27 18:43:48 +00:00
|
|
|
set(SIGN_TARGET "${CMAKE_CURRENT_BINARY_DIR}/lokinet.app")
|
2021-05-14 17:07:44 +00:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/contrib/macos/sign.sh.in"
|
2021-07-27 18:43:48 +00:00
|
|
|
"${PROJECT_BINARY_DIR}/sign.sh"
|
|
|
|
@ONLY)
|
2021-05-14 17:07:44 +00:00
|
|
|
add_custom_target(
|
|
|
|
sign
|
2021-08-25 23:28:58 +00:00
|
|
|
DEPENDS "${PROJECT_BINARY_DIR}/sign.sh" lokinet lokinet-extension
|
2021-07-27 18:43:48 +00:00
|
|
|
COMMAND "${PROJECT_BINARY_DIR}/sign.sh"
|
2021-05-14 17:07:44 +00:00
|
|
|
)
|
|
|
|
else()
|
2021-07-29 17:26:12 +00:00
|
|
|
message(WARNING "Not codesigning: CODESIGN_APP (=${CODESIGN_APP}) and/or CODESIGN_APPEX (=${CODESIGN_APPEX}) are not set")
|
2021-08-16 13:07:31 +00:00
|
|
|
add_custom_target(
|
|
|
|
sign
|
2021-08-25 23:28:58 +00:00
|
|
|
DEPENDS lokinet lokinet-extension
|
2021-08-16 13:07:31 +00:00
|
|
|
COMMAND "true")
|
2021-05-14 17:07:44 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-03-04 19:02:53 +00:00
|
|
|
if(SETCAP)
|
|
|
|
install(CODE "execute_process(COMMAND ${SETCAP} cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
|
|
|
endif()
|