Skip to content

Commit e464d0f

Browse files
Check from the test_package that the plugin can be loaded
1 parent 8d64d52 commit e464d0f

File tree

3 files changed

+42
-15
lines changed

3 files changed

+42
-15
lines changed

test_package/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ set(CMAKE_CXX_STANDARD 14)
44
set(CMAKE_STANDARD_REQUIRED ON)
55

66
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7-
conan_basic_setup()
7+
conan_set_find_paths()
88

9-
find_package(QtBasemapPlugin)
9+
find_package(Qt5 COMPONENTS
10+
Core
11+
Location
12+
REQUIRED QUIET)
13+
find_package(QtBasemapPlugin REQUIRED QUIET)
1014

1115
add_executable(example example.cpp)
1216
get_property(_libFileName TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE)
@@ -24,17 +28,20 @@ else()
2428
endif()
2529

2630
set(DEPLOY_TARGET ${CMAKE_BINARY_DIR})
27-
set(MAP_PLUGIN_DESTINATION ${DEPLOY_TARGET}/Plugins/geoservices)
31+
set(MAP_PLUGIN_DESTINATION ${DEPLOY_TARGET}/plugins/geoservices)
2832
set(MAP_PLUGIN ${_libFileName})
2933

3034
message(STATUS "Map plugin path ${MAP_PLUGIN}")
3135

3236
file(MAKE_DIRECTORY ${MAP_PLUGIN_DESTINATION})
3337
file(COPY ${MAP_PLUGIN} DESTINATION ${MAP_PLUGIN_DESTINATION})
3438

35-
39+
target_link_libraries(example PRIVATE
40+
Qt5::Core
41+
Qt5::Location
42+
)
3643
# don't link with it because this is needed only by the Qt runtime to give a full path to the folder containing it
3744
#target_link_libraries(example PRIVATE
3845
# qtgeoservices_basemap_pix4d
3946
#)
40-
47+

test_package/conanfile.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ class QtBasemapPluginTestConan(ConanFile):
66
generators = 'cmake'
77

88
def build(self):
9-
cmake = CMake(self)
10-
cmake.configure(source_dir=self.conanfile_directory, build_dir='./')
9+
cmake = CMake(self, parallel=True)
10+
cmake.configure(build_dir='./')
1111
cmake.build()
12+
# Note: Not running from the install target to avoid packaging qt properly
1213

13-
def imports(self):
14-
self.copy('*.dll', dst='bin', src='x64/vc15/bin')
15-
self.copy('*.dylib*', dst='lib', src='lib')
16-
self.copy('*.so*', dst='bin', src='lib')
14+
def requirements(self):
15+
self.requires('Qt5/[5.12.7-2]@pix4d/stable')
1716

1817
def test(self):
19-
os.chdir('bin')
20-
self.run('.%sexample' % os.sep)
18+
self.run(os.path.join('bin', 'example'))

test_package/example.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
int main() {
2-
return 0;
1+
#include <QCoreApplication>
2+
#include <QGeoServiceProvider>
3+
4+
#include <iostream>
5+
6+
int main(int argc, char* argv[])
7+
{
8+
QCoreApplication app(argc, argv);
9+
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + "/plugins");
10+
if (!QGeoServiceProvider::availableServiceProviders().contains(QStringLiteral("basemap_pix4d"), Qt::CaseInsensitive))
11+
{
12+
std::cout << "ERROR locating plugin!" << std::endl;
13+
return EXIT_FAILURE;
14+
}
15+
16+
QGeoServiceProvider plugin("basemap_pix4d");
17+
if (plugin.error())
18+
{
19+
std::cout << "ERROR loading plugin!" << std::endl;
20+
return EXIT_FAILURE;
21+
}
22+
23+
std::cout << "Plugin available" << std::endl;
24+
return EXIT_SUCCESS;
325
}

0 commit comments

Comments
 (0)