Build an application using cmake

1929
5
Jump to solution
12-20-2017 05:24 AM
GeorgeArnaut
New Contributor II

Hi ESRI, I have tried to build an ArcGIS qt application with cmake command , I have successfully compiled the project and link it, but after I have received some messages that  my computer couldn't find some ArcGIS qml libraries. How can I fix it? Cmake example and the errors below!

Some code from main.cpp :

QString arcGISRuntimeImportPath;
  QString arcGISToolkitImportPath;

 #if defined(LINUX_PLATFORM_REPLACEMENT)
  // on some linux platforms the string 'linux' is replaced with 1
  // fix the replacement paths which were created
  arcGISRuntimeImportPath = "../For_the_map/qt100.1/sdk/linux/x64/qml";
  arcGISToolkitImportPath = "../For_the_map/qt100.1/sdk/toolkit/Import";
 #endif

  // Add the Runtime and Extras path
  view.engine()->addImportPath(arcGISRuntimeImportPath);
  // Add the Toolkit path
  view.engine()->addImportPath(arcGISToolkitImportPath);

  // Set the source
  view.setSource(QUrl("../For_the_map/Simple_Renderer/Simple_Renderer.qml"));

There are the messages:

file:///home/asus/Desktop/For_the_map/Simple_Renderer/Simple_Renderer.qml:20:1: module "Esri.ArcGISRuntime.Toolkit.Controls" is not installed
     import Esri.ArcGISRuntime.Toolkit.Controls 100.1
     ^
file:///home/asus/Desktop/For_the_map/Simple_Renderer/Simple_Renderer.qml:21:1: module "Esri.ArcGISExtras" is not installed
     import Esri.ArcGISExtras 1.1
     ^
file:///home/asus/Desktop/For_the_map/Simple_Renderer/Simple_Renderer.qml:20:1: module "Esri.ArcGISRuntime.Toolkit.Controls" is not installed
     import Esri.ArcGISRuntime.Toolkit.Controls 100.1
     ^
file:///home/asus/Desktop/For_the_map/Simple_Renderer/Simple_Renderer.qml:21:1: module "Esri.ArcGISExtras" is not installed
     import Esri.ArcGISExtras 1.1

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi George, are you running on linux?

I think that "LINUX_PLATFORM_REPLACEMENT" may not be defined in your project if you are building with cmake. We set this in one of our .pri files which is used by qmake/qtcreator and I am not 100% sure that will be used by your cmake project.

 

It's probably worth adding some print statements so that you can confirm the import paths are correct (e.g. arcGISRuntimeImportPath and arcGISToolkitImportPath).

You can also set the environment variable "QML_IMPORT_TRACE"  (see Import Statements | Qt QML 5.10 ) to try and debug what is going on.  

I hope that helps,

Luke

View solution in original post

0 Kudos
5 Replies
LukeSmallwood
Esri Contributor

Hi George, are you running on linux?

I think that "LINUX_PLATFORM_REPLACEMENT" may not be defined in your project if you are building with cmake. We set this in one of our .pri files which is used by qmake/qtcreator and I am not 100% sure that will be used by your cmake project.

 

It's probably worth adding some print statements so that you can confirm the import paths are correct (e.g. arcGISRuntimeImportPath and arcGISToolkitImportPath).

You can also set the environment variable "QML_IMPORT_TRACE"  (see Import Statements | Qt QML 5.10 ) to try and debug what is going on.  

I hope that helps,

Luke

0 Kudos
GeorgeArnaut
New Contributor II

Thank you, I add this lines to my cmake, I build everything!

0 Kudos
DanielBabatunde
New Contributor

Hi George, could you please kindly share your example cmake file. I'm trying to do something similar using cmake and visual studio code but I can't get it to compile

0 Kudos
by Anonymous User
Not applicable

Hi Daniel, we are now shipping CMake templates with 100.8.

If you need something quick and dirty right now though, this might put you in the right direction:

cmake_minimum_required(VERSION 3.5)

project(example_cmake LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 COMPONENTS REQUIRED Core Quick Multimedia Positioning Sensors Widgets)

set(SOURCE_FILES
main.cpp
Cmake_example.cpp
qml/qml.qrc
Resources/Resources.qrc)

if(ANDROID)
add_library(example_cmake SHARED ${SOURCE_FILES})
else()
add_executable(example_cmake ${SOURCE_FILES})
endif()

target_compile_definitions(example_cmake
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

set(ARCGIS_LOCATION "$ENV{HOME}/arcgis/runtime_sdk/qt100.7/sdk")

add_library(ArcGISRuntime STATIC IMPORTED)
set_property(TARGET ArcGISRuntime PROPERTY IMPORTED_LOCATION
"${ARCGIS_LOCATION}/linux/x64/lib/libEsriRuntimeQt.a")
set_property(TARGET ArcGISRuntime PROPERTY IMPORTED_IMPLIB
"${ARCGIS_LOCATION}/linux/x64/lib/libEsriRuntimeQt.a")
set_property(TARGET ArcGISRuntime PROPERTY INTERFACE_LINK_LIBRARIES
"${ARCGIS_LOCATION}/linux/x64/lib/libruntimecore.so"
"${ARCGIS_LOCATION}/linux/x64/lib/libEsriCommonQt.so")
set_property(TARGET ArcGISRuntime PROPERTY INTERFACE_INCLUDE_DIRECTORIES
"${ARCGIS_LOCATION}/include")
target_compile_definitions(ArcGISRuntime INTERFACE
ARCGIS_RUNTIME_IMPORT_PATH=${ARCGIS_LOCATION}/LINUX_PLATFORM_REPLACEMENT/x64/qml
ARCGIS_TOOLKIT_IMPORT_PATH=${ARCGIS_LOCATION}/toolkit/Import
LINUX_PLATFORM_REPLACEMENT=linux)

target_link_libraries(example_cmake PRIVATE
Qt5::Core
Qt5::Quick
Qt5::Multimedia
Qt5::Positioning
Qt5::Sensors
Qt5::Widgets
ArcGISRuntime)
0 Kudos
DanielBabatunde
New Contributor

Thanks Neil, that was very helpful. 

0 Kudos