Skip to content

Commit 3fbd8a4

Browse files
committed
Merge branch 'master' into dev-speedy
2 parents 4ad3896 + 9f0667b commit 3fbd8a4

File tree

107 files changed

+1241
-4725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1241
-4725
lines changed

.appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ environment:
1212
build_script:
1313
- cmd: cmake -Dlslgitrevision=%APPVEYOR_REPO_COMMIT% -Dlslgitbranch=%APPVEYOR_REPO_BRANCH% -S . -B build -T v140,host=x86 -A %LSLARCH%
1414
- sh: cmake -Dlslgitrevision=${APPVEYOR_REPO_COMMIT} -Dlslgitbranch=${APPVEYOR_REPO_BRANCH} -S . -B build
15-
- cmake -DLSL_UNITTESTS=1 build
15+
- cmake -DLSL_UNITTESTS=ON -DLSL_BUILD_EXAMPLES=ON build
1616
- cmd: cmake --build build --config Release -j --target package
1717
- sh: /usr/bin/time -v cmake --build build -j 3 --target package
1818
- sh: cmake -DCPACK_DEBIAN_PACKAGE_SHLIBDEPS=ON build
1919
- cd build
2020
- sh: sudo dpkg -i *.deb
2121
- sh: cpack -G DEB
22+
- sh: ifconfig
2223
- cmd: testing\Release\lsl_test_internal.exe --wait-for-keypress never
2324
- cmd: set PATH=Release;%PATH% && testing\Release\lsl_test_exported.exe --wait-for-keypress never
2425
- sh: testing/lsl_test_internal --wait-for-keypress never

.github/workflows/cppcmake.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
cmake --version
3131
cmake -E make_directory build
3232
cd build
33-
cmake -DLSL_UNITTESTS=1 -DCPACK_PACKAGE_DIRECTORY=${PWD}/package ..
33+
cmake -DLSL_UNITTESTS=ON -DLSL_BUILD_EXAMPLES=ON -DCPACK_PACKAGE_DIRECTORY=${PWD}/package ..
3434
- name: make
3535
run: cmake --build build --config Release -j --target install
3636
- name: package
@@ -61,8 +61,22 @@ jobs:
6161
with:
6262
name: pkg-${{ matrix.os }}
6363
path: build/package
64+
- name: print network config
65+
shell: bash
66+
run: |
67+
which ifconfig && ifconfig
68+
if [ which ip ]; then
69+
ip link
70+
ip addr
71+
ip route
72+
ip -6 route
73+
fi
6474
- name: unit tests (internal functions)
6575
run: build/install/bin/lsl_test_internal --order rand --wait-for-keypress never --durations yes
76+
timeout-minutes: 5
77+
continue-on-error: true
6678
- name: unit tests (exported functions)
6779
shell: bash
68-
run: build/install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes || [ "${{ matrix.os }}" = "macOS-latest" ]
80+
run: build/install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes
81+
timeout-minutes: 5
82+
continue-on-error: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
/.vs/
88
.DS_Store
99
/out/
10+
# CLion
11+
.idea/
12+
/cmake-build-*/

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ before_script:
1212
- brew upgrade cmake
1313
script:
1414
- cmake --version
15-
- cmake -S . -B build ${CMakeArgs} -DLSL_UNITTESTS=1
15+
- cmake -S . -B build ${CMakeArgs} -DLSL_UNITTESTS=ON -DLSL_EXAMPLES=ON
1616
- cd build
17-
- cmake --build . --config Release --target install
17+
- cmake --build . --config Release -j --target install
1818
- testing/lsl_test_internal || true
1919
- testing/lsl_test_exported
2020
- cpack

CMakeLists.txt

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ add_library(lslobj OBJECT
5454
src/lsl_outlet_c.cpp
5555
src/lsl_streaminfo_c.cpp
5656
src/lsl_xml_element_c.cpp
57+
src/netinterfaces.h
58+
src/netinterfaces.cpp
5759
src/portable_archive/portable_archive_exception.hpp
5860
src/portable_archive/portable_archive_includes.hpp
5961
src/portable_archive/portable_iarchive.hpp
@@ -129,30 +131,32 @@ add_library(lslboost OBJECT
129131
lslboost/libs/chrono/src/chrono.cpp
130132
lslboost/serialization_objects.cpp
131133
)
132-
if (UNIX)
133-
target_sources(lslboost PRIVATE
134-
lslboost/libs/thread/src/pthread/once.cpp
135-
lslboost/libs/thread/src/pthread/thread.cpp
136-
)
137-
find_package(Threads REQUIRED)
138-
target_link_libraries(lslboost PUBLIC Threads::Threads)
139-
target_compile_features(lslboost PUBLIC cxx_std_11 cxx_lambda_init_captures)
140-
else () # WIN32
141-
target_sources(lslboost PRIVATE
142-
lslboost/libs/thread/src/win32/thread.cpp
143-
lslboost/libs/thread/src/win32/tss_dll.cpp
144-
lslboost/libs/thread/src/win32/tss_pe.cpp
145-
)
146-
target_link_libraries(lslboost PRIVATE
147-
bcrypt
148-
$<$<BOOL:${MINGW}>:wsock32 ws2_32 winmm>
134+
135+
if(UNIX)
136+
include(CheckSymbolExists)
137+
# look for clock_gettime, if not we need to link against librt
138+
check_symbol_exists(clock_gettime time.h HAS_GETTIME)
139+
if(NOT HAS_GETTIME)
140+
set(NEEDS_LIBRT ON CACHE INTERNAL "Link to librt")
141+
endif()
142+
endif()
143+
144+
find_package(Threads REQUIRED)
145+
target_link_libraries(lslboost
146+
PUBLIC
147+
Threads::Threads
148+
PRIVATE
149+
$<$<PLATFORM_ID:Windows>:bcrypt>
150+
$<$<PLATFORM_ID:Windows>:iphlpapi>
149151
)
150-
endif ()
152+
target_compile_features(lslboost PUBLIC cxx_std_11 cxx_lambda_init_captures)
151153

152154
target_compile_definitions(lslboost
153155
PUBLIC
154156
BOOST_ALL_NO_LIB
157+
BOOST_ASIO_STANDALONE
155158
BOOST_ASIO_SEPARATE_COMPILATION
159+
BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
156160
$<$<PLATFORM_ID:Windows>:_WIN32_WINNT=${LSL_WINVER}>
157161
PRIVATE
158162
$<$<PLATFORM_ID:Windows>:BOOST_THREAD_BUILD_DLL>
@@ -166,6 +170,7 @@ target_link_libraries(lslobj
166170
lslboost
167171
PUBLIC
168172
$<$<AND:$<BOOL:${LSL_DEBUGLOG}>,$<PLATFORM_ID:Linux>>:dl>
173+
$<$<BOOL:${NEEDS_LIBRT}>:rt>
169174
)
170175
target_include_directories(lslobj
171176
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
@@ -193,17 +198,25 @@ if(LSL_BUILD_STATIC)
193198
add_library(lsl-static STATIC src/buildinfo.cpp)
194199
target_compile_definitions(lsl-static PRIVATE LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO}/link:static")
195200
target_link_libraries(lsl-static PUBLIC lslobj PRIVATE lslboost)
201+
list(APPEND LSL_EXPORT_TARGETS lsl-static)
196202
# for LSL_CPP_API export header
197203
target_compile_definitions(lsl-static PUBLIC LIBLSL_STATIC)
198204
endif()
199205

200206
if(LSL_FORCE_FANCY_LIBNAME)
201-
set(CMAKE_DEBUG_POSTFIX "-debug")
202207
math(EXPR lslplatform "8 * ${CMAKE_SIZEOF_VOID_P}")
203208
set_target_properties(lsl PROPERTIES
204209
PREFIX ""
205210
OUTPUT_NAME "liblsl${lslplatform}"
211+
DEBUG_POSTFIX "-debug"
212+
)
213+
if(LSL_BUILD_STATIC)
214+
set_target_properties(lsl-static PROPERTIES
215+
PREFIX ""
216+
OUTPUT_NAME "liblsl${lslplatform}-static"
217+
DEBUG_POSTFIX "-debug"
206218
)
219+
endif()
207220
endif()
208221

209222
if(LSL_UNIXFOLDERS)

cmake/LSLCMake.cmake

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
macro(LSLAPP_Setup_Boilerplate)
77
endmacro()
88

9-
message(STATUS "Included LSL CMake helpers, rev. 12, ${CMAKE_CURRENT_LIST_DIR}")
9+
message(STATUS "Included LSL CMake helpers, rev. 13, ${CMAKE_CURRENT_LIST_DIR}")
1010
option(LSL_DEPLOYAPPLIBS "Copy library dependencies (at the moment Qt + liblsl) to the installation dir" ON)
1111

12-
# set build type and default install dir if not done already
12+
# set build type and default install dir if not done already or undesired
1313
if(NOT CMAKE_BUILD_TYPE)
1414
message(STATUS "CMAKE_BUILD_TYPE was default initialized to Release")
1515
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
1616
endif()
17-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
18-
# OR ((${MSVC_VERSION} GREATER_EQUAL 1910) AND ("${CMAKE_GENERATOR}" STREQUAL "Ninja"))
17+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT LSL_PRESERVE_INSTALL_PREFIX)
1918
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH
2019
"Where to put redistributable binaries" FORCE)
21-
message(WARNING "CMAKE_INSTALL_PREFIX default initialized to ${CMAKE_INSTALL_PREFIX}")
20+
message(WARNING "CMAKE_INSTALL_PREFIX default initialized to ${CMAKE_INSTALL_PREFIX}. Set LSL_PRESERVE_INSTALL_PREFIX or CMAKE_INSTALL_PREFIX to skip this.")
2221
endif()
2322

2423
# Generate folders for IDE targets (e.g., VisualStudio solutions)
@@ -72,13 +71,18 @@ function(installLSLApp target)
7271
endif()
7372

7473
# Set runtime path, i.e. where shared libs are searched relative to the exe
75-
set(LIBDIRGENEXPR "../$<IF:$<BOOL:${LSL_UNIXFOLDERS}>,lib/,LSL/lib/>")
74+
# CMake>=3.16: set(LIBDIR "../$<IF:$<BOOL:${LSL_UNIXFOLDERS}>,lib/,LSL/lib/>")
75+
if(LSL_UNIXFOLDERS)
76+
set(LIBDIR "../lib")
77+
else()
78+
set(LIBDIR "../LSL/lib")
79+
endif()
7680
if(APPLE)
7781
set_property(TARGET ${target} APPEND
78-
PROPERTY INSTALL_RPATH "@executable_path/;@executable_path/${LIBDIRGENEXPR}")
82+
PROPERTY INSTALL_RPATH "@executable_path/;@executable_path/${LIBDIR}")
7983
elseif(UNIX)
8084
set_property(TARGET ${target}
81-
PROPERTY INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${LIBDIRGENEXPR}")
85+
PROPERTY INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${LIBDIR}")
8286
endif()
8387

8488
if(LSL_UNIXFOLDERS)
@@ -173,8 +177,12 @@ function(installLSLApp target)
173177
findQtInstallationTool("windeployqt")
174178
install(CODE "
175179
message (STATUS \"Running windeployqt on $<TARGET_FILE:${target}>\")
180+
set(qml_dir $<TARGET_PROPERTY:${target},qml_directory>)
181+
message(STATUS \"qml directory: \${qml_dir}\")
176182
execute_process(
177-
COMMAND \"${QT_DEPLOYQT_EXECUTABLE}\" --no-translations
183+
COMMAND \"${QT_DEPLOYQT_EXECUTABLE}\"
184+
\$<\$<BOOL:\${qml_dir}>:--qmldir \${qml_dir}>
185+
--no-translations
178186
--no-system-d3d-compiler --no-opengl-sw
179187
--no-compiler-runtime --dry-run --list mapping
180188
\"$<TARGET_FILE:${target}>\"

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ INPUT = ../src \
1414
../include
1515
FILE_PATTERNS = *.c \
1616
*.cpp \
17-
*.h
17+
*.h *.hpp
1818
EXCLUDE_SYMBOLS = lslboost
1919
SOURCE_BROWSER = YES
2020
CLANG_ASSISTED_PARSING = NO

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.5)
2-
project(Examples
2+
project(lslexamples
33
LANGUAGES C CXX
44
VERSION 0.2.0)
55
find_package(LSL REQUIRED

examples/GetAllStreams.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
#include <algorithm>
2+
#include <chrono>
13
#include <iostream>
24
#include <lsl_cpp.h>
5+
#include <map>
6+
#include <thread>
37

48
/**
59
* This example program shows how all streams that are currently present on the lab network can be
@@ -13,17 +17,41 @@ int main(int argc, char* argv[]) {
1317
// discover all streams on the network
1418
std::vector<lsl::stream_info> results = lsl::resolve_streams();
1519

20+
std::map<std::string, lsl::stream_info> found_streams;
1621
// display them
17-
for (auto& stream: results) std::cout << stream.as_xml() << "\n\n";
22+
for (auto &stream : results) {
23+
found_streams.emplace(std::make_pair(stream.uid(), stream));
24+
std::cout << stream.as_xml() << "\n\n";
25+
}
1826

1927
std::cout << "Press any key to switch to the continuous resolver test: " << std::endl;
2028
std::cin.get();
2129

2230
lsl::continuous_resolver r;
2331
while (true) {
24-
std::vector<lsl::stream_info> tmp = r.results();
25-
for (auto& val : tmp) std::cout << val.name() << " ";
26-
std::cout << std::endl;
32+
auto results = r.results();
33+
for (auto &stream : results) {
34+
auto uid = stream.uid();
35+
if (found_streams.find(uid) == found_streams.end()) {
36+
found_streams.emplace(std::make_pair(uid, stream));
37+
std::cout << "Found " << stream.name() << '@' << stream.hostname() << std::endl;
38+
}
39+
}
40+
auto n_missing = found_streams.size() - results.size();
41+
if (n_missing) {
42+
std::vector<std::string> missing;
43+
missing.reserve(n_missing);
44+
for (const auto &pair : found_streams)
45+
if (std::none_of(results.begin(), results.end(),
46+
[uid = pair.first](
47+
const lsl::stream_info &info) { return info.uid() == uid; })) {
48+
missing.push_back(pair.first);
49+
std::cout << "Lost " << pair.second.name() << '@' << pair.second.hostname()
50+
<< std::endl;
51+
}
52+
for (const auto &uid : missing) found_streams.erase(uid);
53+
}
54+
std::this_thread::sleep_for(std::chrono::seconds(1));
2755
}
2856

2957
} catch (std::exception& e) { std::cerr << "Got an exception: " << e.what() << std::endl; }

examples/SendStringMarkers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ int main(int argc, char* argv[]) {
2525
std::random_device rd;
2626
std::mt19937 gen(rd());
2727
std::uniform_int_distribution<std::size_t> rnd(0, markertypes.size() - 1);
28+
std::uniform_int_distribution<int> delayrnd(0, 1000);
2829
while(true) {
2930
// wait for a 20ms
30-
std::this_thread::sleep_for(std::chrono::milliseconds(20));
31+
std::this_thread::sleep_for(std::chrono::milliseconds(delayrnd(gen)));
3132
// and choose the marker to send
3233
std::string mrk = markertypes[rnd(gen)];
3334
std::cout << "now sending: " << mrk << std::endl;

0 commit comments

Comments
 (0)