2021-04-15 17:39:45 +00:00
|
|
|
add_executable(lokinet lokinet.cpp)
|
2021-03-04 19:02:53 +00:00
|
|
|
add_executable(lokinet-vpn lokinet-vpn.cpp)
|
2021-04-15 17:39:45 +00:00
|
|
|
add_executable(lokinet-bootstrap lokinet-bootstrap.cpp)
|
|
|
|
enable_lto(lokinet lokinet-vpn lokinet-bootstrap)
|
2019-10-07 10:08:47 +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-04-15 17:39:45 +00:00
|
|
|
target_link_libraries(lokinet-bootstrap PUBLIC cpr::cpr)
|
2021-04-16 13:40:36 +00:00
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
# because debian sid's curl doesn't link against openssl for some godawful cursed reason
|
2021-04-20 02:45:36 +00:00
|
|
|
target_link_libraries(lokinet-bootstrap PUBLIC OpenSSL::SSL OpenSSL::Crypto)
|
2021-04-16 13:40:36 +00:00
|
|
|
endif()
|
2021-04-15 17:39:45 +00:00
|
|
|
|
|
|
|
foreach(exe lokinet lokinet-vpn lokinet-bootstrap)
|
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()
|
|
|
|
target_link_libraries(${exe} PRIVATE liblokinet)
|
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
target_link_libraries(${exe} PUBLIC jemalloc)
|
|
|
|
endif()
|
2021-04-16 09:51:34 +00:00
|
|
|
target_include_directories(${exe} PRIVATE ${CMAKE_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)
|
|
|
|
install(TARGETS ${exe} RUNTIME DESTINATION bin COMPONENT lokinet)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(SETCAP)
|
|
|
|
install(CODE "execute_process(COMMAND ${SETCAP} cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
|
|
|
endif()
|