From d6dca0dd3af293e27ab828d58ed47b5378fce184 Mon Sep 17 00:00:00 2001 From: "DISGUISE-LONDON\\nathan.butt" Date: Thu, 18 Jun 2026 10:50:29 +0100 Subject: [PATCH] Added support for multiplatform shared lib symbol export/import. --- CMakeLists.txt | 1 + include/opentrackio-cpp/OpenTrackIOProperties.h | 14 ++++++++++++-- include/opentrackio-cpp/OpenTrackIOSample.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15c164c..f706bb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ endif() target_sources(${PROJECT_NAME} PRIVATE ${source_list}) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) +add_compile_definitions(OPENTRACKIO_BUILD) # Handle debug vs release builds and their separate libs diff --git a/include/opentrackio-cpp/OpenTrackIOProperties.h b/include/opentrackio-cpp/OpenTrackIOProperties.h index 42bbafc..c66d858 100644 --- a/include/opentrackio-cpp/OpenTrackIOProperties.h +++ b/include/opentrackio-cpp/OpenTrackIOProperties.h @@ -23,6 +23,16 @@ #define OPEN_TRACK_IO_PROTOCOL_MINOR_VERSION 0 #define OPEN_TRACK_IO_PROTOCOL_PATCH 1 +#ifdef _MSC_VER + #ifdef OPENTRACKIO_BUILD + #define EXPORT __declspec(dllexport) + #else + #define EXPORT __declspec(dllimport) + #endif +#else // Support for GCC and Clang. + #define EXPORT __attribute__((visibility("default"))) +#endif + namespace opentrackio::opentrackioproperties { /** Duration of the clip. @@ -305,8 +315,8 @@ namespace opentrackio::opentrackioproperties struct SourceNumber { /** - * Number that identifies the index of the stream from a source from which data is being transported. - * This is most important in the case where a source is producing multiple streams of samples. */ + * Number that identifies the index of the stream from a source from which data is being transported. + * This is most important in the case where a source is producing multiple streams of samples. */ uint32_t value; static std::optional parse(nlohmann::json& json, std::vector& errors); diff --git a/include/opentrackio-cpp/OpenTrackIOSample.h b/include/opentrackio-cpp/OpenTrackIOSample.h index efa4fab..cb6f76f 100644 --- a/include/opentrackio-cpp/OpenTrackIOSample.h +++ b/include/opentrackio-cpp/OpenTrackIOSample.h @@ -19,7 +19,7 @@ namespace opentrackio { - struct OpenTrackIOSample + struct EXPORT OpenTrackIOSample { std::optional camera = std::nullopt; std::optional duration = std::nullopt;