2022-05-07 10:54:14 -07:00
|
|
|
project(wpinet)
|
|
|
|
|
|
|
|
|
|
include(SubDirList)
|
|
|
|
|
include(GenResources)
|
|
|
|
|
include(CompileWarnings)
|
|
|
|
|
include(AddTest)
|
|
|
|
|
|
|
|
|
|
file(GLOB wpinet_jni_src src/main/native/cpp/jni/WPINetJNI.cpp)
|
|
|
|
|
|
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(NOT MSVC AND NOT APPLE)
|
2022-05-07 10:54:14 -07:00
|
|
|
find_library(ATOMIC NAMES atomic libatomic.so.1)
|
2023-11-30 19:52:21 -05:00
|
|
|
if(ATOMIC)
|
2022-05-07 10:54:14 -07:00
|
|
|
message(STATUS "Found libatomic: ${ATOMIC}")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
file(
|
|
|
|
|
GLOB_RECURSE wpinet_native_src
|
|
|
|
|
src/main/native/cpp/*.cpp
|
|
|
|
|
src/main/native/thirdparty/tcpsockets/cpp/*.cpp
|
|
|
|
|
)
|
2022-05-07 10:54:14 -07:00
|
|
|
list(REMOVE_ITEM wpinet_native_src ${wpinet_jni_src})
|
|
|
|
|
file(GLOB_RECURSE wpinet_unix_src src/main/native/unix/*.cpp)
|
|
|
|
|
file(GLOB_RECURSE wpinet_linux_src src/main/native/linux/*.cpp)
|
|
|
|
|
file(GLOB_RECURSE wpinet_macos_src src/main/native/macOS/*.cpp)
|
|
|
|
|
file(GLOB_RECURSE wpinet_windows_src src/main/native/windows/*.cpp)
|
|
|
|
|
|
|
|
|
|
file(GLOB uv_native_src src/main/native/thirdparty/libuv/src/*.cpp)
|
|
|
|
|
|
|
|
|
|
file(GLOB uv_windows_src src/main/native/thirdparty/libuv/src/win/*.cpp)
|
|
|
|
|
|
|
|
|
|
set(uv_unix_src
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/async.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/core.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/dl.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/fs.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/loop-watcher.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/loop.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/pipe.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/poll.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/process.cpp
|
2022-05-18 20:40:27 -07:00
|
|
|
src/main/native/thirdparty/libuv/src/unix/random-devurandom.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/random-getentropy.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/random-getrandom.cpp
|
2022-05-07 10:54:14 -07:00
|
|
|
src/main/native/thirdparty/libuv/src/unix/signal.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/stream.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/tcp.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/thread.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/tty.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/udp.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(uv_darwin_src
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/bsd-ifaddrs.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/darwin.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/darwin-proctitle.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/fsevents.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/kqueue.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/proctitle.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(uv_linux_src
|
2023-07-14 18:55:32 -07:00
|
|
|
src/main/native/thirdparty/libuv/src/unix/linux.cpp
|
2022-05-07 10:54:14 -07:00
|
|
|
src/main/native/thirdparty/libuv/src/unix/procfs-exepath.cpp
|
|
|
|
|
src/main/native/thirdparty/libuv/src/unix/proctitle.cpp
|
2022-05-18 20:40:27 -07:00
|
|
|
src/main/native/thirdparty/libuv/src/unix/random-sysctl-linux.cpp
|
2022-05-07 10:54:14 -07:00
|
|
|
)
|
|
|
|
|
|
2025-11-01 22:09:38 -06:00
|
|
|
add_library(wpinet ${wpinet_native_src})
|
2022-05-07 10:54:14 -07:00
|
|
|
set_target_properties(wpinet PROPERTIES DEBUG_POSTFIX "d")
|
|
|
|
|
|
|
|
|
|
set_property(TARGET wpinet PROPERTY FOLDER "libraries")
|
|
|
|
|
|
2026-04-26 00:15:39 -07:00
|
|
|
target_compile_features(wpinet PUBLIC cxx_std_23)
|
2022-05-07 10:54:14 -07:00
|
|
|
wpilib_target_warnings(wpinet)
|
|
|
|
|
target_link_libraries(wpinet PUBLIC wpiutil)
|
|
|
|
|
|
2025-12-12 19:39:26 -08:00
|
|
|
if(USE_LINKED_AVAHI)
|
|
|
|
|
find_library(AVAHI_COMMON REQUIRED NAMES avahi-common)
|
|
|
|
|
if(AVAHI_COMMON)
|
|
|
|
|
message(STATUS "Found avahi common: ${AVAHI_COMMON}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
find_library(AVAHI_CLIENT REQUIRED NAMES avahi-client)
|
|
|
|
|
if(AVAHI_CLIENT)
|
|
|
|
|
message(STATUS "Found avahi client: ${AVAHI_CLIENT}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
target_link_libraries(wpinet PUBLIC ${AVAHI_COMMON} ${AVAHI_CLIENT})
|
|
|
|
|
target_compile_definitions(wpinet PRIVATE DIRECT_LINK_AVAHI)
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(NOT USE_SYSTEM_LIBUV)
|
2022-05-07 10:54:14 -07:00
|
|
|
target_sources(wpinet PRIVATE ${uv_native_src})
|
2023-11-30 19:52:21 -05:00
|
|
|
install(
|
|
|
|
|
DIRECTORY src/main/native/thirdparty/libuv/include/
|
|
|
|
|
DESTINATION "${include_dest}/wpinet"
|
|
|
|
|
)
|
|
|
|
|
target_include_directories(wpinet PRIVATE src/main/native/thirdparty/libuv/src)
|
|
|
|
|
target_include_directories(
|
|
|
|
|
wpinet
|
|
|
|
|
PUBLIC
|
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/libuv/include>
|
|
|
|
|
)
|
2022-05-07 10:54:14 -07:00
|
|
|
if(NOT MSVC)
|
|
|
|
|
target_sources(wpinet PRIVATE ${uv_unix_src})
|
2023-11-30 19:52:21 -05:00
|
|
|
if(APPLE)
|
2022-05-07 10:54:14 -07:00
|
|
|
target_sources(wpinet PRIVATE ${uv_darwin_src})
|
|
|
|
|
else()
|
|
|
|
|
target_sources(wpinet PRIVATE ${uv_linux_src})
|
|
|
|
|
endif()
|
|
|
|
|
target_compile_definitions(wpinet PRIVATE -D_GNU_SOURCE)
|
|
|
|
|
else()
|
|
|
|
|
target_sources(wpinet PRIVATE ${uv_windows_src})
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
|
target_compile_definitions(wpinet PRIVATE -DBUILDING_UV_SHARED)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
2023-07-20 09:30:56 +02:00
|
|
|
find_package(libuv CONFIG REQUIRED)
|
|
|
|
|
target_link_libraries(wpinet PUBLIC $<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv>)
|
2022-05-07 10:54:14 -07:00
|
|
|
endif()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(MSVC)
|
2022-05-07 10:54:14 -07:00
|
|
|
target_sources(wpinet PRIVATE ${wpinet_windows_src})
|
2023-11-30 19:52:21 -05:00
|
|
|
else()
|
2022-05-07 10:54:14 -07:00
|
|
|
target_sources(wpinet PRIVATE ${wpinet_unix_src})
|
2023-11-30 19:52:21 -05:00
|
|
|
if(APPLE)
|
2022-05-07 10:54:14 -07:00
|
|
|
target_sources(wpinet PRIVATE ${wpinet_macos_src})
|
|
|
|
|
else()
|
|
|
|
|
target_sources(wpinet PRIVATE ${wpinet_linux_src})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
install(
|
2024-08-11 02:39:17 -04:00
|
|
|
DIRECTORY src/main/native/include/ src/main/native/thirdparty/tcpsockets/include/
|
2023-11-30 19:52:21 -05:00
|
|
|
DESTINATION "${include_dest}/wpinet"
|
|
|
|
|
)
|
|
|
|
|
target_include_directories(
|
|
|
|
|
wpinet
|
|
|
|
|
PUBLIC
|
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
2024-08-11 02:39:17 -04:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/tcpsockets/include>
|
2023-11-30 19:52:21 -05:00
|
|
|
$<INSTALL_INTERFACE:${include_dest}/wpinet>
|
|
|
|
|
)
|
2022-05-07 10:54:14 -07:00
|
|
|
|
2023-09-18 01:17:32 +02:00
|
|
|
install(TARGETS wpinet EXPORT wpinet)
|
2024-04-10 22:04:22 -07:00
|
|
|
export(TARGETS wpinet FILE wpinet.cmake NAMESPACE wpinet::)
|
2022-05-07 10:54:14 -07:00
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
configure_file(wpinet-config.cmake.in ${WPILIB_BINARY_DIR}/wpinet-config.cmake)
|
2023-11-21 14:48:32 -05:00
|
|
|
install(FILES ${WPILIB_BINARY_DIR}/wpinet-config.cmake DESTINATION share/wpinet)
|
|
|
|
|
install(EXPORT wpinet DESTINATION share/wpinet)
|
2022-05-07 10:54:14 -07:00
|
|
|
|
2023-08-30 21:17:09 -07:00
|
|
|
subdir_list(wpinet_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
2022-05-07 10:54:14 -07:00
|
|
|
foreach(example ${wpinet_examples})
|
|
|
|
|
file(GLOB wpinet_example_src examples/${example}/*.cpp)
|
|
|
|
|
if(wpinet_example_src)
|
|
|
|
|
add_executable(wpinet_${example} ${wpinet_example_src})
|
|
|
|
|
wpilib_target_warnings(wpinet_${example})
|
|
|
|
|
target_link_libraries(wpinet_${example} wpinet)
|
|
|
|
|
set_property(TARGET wpinet_${example} PROPERTY FOLDER "examples")
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2024-11-12 16:39:41 -08:00
|
|
|
if(UNIX AND NOT APPLE AND NOT ANDROID)
|
2023-11-30 19:52:21 -05:00
|
|
|
set(LIBUTIL -lutil)
|
2022-05-07 10:54:14 -07:00
|
|
|
else()
|
2023-11-30 19:52:21 -05:00
|
|
|
set(LIBUTIL)
|
2022-05-07 10:54:14 -07:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
file(GLOB netconsoleServer_src src/netconsoleServer/native/cpp/*.cpp)
|
|
|
|
|
add_executable(netconsoleServer ${netconsoleServer_src})
|
|
|
|
|
wpilib_target_warnings(netconsoleServer)
|
|
|
|
|
target_link_libraries(netconsoleServer wpinet ${LIBUTIL})
|
|
|
|
|
|
|
|
|
|
file(GLOB netconsoleTee_src src/netconsoleTee/native/cpp/*.cpp)
|
|
|
|
|
add_executable(netconsoleTee ${netconsoleTee_src})
|
|
|
|
|
wpilib_target_warnings(netconsoleTee)
|
|
|
|
|
target_link_libraries(netconsoleTee wpinet)
|
|
|
|
|
|
|
|
|
|
set_property(TARGET netconsoleServer PROPERTY FOLDER "examples")
|
|
|
|
|
set_property(TARGET netconsoleTee PROPERTY FOLDER "examples")
|
|
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(WITH_TESTS)
|
2022-05-07 10:54:14 -07:00
|
|
|
wpilib_add_test(wpinet src/test/native/cpp)
|
2023-09-18 19:49:54 -07:00
|
|
|
target_include_directories(wpinet_test PRIVATE src/test/native/include src/main/native/cpp)
|
2024-07-19 00:10:26 -04:00
|
|
|
target_link_libraries(wpinet_test wpinet ${LIBUTIL} googletest wpiutil_testlib)
|
2022-05-07 10:54:14 -07:00
|
|
|
endif()
|