diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51d477fd..a4929ffa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -570,3 +570,4 @@ windows: - 69-support-for-epiphan-on-windows-10 - 75-build-against-epiphan-sdk-on-windows-10-for-69 - 78-opencv-free-epiphan-on-windows-10-for-69 + - 84-generate-import-library-on-windows-builds-for-69 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f540ea27..8c16223a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,6 +169,11 @@ endif(USE_NUMPY AND NOT BUILD_PYTHON) # Library name SET(NAME giftgrab) +# For generating import lib in Windows +if(WIN32) + INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") +endif() + # Library include dirs INCLUDE_DIRECTORIES(api) INCLUDE_DIRECTORIES(utils) @@ -187,6 +192,7 @@ SET(HEADERS api/videosourcefactory.h api/videotargetfactory.h api/except.h + api/exports.h ) SET(SOURCES api/iobservable.cpp @@ -347,6 +353,16 @@ if(BUILD_PYTHON) LIST(APPEND INSTALLABLES ${NAME_PYTHON}) endif(BUILD_PYTHON) +# For generating import lib in Windows +if(WIN32) + INCLUDE(GenerateExportHeader) + + GENERATE_EXPORT_HEADER(${NAME} + EXPORT_MACRO_NAME GG_EXPORTS + EXPORT_FILE_NAME gg_exports_win.h + STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC + ) +endif() # Install INSTALL( diff --git a/src/api/except.h b/src/api/except.h index 6ef49f4f..a3594d57 100644 --- a/src/api/except.h +++ b/src/api/except.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include #include @@ -13,7 +14,7 @@ namespace gg { //! \attention In Python: This exception //! maps to \c RuntimeError //! -class BasicException : public std::exception { +class GG_EXPORTS BasicException : public std::exception { protected: //! //! \brief Exception details @@ -47,7 +48,7 @@ class BasicException : public std::exception { //! \attention In Python: This exception //! maps to \c IOError //! -class DeviceAlreadyConnected : public BasicException +class GG_EXPORTS DeviceAlreadyConnected : public BasicException { public: //! @@ -71,7 +72,7 @@ class DeviceAlreadyConnected : public BasicException //! \attention In Python: This exception //! maps to \c IOError //! -class DeviceNotFound : public BasicException { +class GG_EXPORTS DeviceNotFound : public BasicException { public: //! //! \brief @@ -94,7 +95,7 @@ class DeviceNotFound : public BasicException { //! \attention In Python: This exception //! maps to \c IOError //! -class DeviceOffline : public BasicException { +class GG_EXPORTS DeviceOffline : public BasicException { public: //! //! \brief @@ -117,7 +118,7 @@ class DeviceOffline : public BasicException { //! \attention In Python: This exception //! maps to \c RuntimeError //! -class VideoTargetError : public BasicException +class GG_EXPORTS VideoTargetError : public BasicException { public: //! @@ -141,7 +142,7 @@ class VideoTargetError : public BasicException //! \attention In Python: This exception //! maps to \c RuntimeError //! -class VideoSourceError : public BasicException +class GG_EXPORTS VideoSourceError : public BasicException { public: //! @@ -164,7 +165,7 @@ class VideoSourceError : public BasicException //! \attention In Python: This exception //! maps to \c RuntimeError //! -class ObserverError : public BasicException +class GG_EXPORTS ObserverError : public BasicException { public: //! @@ -187,7 +188,7 @@ class ObserverError : public BasicException //! \attention In Python: This exception //! maps to \c IOError //! -class NetworkSourceUnavailable : public BasicException +class GG_EXPORTS NetworkSourceUnavailable : public BasicException { public: //! diff --git a/src/api/exports.h b/src/api/exports.h new file mode 100644 index 00000000..4a562185 --- /dev/null +++ b/src/api/exports.h @@ -0,0 +1,7 @@ +#pragma once + +#ifdef WIN32 +#include "gg_exports_win.h" +#else +#define GG_EXPORTS +#endif diff --git a/src/api/iobservable.h b/src/api/iobservable.h index 020bf96e..358ae5c0 100644 --- a/src/api/iobservable.h +++ b/src/api/iobservable.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "iobserver.h" #include #include @@ -39,7 +40,7 @@ namespace gg //! ensuring data is promptly copied to their own //! data buffer. //! -class IObservable +class GG_EXPORTS IObservable { protected: //! diff --git a/src/api/iobserver.h b/src/api/iobserver.h index 44e796c8..c44e6ed0 100644 --- a/src/api/iobserver.h +++ b/src/api/iobserver.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "videoframe.h" namespace gg @@ -32,7 +33,7 @@ namespace gg //! pass //! \endcode //! -class IObserver +class GG_EXPORTS IObserver { public: //! diff --git a/src/api/ivideosource.h b/src/api/ivideosource.h index bdb44c96..3a47fa3a 100644 --- a/src/api/ivideosource.h +++ b/src/api/ivideosource.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "videoframe.h" #include "except.h" #include "iobservable.h" @@ -12,7 +13,7 @@ //! This enables the underlying algorithms to be agnostic of //! the data sources. //! -class IVideoSource : public gg::IObservable +class GG_EXPORTS IVideoSource : public gg::IObservable { public: //! diff --git a/src/api/ivideotarget.h b/src/api/ivideotarget.h index d56db15d..8d65a115 100644 --- a/src/api/ivideotarget.h +++ b/src/api/ivideotarget.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "videoframe.h" #include "except.h" #include "iobserver.h" @@ -14,7 +15,7 @@ namespace gg //! functionality to save streamed video e.g. //! to files //! -class IVideoTarget : public IObserver +class GG_EXPORTS IVideoTarget : public IObserver { protected: //! diff --git a/src/api/videoframe.h b/src/api/videoframe.h index 35567e9c..52012889 100644 --- a/src/api/videoframe.h +++ b/src/api/videoframe.h @@ -14,6 +14,7 @@ namespace cv #endif #endif // USE_OPENCV +#include "exports.h" #include #include "maskframe.h" #include "except.h" @@ -44,7 +45,7 @@ enum ColourSpace //! within a single frame object, so as to preserve temporal //! relations and to facilitate potential stereo encoding. //! -class VideoFrame +class GG_EXPORTS VideoFrame { protected: //! diff --git a/src/api/videosourcefactory.h b/src/api/videosourcefactory.h index f37f9b3b..94aadd68 100644 --- a/src/api/videosourcefactory.h +++ b/src/api/videosourcefactory.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "ivideosource.h" #include "device.h" #include "codec.h" @@ -22,7 +23,7 @@ namespace gg //! \sa IVideoSource //! \sa Device //! -class VideoSourceFactory +class GG_EXPORTS VideoSourceFactory { protected: //! diff --git a/src/api/videotargetfactory.h b/src/api/videotargetfactory.h index 4703950d..0971c886 100644 --- a/src/api/videotargetfactory.h +++ b/src/api/videotargetfactory.h @@ -1,5 +1,6 @@ #pragma once +#include "exports.h" #include "macros.h" #include "codec.h" #include "ivideotarget.h" @@ -19,7 +20,7 @@ namespace gg //! //! \sa IVideoTarget //! -class VideoTargetFactory +class GG_EXPORTS VideoTargetFactory { protected: //!