You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/CMakeLists.txt

301 lines
7.6 KiB
CMake

include(Version)
add_library(lokinet-util
STATIC
${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp
util/bencode.cpp
util/buffer.cpp
util/fs.cpp
util/json.cpp
util/logging/buffer.cpp
util/easter_eggs.cpp
util/mem.cpp
util/str.cpp
util/thread/queue_manager.cpp
util/thread/threading.cpp
util/time.cpp)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
add_dependencies(lokinet-util genversion)
target_include_directories(lokinet-util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR})
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
target_link_libraries(lokinet-util PUBLIC
lokinet-cryptography
nlohmann_json::nlohmann_json
filesystem
oxenc::oxenc
oxen::logging
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
add_library(lokinet-platform
STATIC
# for networking
ev/ev.cpp
ev/libuv.cpp
net/ip.cpp
net/ip_address.cpp
net/ip_packet.cpp
net/ip_range.cpp
5 years ago
net/net_int.cpp
net/sock_addr.cpp
vpn/packet_router.cpp
vpn/egres_packet_router.cpp
vpn/platform.cpp
)
Replace libuv with uvw & related refactoring - removes all the llarp_ev_* functions, replacing with methods/classes/functions in the llarp namespace. - banish ev/ev.h to the void - Passes various things by const lvalue ref, especially shared_ptr's that don't need to be copied (to avoid an atomic refcount increment/decrement). - Add a llarp::UDPHandle abstract class for UDP handling - Removes the UDP tick handler; code that needs tick can just do a separate handler on the event loop outside the UDP socket. - Adds an "OwnedBuffer" which owns its own memory but is implicitly convertible to a llarp_buffer_t. This is mostly needed to take over ownership of buffers from uvw without copying them as, currently, uvw does its own allocation (pending some open upstream issues/PRs). - Logic: - add `make_caller`/`call_forever`/`call_every` utility functions to abstract Call wrapping and dependent timed tasks. - Add inLogicThread() so that code can tell its inside the logic thread (typically for debugging assertions). - get rid of janky integer returns and dealing with cancellations on call_later: the other methods added here and the event loop code remove the need for them. - Event loop: - redo everything with uvw instead of libuv - rename EventLoopWakeup::Wakeup to EventLoopWakeup::Trigger to better reflect what it does. - add EventLoopRepeater for repeated events, and replace the code that reschedules itself every time it is called with a repeater. - Split up `EventLoop::run()` into a non-virtual base method and abstract `run_loop()` methods; the base method does a couple extra setup/teardown things that don't need to be in the derived class. - udp_listen is replaced with ev->udp(...) which returns a new UDPHandle object rather that needing gross C-style-but-not-actually-C-compatible structs. - Remove unused register_poll_fd_(un)readable - Use shared_ptr for EventLoopWakeup rather than returning a raw pointer; uvw lets us not have to worry about having the event loop class maintain ownership of it. - Add factory EventLoop::create() function to create a default (uvw-based) event loop (previously this was one of the llarp_ev_blahblah unnamespaced functions). - ev_libuv: this is mostly rewritten; all of the glue code/structs, in particular, are gone as they are no longer needed with uvw. - DNS: - Rename DnsHandler to DnsInterceptor to better describe what it does (this is the code that intercepts all DNS to the tun IP range for Android). - endpoint: - remove unused "isolated network" code - remove distinct (but actually always the same) variables for router/endpoint logic objects - llarp_buffer_t - make constructors type-safe against being called with points to non-size-1 values - tun packet reading: - read all available packets off the device/file descriptor; previously we were reading one packet at a time then returning to the event loop to poll again. - ReadNextPacket() now returns a 0-size packet if the read would block (so that we can implement the previous point). - ReadNextPacket() now throws on I/O error - Miscellaneous code cleanups/simplifications
3 years ago
target_link_libraries(lokinet-platform PUBLIC lokinet-cryptography lokinet-util Threads::Threads base_libs uvw)
target_link_libraries(lokinet-platform PRIVATE oxenmq::oxenmq)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if (ANDROID)
target_sources(lokinet-platform PRIVATE android/ifaddrs.c)
endif()
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
target_sources(lokinet-platform PRIVATE linux/dbus.cpp)
endif()
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if (WIN32)
target_sources(lokinet-platform PRIVATE
net/win32.cpp
vpn/win32.cpp
win32/exec.cpp)
add_library(lokinet-win32 STATIC
win32/dll.cpp
win32/exception.cpp)
add_library(lokinet-wintun STATIC
win32/wintun.cpp)
add_library(lokinet-windivert STATIC
win32/windivert.cpp)
# wintun and windivert are privated linked by lokinet-platform
# this is so their details do not leak out to deps of lokinet-platform
# wintun and windivert still need things from lokinet-platform
target_compile_options(lokinet-wintun PUBLIC -I${CMAKE_BINARY_DIR}/wintun/include/)
target_compile_options(lokinet-windivert PUBLIC -I${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/include/)
target_include_directories(lokinet-windivert PUBLIC ${PROJECT_SOURCE_DIR})
target_link_libraries(lokinet-wintun PUBLIC lokinet-platform lokinet-util lokinet-config)
target_link_libraries(lokinet-win32 PUBLIC lokinet-util)
target_link_libraries(lokinet-windivert PUBLIC oxen-logging)
target_link_libraries(lokinet-windivert PRIVATE lokinet-win32)
target_link_libraries(lokinet-platform PRIVATE lokinet-win32 lokinet-wintun lokinet-windivert)
else()
target_sources(lokinet-platform PRIVATE
net/posix.cpp)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
endif()
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
target_include_directories(lokinet-platform SYSTEM PUBLIC /usr/local/include)
endif()
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
add_library(lokinet-dns
STATIC
dns/message.cpp
dns/name.cpp
dns/platform.cpp
dns/question.cpp
dns/rr.cpp
dns/serialize.cpp
dns/server.cpp
dns/srv_data.cpp)
if(WITH_SYSTEMD)
target_sources(lokinet-dns PRIVATE dns/nm_platform.cpp dns/sd_platform.cpp)
endif()
target_link_libraries(lokinet-dns PUBLIC lokinet-platform uvw)
target_link_libraries(lokinet-dns PRIVATE libunbound lokinet-config)
add_library(lokinet-config
STATIC
config/config.cpp
config/definition.cpp
config/ini.cpp
config/key_manager.cpp)
target_link_libraries(lokinet-config PUBLIC lokinet-dns lokinet-platform oxenmq::oxenmq)
add_library(lokinet-amalgum
STATIC
consensus/reachability_testing.cpp
bootstrap.cpp
context.cpp
crypto/crypto_libsodium.cpp
crypto/crypto.cpp
crypto/encrypted_frame.cpp
crypto/types.cpp
dht/context.cpp
dht/dht.cpp
dht/explorenetworkjob.cpp
dht/localtaglookup.cpp
dht/localrouterlookup.cpp
dht/localserviceaddresslookup.cpp
dht/message.cpp
dht/messages/findintro.cpp
dht/messages/findrouter.cpp
dht/messages/gotintro.cpp
dht/messages/gotrouter.cpp
dht/messages/pubintro.cpp
dht/messages/findname.cpp
dht/messages/gotname.cpp
dht/publishservicejob.cpp
dht/recursiverouterlookup.cpp
dht/serviceaddresslookup.cpp
dht/taglookup.cpp
endpoint_base.cpp
exit/context.cpp
exit/endpoint.cpp
exit/exit_messages.cpp
exit/policy.cpp
exit/session.cpp
handlers/exit.cpp
handlers/tun.cpp
iwp/iwp.cpp
5 years ago
iwp/linklayer.cpp
iwp/message_buffer.cpp
iwp/session.cpp
link/link_manager.cpp
link/session.cpp
link/server.cpp
messages/dht_immediate.cpp
messages/link_intro.cpp
messages/link_message_parser.cpp
messages/relay.cpp
messages/relay_commit.cpp
messages/relay_status.cpp
net/address_info.cpp
net/exit_info.cpp
net/traffic_policy.cpp
nodedb.cpp
path/ihophandler.cpp
path/path_context.cpp
path/path.cpp
path/pathbuilder.cpp
path/pathset.cpp
path/transit_hop.cpp
peerstats/peer_db.cpp
peerstats/types.cpp
pow.cpp
profiling.cpp
quic/address.cpp
quic/client.cpp
quic/connection.cpp
quic/endpoint.cpp
quic/null_crypto.cpp
quic/server.cpp
quic/stream.cpp
quic/tunnel.cpp
router_contact.cpp
router_id.cpp
router_version.cpp
service/name.cpp
router/outbound_message_handler.cpp
router/outbound_session_maker.cpp
router/rc_lookup_handler.cpp
4 years ago
router/rc_gossiper.cpp
router/router.cpp
router/route_poker.cpp
routing/dht_message.cpp
routing/message_parser.cpp
routing/path_confirm_message.cpp
routing/path_latency_message.cpp
routing/path_transfer_message.cpp
routing/transfer_traffic_message.cpp
rpc/lokid_rpc_client.cpp
rpc/rpc_server.cpp
4 years ago
rpc/endpoint_rpc.cpp
service/address.cpp
service/async_key_exchange.cpp
4 years ago
service/auth.cpp
3 years ago
service/convotag.cpp
service/context.cpp
service/endpoint_state.cpp
service/endpoint_util.cpp
service/endpoint.cpp
service/hidden_service_address_lookup.cpp
service/identity.cpp
service/info.cpp
service/intro_set.cpp
service/intro.cpp
service/lns_tracker.cpp
service/lookup.cpp
service/name.cpp
service/outbound_context.cpp
service/protocol.cpp
service/router_lookup_job.cpp
service/sendcontext.cpp
service/session.cpp
service/tag.cpp
)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if(WITH_PEERSTATS_BACKEND)
target_compile_definitions(lokinet-amalgum PRIVATE -DLOKINET_PEERSTATS_BACKEND)
target_link_libraries(lokinet-amalgum PUBLIC sqlite_orm)
endif()
if(WITH_HIVE)
target_sources(lokinet-amalgum PRIVATE
tooling/router_hive.cpp
tooling/hive_router.cpp
tooling/hive_context.cpp
)
endif()
# TODO: make libunbound hidden behind a feature flag like sqlite for embedded lokinet
target_link_libraries(lokinet-amalgum PRIVATE libunbound)
target_link_libraries(lokinet-amalgum PUBLIC
cxxopts
oxenc::oxenc
lokinet-platform
lokinet-config
lokinet-dns
lokinet-util
lokinet-cryptography
ngtcp2_static
oxenmq::oxenmq)
enable_lto(lokinet-util lokinet-platform lokinet-dns lokinet-config lokinet-amalgum)
pkg_check_modules(CRYPT libcrypt IMPORTED_TARGET)
if(CRYPT_FOUND AND NOT CMAKE_CROSSCOMPILING)
add_definitions(-DHAVE_CRYPT)
add_library(libcrypt INTERFACE)
target_link_libraries(libcrypt INTERFACE PkgConfig::CRYPT)
target_link_libraries(lokinet-amalgum PRIVATE libcrypt)
message(STATUS "using libcrypt ${CRYPT_VERSION}")
endif()
5 years ago
if(BUILD_LIBLOKINET)
include(GNUInstallDirs)
add_library(lokinet-shared SHARED lokinet_shared.cpp)
target_link_libraries(lokinet-shared PUBLIC lokinet-amalgum)
cmake refactor Refactors many things in cmake to improve and simplify: - don't use variable indirection for target names; target names are *already* a variable of sorts. (e.g. ${UTIL_LIB} is now just lokinet-util). cmake/basic_definitions.cmake is now gone. - fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather than shoving a bunch of flag hacks through link_libraries and add_compile_options. This also now enables LTO when building a shared library (because previously the -flto hacks were only turned on in the static code for some reason). - build liblokinet as *either* shared library or static library, but not both. Building both makes things more complicated because they had different names (lokinet-shared or lokinet-static) and seems pointless: you generally want one or the other. Now there is just the liblokinet target, which will be shared or static depending on the value of BUILD_SHARED_LIBS. - Simplify lokinet-cryptography AVX2 code: just build *one* library, and add in the additional AVX2 files when possible, rather than building two and needing to merge them. - Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK. It makes no sense to use one of these (_RUNTIME) on Windows and the other on non-Windows when they appear to try to do the same thing. - remove a bunch of annotations from `endif(FOO)` -> `endif()`. - move all the tuntap compilation code (including OS-specific source file selection) into vendor/CMakeLists.txt and build tuntap as an intermediate OBJECT library rather than keeping a global variable in 5 different files. - move release motto define to root cmake; it made no sense being duplicated in both unix.cmake and win32.cmake - fix add_log_tag to not stomp on any existing source compile flags with its definition. Also use proper compile definition property instead of cramming it into compile flags. - make optimization/linker flags less hacky. There's no reason for us to force particular optimization flags because the cmake build type already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3). Not doing that also silences a bunch of cmake warnings because it thinks "-O0 -g3" etc. are link libraries (which is reasonable: that's what the code was telling cmake they are). - sets the default build type to RelWithDebInfo which gives us `-O2 -g` if you don't specify a build type. - Move PIC up (so that the things loaded in unix.cmake, notably libuv, have it set). - Add a custom `curl` interface library that carries the correct link target and include paths for curl (system or bundled).
4 years ago
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX_CXX "")
endif()
set_target_properties(lokinet-shared PROPERTIES OUTPUT_NAME lokinet)
if(WIN32)
target_link_libraries(lokinet-shared PUBLIC ws2_32 iphlpapi -fstack-protector)
install(TARGETS lokinet-shared DESTINATION bin COMPONENT liblokinet)
elseif(NOT APPLE)
install(TARGETS lokinet-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT liblokinet)
endif()
endif()
if(APPLE)
add_subdirectory(apple)
endif()
file(GLOB_RECURSE docs_SRC */*.hpp *.hpp)
set(DOCS_SRC ${docs_SRC} PARENT_SCOPE)