Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 6de215e

Browse files
authored
Replace QPluginLoader with QLibrary, should allow to create statically linked plugins (#68)
1 parent 8c359b1 commit 6de215e

21 files changed

Lines changed: 55 additions & 34 deletions

cmake/functions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ function(add_driver)
3434
set(disabled_drivers ${disabled_drivers} ${add_driver_NAME} CACHE INTERNAL "")
3535
return()
3636
endif()
37+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/driver.json ${CMAKE_CURRENT_BINARY_DIR}/driver_${add_driver_NAME}.json)
3738
add_library(${add_driver_NAME} MODULE ${add_driver_SRCS})
3839
target_link_libraries(${add_driver_NAME} GuLinux_Qt_Commons GuLinux_c++_Commons drivers planetaryimager-commons ${add_driver_LINK} Qt5::Core Qt5::Qml ${OpenCV_LIBS})
40+
41+
set_target_properties(${add_driver_NAME} PROPERTIES PREFIX "driver_")
3942
install(TARGETS ${add_driver_NAME} LIBRARY DESTINATION ${drivers_destination})
43+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${add_driver_NAME}.json DESTINATION ${drivers_destination})
4044
set(enabled_drivers ${enabled_drivers} ${add_driver_NAME} CACHE INTERNAL "")
4145
endfunction()

src/drivers/driver.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ class Driver : public QObject {
3838
virtual Cameras cameras() const = 0;
3939
};
4040
typedef QList<Driver::ptr> Drivers;
41-
#define DRIVER_IID "net.gulinux.planetaryimager.driver"
42-
Q_DECLARE_INTERFACE(Driver, DRIVER_IID)
43-
#define DECLARE_DRIVER_PLUGIN \
44-
Q_INTERFACES(Driver) \
45-
Q_PLUGIN_METADATA(IID DRIVER_IID FILE "driver.json")
41+
typedef Driver *(*LoadDriverFunction)();
42+
43+
#ifdef Q_OS_WIN
44+
#define EXPORT_DECL __declspec(dllexport)
45+
#else
46+
#define EXPORT_DECL
47+
#endif
48+
49+
#define PLANETARY_IMAGER_DRIVER_LOAD_F "PlanetaryImager_loadDriver"
50+
#define DECLARE_DRIVER_PLUGIN_INIT(DriverClass) extern "C" EXPORT_DECL Driver *PlanetaryImager_loadDriver() { return new DriverClass(); }
4651

4752
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "FlyCapture2",
33
"description": "FLIR/Point Grey native API",
4-
"version": "0.8"
4+
"version": "${FULL_VERSION}"
55
}

src/drivers/flycapture2/fc2_driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ FC2Driver::FC2Driver(): dptr()
108108
FC2Driver::~FC2Driver()
109109
{
110110
}
111+
112+
DECLARE_DRIVER_PLUGIN_INIT(FC2Driver)

src/drivers/flycapture2/fc2_driver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class FC2Driver: public Driver
2828

2929
public:
3030

31-
DECLARE_DRIVER_PLUGIN
32-
3331
FC2Driver();
3432

3533
~FC2Driver();

src/drivers/iidc/driver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "IIDC",
33
"description": "Instrumentation & Industrial Digital Camera, a standard for camera control over FireWire and USB",
4-
"version": "0.8"
4+
"version": "${FULL_VERSION}"
55
}

src/drivers/iidc/iidc_driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,6 @@ IIDCDriver::IIDCDriver(): dptr()
138138
}
139139

140140
IIDCDriver::~IIDCDriver() { }
141+
142+
143+
DECLARE_DRIVER_PLUGIN_INIT(IIDCDriver)

src/drivers/iidc/iidc_driver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class IIDCDriver: public Driver
2828

2929
public:
3030

31-
DECLARE_DRIVER_PLUGIN
32-
3331
IIDCDriver();
3432

3533
~IIDCDriver();

src/drivers/qhy/driver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "QHY",
33
"description": "QHYCCD Cameras driver",
4-
"version": "0.7"
4+
"version": "${FULL_VERSION}"
55
}

src/drivers/qhy/qhydriver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ Driver::Cameras QHYDriver::cameras() const
8282
return cameras;
8383
}
8484

85+
DECLARE_DRIVER_PLUGIN_INIT(QHYDriver)

0 commit comments

Comments
 (0)