Skip to content

Commit 8c1beb2

Browse files
committed
Merge branch 'tstenner-xcode'
2 parents 98178aa + b811e2e commit 8c1beb2

File tree

9 files changed

+31
-52
lines changed

9 files changed

+31
-52
lines changed

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,13 @@ matrix:
77
- os: osx
88
osx_image: xcode10.1
99
env: OSXVER=MacOS10.13
10-
- os: osx
11-
osx_image: xcode9.2
12-
env: OSXVER=MacOS10.12
13-
- os: osx
14-
osx_image: xcode8
15-
env: OSXVER=MacOS10.11
1610
before_script:
1711
- brew update
1812
- brew upgrade cmake
1913
script:
20-
- mkdir -p build/install
21-
- cd build
2214
- cmake --version
23-
- cmake -DCMAKE_BUILD_TYPE=Release -DLSL_UNIXFOLDERS=1 ${CMakeArgs} -DLSL_UNITTESTS=1 ../
15+
- cmake -S . -B build ${CMakeArgs} -DLSL_UNITTESTS=1
16+
- cd build
2417
- cmake --build . --config Release --target install
2518
- testing/lsl_test_internal || true
2619
- testing/lsl_test_exported

CMakeLists.txt

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set(LSL_WINVER "0x0601" CACHE STRING
2525
"Windows version (_WIN32_WINNT) to target (defaults to 0x0601 for Windows 7)")
2626

2727
# Add an object library so all files are only compiled once
28-
set(lslobj_sources
28+
add_library(lslobj OBJECT
2929
src/api_config.cpp
3030
src/api_config.h
3131
src/api_types.hpp
@@ -96,7 +96,6 @@ set(lslobj_sources
9696
include/lsl/types.h
9797
include/lsl/xml.h
9898
)
99-
add_library(lslobj OBJECT ${lslobj_sources})
10099

101100
# try to find out which revision is currently checked out
102101
find_package(Git)
@@ -120,11 +119,9 @@ else()
120119
set(lslgitrevision "unknown")
121120
set(lslgitbranch "unknown")
122121
endif()
123-
set(LSL_VERSION_INFO "\"git:${lslgitrevision}/branch:${lslgitbranch}/build:${CMAKE_BUILD_TYPE}/compiler:${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}/boost:\" BOOST_LIB_VERSION")
124-
set_source_files_properties("src/common.cpp" PROPERTIES COMPILE_DEFINITIONS LSL_LIBRARY_INFO_STR=${LSL_VERSION_INFO})
122+
set(LSL_VERSION_INFO "git:${lslgitrevision}/branch:${lslgitbranch}/build:${CMAKE_BUILD_TYPE}/compiler:${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}")
125123
set_source_files_properties("src/loguru/loguru.cpp" PROPERTIES COMPILE_DEFINITIONS LOGURU_STACKTRACES=$<BOOL:${LSL_DEBUGLOG}>)
126124

127-
128125
## create the lslboost target
129126
add_library(lslboost OBJECT
130127
lslboost/asio_objects.cpp
@@ -176,37 +173,24 @@ target_compile_definitions(lslobj
176173
)
177174

178175
# shared library
179-
if (CMAKE_GENERATOR MATCHES "Xcode")
180-
# Xcode is rather annoying in that it doesn't build SHARED libs unless they have source files.
181-
# So we need to build from source, and then add all the other settings missing due to lack of lslobj
182-
add_library(lsl SHARED ${lslobj_sources})
183-
target_link_libraries(lsl PRIVATE lslboost)
184-
else()
185-
add_library(lsl SHARED)
186-
target_link_libraries(lsl
187-
PUBLIC lslobj
188-
PRIVATE lslboost)
189-
endif()
190-
target_include_directories(lsl
191-
PUBLIC
192-
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
193-
$<INSTALL_INTERFACE:include>
194-
)
195-
target_compile_definitions(lsl
196-
PRIVATE LIBLSL_EXPORTS $<$<PLATFORM_ID:Windows>:_CRT_SECURE_NO_WARNINGS>
197-
INTERFACE LSLNOAUTOLINK # don't use #pragma(lib) in CMake builds
198-
)
199-
176+
add_library(lsl SHARED src/buildinfo.cpp)
177+
target_compile_definitions(lsl PRIVATE
178+
LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO}/link:shared"
179+
LIBLSL_EXPORTS)
180+
target_link_libraries(lsl
181+
PUBLIC lslobj
182+
PRIVATE lslboost)
200183
set_target_properties(lsl PROPERTIES
201184
VERSION ${liblsl_VERSION_MAJOR}.${liblsl_VERSION_MINOR}.${liblsl_VERSION_PATCH}
202185
)
203186

204187
set(LSL_EXPORT_TARGETS lsl lslobj lslboost)
205188
if(LSL_BUILD_STATIC)
206-
add_library(lsl-static STATIC)
189+
add_library(lsl-static STATIC src/buildinfo.cpp)
190+
target_compile_definitions(lsl-static PRIVATE LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO}/link:static")
207191
target_link_libraries(lsl-static PUBLIC lslobj PRIVATE lslboost)
208192
# for LSL_CPP_API export header
209-
target_compile_definitions(lsl-static INTERFACE LIBLSL_STATIC)
193+
target_compile_definitions(lsl-static PUBLIC LIBLSL_STATIC)
210194
endif()
211195

212196
if(LSL_FORCE_FANCY_LIBNAME)

include/lsl/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extern LIBLSL_C_API int32_t lsl_library_version();
171171
*
172172
* The format of the string shouldn't be used for anything important except giving a debugging
173173
* person a good idea which exact library version is used. */
174-
extern LIBLSL_C_API const char *lsl_library_info();
174+
extern LIBLSL_C_API const char *lsl_library_info(void);
175175

176176
/**
177177
* Obtain a local system time stamp in seconds.

src/buildinfo.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extern "C" {
2+
#include "../include/lsl/common.h"
3+
4+
LIBLSL_C_API const char *lsl_library_info(void) {
5+
#ifdef LSL_LIBRARY_INFO_STR
6+
return LSL_LIBRARY_INFO_STR;
7+
#else
8+
return "Unknown (not set by build system)";
9+
#endif
10+
}
11+
}

src/common.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ LIBLSL_C_API int32_t lsl_protocol_version() {
2020

2121
LIBLSL_C_API int32_t lsl_library_version() { return LSL_LIBRARY_VERSION; }
2222

23-
LIBLSL_C_API const char *lsl_library_info() {
24-
#ifdef LSL_LIBRARY_INFO_STR
25-
return LSL_LIBRARY_INFO_STR;
26-
#else
27-
return "Unknown (not set by build system)";
28-
#endif
29-
}
30-
3123
LIBLSL_C_API double lsl_local_clock() {
3224
return lslboost::chrono::nanoseconds(
3325
lslboost::chrono::high_resolution_clock::now().time_since_epoch())

src/stream_outlet_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ using namespace lslboost::asio;
1111

1212
stream_outlet_impl::stream_outlet_impl(
1313
const stream_info_impl &info, int chunk_size, int max_capacity)
14-
: chunk_size_(chunk_size), info_(std::make_shared<stream_info_impl>(info)),
15-
sample_factory_(std::make_shared<factory>(info.channel_format(), info.channel_count(),
14+
: sample_factory_(std::make_shared<factory>(info.channel_format(), info.channel_count(),
1615
static_cast<uint32_t>(
1716
info.nominal_srate()
1817
? info.nominal_srate() * api_config::get_instance()->outlet_buffer_reserve_ms() /
1918
1000
2019
: api_config::get_instance()->outlet_buffer_reserve_samples()))),
21-
send_buffer_(std::make_shared<send_buffer>(max_capacity)) {
20+
chunk_size_(chunk_size), info_(std::make_shared<stream_info_impl>(info)),
21+
send_buffer_(std::make_shared<send_buffer>(max_capacity)) {
2222
ensure_lsl_initialized();
2323
const api_config *cfg = api_config::get_instance();
2424

standalone_compilation_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# For development, install a recent CMake version, either via pip
66
# (pip install cmake) or as binary download from cmake.org
77

8-
set -x
8+
set -e -x
99
# Try to read LSLGITREVISION from git if the variable isn't set
1010
echo ${LSLGITREVISION:="$(git describe --tags HEAD)"}
1111
${CXX:-g++} -fPIC -fvisibility=hidden -O2 ${CFLAGS} -Ilslboost \

testing/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ option(LSL_BENCHMARKS "Enable benchmarks in unit tests" OFF)
1111
add_library(catch_main OBJECT catch_main.cpp)
1212
target_compile_features(catch_main PUBLIC cxx_std_11)
1313

14-
target_compile_definitions(catch_main PRIVATE LSL_VERSION_INFO=${LSL_VERSION_INFO})
14+
target_compile_definitions(catch_main PRIVATE LSL_VERSION_INFO="${LSL_VERSION_INFO}")
1515
if(LSL_BENCHMARKS)
1616
target_compile_definitions(catch_main PUBLIC CATCH_CONFIG_ENABLE_BENCHMARKING)
1717
endif()

testing/catch_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ int main(int argc, char *argv[]) {
88
#endif
99
session.configData().runOrder = Catch::RunTests::InRandomOrder;
1010
#ifdef LSL_VERSION_INFO
11-
#define BOOST_LIB_VERSION ""
1211
std::cout << "liblsl version: " << LSL_VERSION_INFO << '\n';
1312
#endif
1413
int returnCode = session.applyCommandLine(argc, argv);

0 commit comments

Comments
 (0)