Skip to content

Commit 20f8409

Browse files
Merge pull request #5 from Pix4D/port-conan-qt-dependency
Port conan qt dependency
2 parents 467628d + 4497bdb commit 20f8409

File tree

6 files changed

+71
-56
lines changed

6 files changed

+71
-56
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Removed
1515

1616

17+
## QtBasemapPlugin 1.1.0-2
18+
19+
### Changed
20+
- used conan-package for Qt-dependency
21+
- minor changes in recipe build configuration
22+
23+
1724
## QtBasemapPlugin 1.1.0-1
1825

1926
### Added

CMakeLists.txt

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.12)
22
project(QtBasemapPlugin VERSION 1.0.0 LANGUAGES CXX)
33

44
set(LIB_NAME qtgeoservices_basemap_pix4d)
@@ -14,13 +14,7 @@ endif()
1414

1515
find_package(Qt5 COMPONENTS
1616
Core
17-
Gui
18-
OpenGL
19-
Quick
20-
Xml
21-
Positioning
22-
Location
23-
Network
17+
Location
2418
REQUIRED QUIET)
2519

2620
set(SOURCES
@@ -29,7 +23,7 @@ set(SOURCES
2923
src/GeoTileFetcher.cpp
3024
src/GeoMapReply.cpp
3125
src/GeoFileTileCache.cpp
32-
26+
3327
src/GeoServiceProviderPlugin.h
3428
src/GeoTiledMappingManagerEngine.h
3529
src/GeoTileFetcher.h
@@ -42,20 +36,12 @@ set_target_properties(${LIB_NAME} PROPERTIES AUTORCC ON AUTOMOC ON)
4236

4337
target_link_libraries(${LIB_NAME} PRIVATE
4438
Qt5::Core
45-
Qt5::Gui
46-
Qt5::Quick
47-
Qt5::Positioning
48-
Qt5::Xml
4939
Qt5::Location
5040
Qt5::LocationPrivate
51-
Qt5::Network
52-
Qt5::OpenGL
5341
)
5442

5543
target_include_directories(${LIB_NAME} INTERFACE
5644
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
57-
PRIVATE src
58-
${Qt5Location_PRIVATE_INCLUDE_DIRS}
5945
)
6046

6147
target_compile_features(${LIB_NAME} PRIVATE cxx_std_14)

conanfile.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44

55
class QtBasemapPluginConan(ConanFile):
66
name = 'QtBasemapPlugin'
7-
version = '1.1.0-1'
7+
version = '1.1.0-2'
88
license = 'LGPL3'
99
url = 'http://code.qt.io/cgit/qt/qtlocation.git/tree/src/plugins/geoservices/mapbox?h=5.10'
1010
description = 'Qt GeoServices plugin for basemaps including MapBox'
11-
options = {'shared': [True, False]}
12-
default_options = 'shared=True'
1311
settings = 'os', 'compiler', 'build_type', 'arch'
1412
generators = 'cmake'
1513
exports_sources = ['CMakeLists.txt', 'src/*']
1614

1715
def build(self):
1816
cmake = CMake(self, parallel=True)
1917
cmake_args = {
20-
'-DBUILD_SHARED_LIBS=': 'ON' if self.options.shared else 'OFF'
18+
'BUILD_SHARED_LIBS': True
2119
}
2220

2321
if(tools.cross_building(self.settings) and
@@ -26,12 +24,20 @@ def build(self):
2624
# see https://github.com/conan-io/conan/issues/2856#issuecomment-421036768
2725
cmake.definitions["CONAN_LIBCXX"] = ""
2826

29-
cmake.configure(source_dir='..', build_dir='build', defs=cmake_args)
27+
cmake.configure(source_dir='.', defs=cmake_args)
3028
cmake.build(target='install')
3129

30+
def build_requirements(self):
31+
self.build_requires('Qt5/[5.12.7-2]@pix4d/stable')
32+
3233
def configure(self):
3334
del self.settings.compiler.libcxx
3435

36+
def package_id(self):
37+
# Make all options and dependencies (direct and transitive) contribute
38+
# to the package id
39+
self.info.requires.full_package_mode()
40+
3541
def package_info(self):
3642
self.cpp_info.libs = ["qtgeoservices_basemap_pix4d"]
3743
self.cpp_info.includedirs = ['include']

test_package/CMakeLists.txt

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1+
cmake_minimum_required(VERSION 3.12)
12
project(PackageTest CXX)
2-
cmake_minimum_required(VERSION 3.8)
3-
set(CMAKE_CXX_STANDARD 14)
4-
set(CMAKE_STANDARD_REQUIRED ON)
53

64
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7-
conan_basic_setup()
8-
9-
find_package(QtBasemapPlugin)
10-
11-
add_executable(example example.cpp)
12-
get_property(_libFileName TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE)
5+
conan_set_find_paths()
136

14-
if(EXISTS ${_libFileName})
15-
message(STATUS "Plugin generated at: ${_libFileName}")
16-
else()
17-
message(FATAL_ERROR "Plugin not generated at: ${_libFileName}")
18-
endif()
7+
set(CMAKE_CXX_STANDARD 14)
8+
set(CMAKE_STANDARD_REQUIRED ON)
9+
set(CMAKE_CXX_EXTENSIONS OFF)
1910

20-
if (${CMAKE_INSTALL_PREFIX} STREQUAL "")
21-
set(DEPLOY_TARGET ${CMAKE_BINARY_DIR})
22-
else()
23-
set(DEPLOY_TARGET ${CMAKE_INSTALL_PREFIX})
24-
endif()
11+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
12+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
2513

26-
set(DEPLOY_TARGET ${CMAKE_BINARY_DIR})
27-
set(MAP_PLUGIN_DESTINATION ${DEPLOY_TARGET}/Plugins/geoservices)
28-
set(MAP_PLUGIN ${_libFileName})
14+
find_package(Qt5 COMPONENTS
15+
Core
16+
Location
17+
REQUIRED QUIET)
18+
find_package(QtBasemapPlugin REQUIRED QUIET)
2919

20+
add_executable(example example.cpp)
21+
get_property(MAP_PLUGIN TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE)
3022
message(STATUS "Map plugin path ${MAP_PLUGIN}")
3123

24+
set(MAP_PLUGIN_DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/geoservices)
3225
file(MAKE_DIRECTORY ${MAP_PLUGIN_DESTINATION})
3326
file(COPY ${MAP_PLUGIN} DESTINATION ${MAP_PLUGIN_DESTINATION})
3427

35-
28+
target_link_libraries(example PRIVATE
29+
Qt5::Core
30+
Qt5::Location
31+
)
3632
# don't link with it because this is needed only by the Qt runtime to give a full path to the folder containing it
3733
#target_link_libraries(example PRIVATE
3834
# qtgeoservices_basemap_pix4d
3935
#)
40-
36+

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)