Cross-compiling Qtquick GUI application through command line - cmake

I am Developing a GUI using QT framework; QT-Creator for front-end development and building the app. I am cross-compiling the code that will be running on RaspberryPi and host machine Ubuntu20.04. I am able to build the application through QT-Creator but I want to compile the code through terminal i.e. write CMakeLists.txt that will detect the cross-compiler and build the source-code. Because I need to integrate my GUI code into my other source-code and have to compile from Source-code makefile.
Can anyone help me in this?
Once I have created a screen and compiled through command line. I have tried to compile from terminal through command:
cmake .
to configure the cmake into the current directory. But I am getting error into this
cmake --build . --target clean
(to clean the directory and remove the object files), and
cmake --build . --target all
(to build the executable into the current directory)
Ideally, this should run and binary file should be generated into the current directory that will be running on target board after copying to the board.

Related

How to undo Qt6 Build?

I'm trying to build Qt6 from Sources that i downloaded with Open Source Installer.
Starting from "C:\Qt\6.2.3\Src" folder I opened Command Prompt and entered:
configure.bat -static
Configured successfully. then i builded with :
cmake --build . --parallel
Then it crashed for no enough space. but I cant find builded Sources to delete them. and undo building.

Compiling Dipha on Ubuntu with CMAKE

I have been trying to compile an application called Dipha. The advice from their instructions is to build the application with the CCMAKE command, you can press the letter c to configure the build. Then from the g Key to generate the build files. However, the g option isn't available so I can't build the app.
Am I missing some configuration?
https://github.com/DIPHA/dipha
Managed to get around this by just using cmake command.
Created a new directory to build the application, one level up outside of the main Dipha repo
cd into build directory
ran cmake ../dipha to generate build files
then make to compile everything.
Moved binaries into bin

cmake doesn't add the jsoncpp generated files to the bin

I used https://github.com/open-source-parsers/jsoncpp and downloaded cmake, python, scons. Followed everything that was in build guide and cmake doesn't put what is generated in the bin directory, anyone have an idea?
Using windows 7 if that helps
The instructions are very Linux-centric. I'm guessing if you're on Windows you might be using Visual Studio, in which case the following should work (I didn't use SCONS or Python):
git clone git#github.com:open-source-parsers/jsoncpp.git
mkdir build
cd build
cmake -G"Visual Studio 12 2013 Win64" ..\jsoncpp
cmake --build . --config Debug
cmake --build . --config Release
Line 4 is specifying VS 2013 as the generator targeting a 64-bit build. To create a 32-bit build, simply omit the Win64. To see all available generators, just run cmake with no args.
Once line 4 has completed, you should have a VS solution called "jsoncpp.sln" in the root of your build folder. You can either open this and build from VS, or just use CMake to invoke the compiler by running lines 5 & 6.
Building the project also causes the tests to run, some of which fail. This makes it appear that the build has failed, but in fact you should have the test exes in the bin folder (e.g. build\bin\Debug\jsoncpp_test.exe) and the library in the lib folder (e.g. build\lib\Release\jsoncpp.lib).
I'm not sure how significant the test failures are - I'd be worried if I were you :-)

CMake: How to build projects in a cross-platform manner?

I'm trying to build a project in a cross-platform manner.
I'm using CMake to generate project files on the fly, but it's not clear how to then compile those project files in a cross-platform way. I found try_compile but it's not clear whether this will do what I want. Any ideas?
For example, say I am using Visual Studio 2010 against project foo. I am expecting CMake to generate foo.sln, and then build it (generate the binaries). I know how to automate the first part, but how do I automate the second?
From the CMake docs:
"CMake is a cross-platform build system generator."
So in other words, once CMake has generated the project files, it's work is really done.
You can invoke the native build tool via CMake using the --build flag, e.g.
cmake --build . --config Release --target install -- /M:4
See here for further info.

eclipse indexer problem with cmake project

I've created the eclipse project with cmake. I use vtk with qt. Dir structure is as follows:
parent_dir:
source - source.h, source.cpp
build - this is where the .project resides
I've fired up the eclipse with workspace dir /path/parent .
I have followed the instructions described in
http://www.cmake.org/Wiki/Eclipse_CDT4_Generator .
Everything builds fine, but navigation is not working. That is, the eclipse gives me the warning that the source.h is not indexed yet.
Furthermore, autocompletion doesn't work with qt and vtk related classes. I had checked with Project|Properties, where the qt and vtk includes are included. What am I doing wrong? I would really like to have autocompletion nd navigation in eclipse working with my project. I'm using eclipse ganymede on ubuntu 8.04 64-bit.
thx in advance
According to the Wiki, you should have your build tree outside the source tree.
This linked resource isn't created if
the build directory is a subdirectory
of the source directory because
Eclipse doesn't allow to load projects
which have linked resources pointing
to a parent directory. So we recommend
to create your build directories not
as children, but as siblings to the
source directory.
You'll need to do something like this:
mkdir /home/user/parent_dir_build
cd /home/user/parent_dir_build
cmake /home/user/parent_dir
This took me quite a while to figure out.
You should make sure that the "Build" directory is really NOT part of the project directory, which means, the most high-level directory that contains the "CMakeLists.txt".
So in my case, I have "dir/tree/project_dir" and "dir/tree/project_dir/src", then I should create the build directories "dir/tree/build_dir".
Then, I created a small script that creates both Debug and Release projects:
#!/bin/sh
mkdir -p $1_build/Release
mkdir -p $1_build/Debug
cmake -E chdir $1_build/Release cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../../$1
cmake -E chdir $1_build/Debug cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../$1
Call the script from "dir/tree" with argument "project_dir".
Then, in Eclipse, click "File" --> "Import" --> "General" --> "Existing Projects into Workspace".
Specify the directory "dir/tree/$1_build", it will automatically recognize both projects.
Now, both Release and Debug projects are loaded into Eclipse, and you have all nice options like Code Assiste (code completion), and quick debugging by double-clicking on errors.
Note that you can add some file-filters in Eclipse to remove the CMake files from the project tree.