2022-06-22 21:56:35 +00:00
|
|
|
set(exetargets lokinet)
|
|
|
|
|
2021-05-14 17:07:44 +00:00
|
|
|
if(APPLE)
|
2021-09-02 22:16:43 +00:00
|
|
|
add_executable(lokinet lokinet.swift)
|
2022-08-29 18:53:16 +00:00
|
|
|
target_compile_options(lokinet BEFORE PRIVATE -target x86_64-apple-macos${CMAKE_OSX_DEPLOYMENT_TARGET})
|
2021-05-14 17:07:44 +00:00
|
|
|
else()
|
|
|
|
add_executable(lokinet lokinet.cpp)
|
2021-09-24 14:10:08 +00:00
|
|
|
endif()
|
2022-06-22 21:56:35 +00:00
|
|
|
add_executable(lokinet-vpn lokinet-vpn.cpp)
|
|
|
|
enable_lto(lokinet lokinet-vpn)
|
|
|
|
list(APPEND exetargets lokinet-vpn)
|
|
|
|
|
2021-09-24 14:10:08 +00:00
|
|
|
if(WITH_BOOTSTRAP)
|
|
|
|
add_executable(lokinet-bootstrap lokinet-bootstrap.cpp)
|
2022-06-22 21:56:35 +00:00
|
|
|
list(APPEND exetargets lokinet-bootstrap)
|
2021-09-24 14:10:08 +00:00
|
|
|
enable_lto(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-09-10 14:41:42 +00:00
|
|
|
if(WITH_BOOTSTRAP)
|
2021-06-30 11:21:17 +00:00
|
|
|
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
|
|
|
|
2022-07-28 16:07:38 +00:00
|
|
|
# cmake interface library for bunch of cmake hacks to fix final link order
|
|
|
|
add_library(hax_and_shims_for_cmake INTERFACE)
|
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(hax_and_shims_for_cmake INTERFACE uvw oxenmq::oxenmq -lws2_32 -lshlwapi -ldbghelp -luser32 -liphlpapi -lpsapi -luserenv)
|
|
|
|
endif()
|
|
|
|
|
2021-05-14 17:07:44 +00:00
|
|
|
foreach(exe ${exetargets})
|
2022-07-28 16:07:38 +00:00
|
|
|
if(WIN32)
|
2022-05-27 14:14:31 +00:00
|
|
|
target_sources(${exe} PRIVATE ${CMAKE_BINARY_DIR}/${exe}.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
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
target_link_directories(${exe} PRIVATE /usr/local/lib)
|
|
|
|
endif()
|
2022-07-28 16:07:38 +00:00
|
|
|
target_link_libraries(${exe} PUBLIC lokinet-amalgum hax_and_shims_for_cmake)
|
|
|
|
if(STRIP_SYMBOLS)
|
|
|
|
add_custom_command(TARGET ${exe}
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} ARGS --only-keep-debug $<TARGET_FILE:${exe}> $<TARGET_FILE:${exe}>.debug
|
|
|
|
COMMAND ${CMAKE_STRIP} ARGS --strip-all $<TARGET_FILE:${exe}>)
|
|
|
|
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
|
|
|
if(should_install)
|
2021-05-14 17:07:44 +00:00
|
|
|
if(APPLE)
|
2022-06-22 21:56:35 +00:00
|
|
|
install(TARGETS ${exe}
|
|
|
|
BUNDLE DESTINATION "${PROJECT_BINARY_DIR}"
|
|
|
|
RUNTIME DESTINATION "."
|
|
|
|
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()
|
|
|
|
|
|
|
|
if(SETCAP)
|
|
|
|
install(CODE "execute_process(COMMAND ${SETCAP} cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
|
|
|
endif()
|
2022-07-28 16:07:38 +00:00
|
|
|
|
|
|
|
if(STRIP_SYMBOLS)
|
|
|
|
add_custom_target(symbols ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar cJf ${CMAKE_CURRENT_BINARY_DIR}/debug-symbols.tar.xz $<TARGET_FILE:lokinet>.debug
|
|
|
|
DEPENDS lokinet)
|
|
|
|
endif()
|