1

I have imported CMake-based project into Ubuntu IDE. It uses plain C++ with no QML components. When I try to run it, it does not deploy to device, but runs on desktop (unsuccessfully, reporting it can't find armhf ld library), even though I selected armhf SDK and in Kits tab, my device is selected for current kit, and tooltip in lower-left corner shows that app is going to be installed on device.

When I open Run tab in Project settings, my CMake-based project differs from QMake-based projects in that it has "Command Line Arguments" and "Current Working Directory" fields, but do not "Override app if installed" and "Uninstall app after debugging" (I don't remember exact text now). From this, I conclude that Ubuntu IDE sees my app not as Ubuntu Touch targeted, but as Desktop-targeted. What marks a CMake-based project as Ubuntu Touch targeted fomr IDE?

Is it even possible to run CMake-based project without QML on device? SDK does not have template for this use-case: all CMake-based templates use QML, and the only plain C++ project (QtQuick App) uses QMake.

I have no such problems with QMake-based projects, and presently I use CMake to build a library instead of executable, and then link it into executable with dummy QMake project. But it seems like a kludge.

  • Even QWidgets run on the phone, so it's not related to the QML. Is CMake packaging it correctly into a click-package? You can look at the programs on the launchpad.net: terminal-app is built with CMake. There is a need for an option -DCLICK_MODE=on and a support for that in CMakeLists.txt. I had a minimal example somewhere: askubuntu.com/a/614300/391744 – Velkan Mar 30 '16 at 9:21
  • I copied CMakeLists.txt from your example, modified it a little to make it work with my test, and got the same bad results. When I try to run my project, Ubuntu IDE asks me to connect my device, and, after I done that, I get an error saying Debugging starts Selected architecture arm is not compatible with reported target architecture i386:x86-64 Architecture rejected target-supplied description Debugging has finished Which seems to mean it - again - tries to run armhf code on i386 platform, meaning desktop. – MaxEd Mar 30 '16 at 19:36
0

Ok, so if you are using the desktop Kit and cmake complains about that it cannot find armhf tools, you probably did not have cmake installed on the desktop in the first place (there is a problem with dependencies that we are trying to solve atm) and QtCreator is using a cmake installation from one of the click chroots you have created for device support.

So what to do:

  • Close Ubuntu SDK IDE
  • Install cmake "apt install cmake"
  • Start Ubuntu SDK IDE
  • go to: Options -> Build & Run and click the CMake tab
  • make sure /usr/bin/cmake is selected as the default
  • Open the Kits tab, there select your Desktop Kit and make sure that /usr/bin/cmake is used as the cmake tool.
  • Delete the buildfolders for your projects and build again

There is no need to change the Kits for the devices since these are automatically checked on each start.

If you want to package your own cmake project you need to make sure that it is packaged correctly for the phone. Your best bet is to check out one of the original ubuntu SDK templates to see how it is done.

  • No, it's not a problem with dependencies. The problem is, IDE creates arm-targeted package (just like I want it to), and then tries to run it on desktop for whatever reasons (failing, of course). I'm NOT using Desktop Kit - the selected kit for this project is "UbuntuSDK for armhf" and "Deploy" string says "Deploy to Ubuntu device". – MaxEd Mar 30 '16 at 19:40
  • Please check if there are more than one runconfigurations for you to select from. You can select runconfigurations by pressing on the symbol on the left right over the green rectangle. – zbenjamin Mar 31 '16 at 20:35
  • In my test project, I do indeed have two run configurations! One is named "cmake_test" and the other is "cmake_test2". The first one runs on desktop, and the second one on device. The first, however, gives no indication it's going to run on desktop - when I select it, the text above still says "Deploy: deploy to Ubuntu device". Visually, there is no difference between two. In my other CMake project, there is only one configuration, which runs on desktop (but also gives no indication of that). What exactly triggers creation of the second run target in CMakeLists.txt? – MaxEd Apr 1 '16 at 7:35
  • Reading CMakeLists.txt.user brought me a new insight: for "good" configuration, I have key "ProjectExplorer.ProjectConfiguration.Id" equals UbuntuProjectManager.RemoteRunConfiguration.AppName and for "bad" one, I get CMakeProjectManager.CMakeRunConfiguration.AppName. So, Ubuntu IDE creates a completely wrong, non-Ubuntu run configuration for my project! However, deploy configuration have UbuntuProjectManager.DeployConfiguration value. It seems like a bug in Ubuntu QtCreator plugin, or a very badly documented feature. I think I will file a bug, reading source code for plugin not helping. – MaxEd Apr 2 '16 at 10:51
0

OK, after a lot of experiments, I found what I did wrong.

So, to make Ubuntu IDE create a configuration that runs your CMake-based project on device, all you need is to have UBUNTU_MANIFEST_FILE variable to be set in your CMakeLists.txt, AND it needs explicitly to be marked CACHE INTERNAL. It's kind of obvious when you know how Ubuntu QtCreator plug-in works, but otherwise, not so much.

So, just add

set(UBUNTU_MANIFEST_PATH "manifest.json" CACHE INTERNAL "Path to manifest file")

to your CMakeLists.txt and you're NEARLY good.

However, I also encountered a problem that this won't work if I specify "${CMAKE_SOURCE_DIR}/manifest.json" as UBUNTU_MANIFEST_PATH, even though the file is exactly there.

The bad part, is that Ubuntu IDE still will create TWO run configurations for project. The first one, the default one, which has name based on your executable target's name, will still try to run armhf code on desktop. I think it's a bug.

The second one has name that depends on what you written in "hooks" section of your .desktop file. If that name equals with executable name, then that configuration will have "2" added to it (i.e. cmake_test2). This second configuration is the one to use - it runs project on device, but you have to choose it in "Run" section of "Projects" page - by default, the wrong run configuration is selected.

All in all, it seems like CMake support in Ubuntu IDE is still kinda fragile/buggy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.