Using cmake-gui with Qt Creator - cmake

I started trying to convert a project to use CMake so that I could import the project into QtCreator to make use of the QtCreator IDE for this straight C code. This worked pretty nicely as far as giving me auto completions, code diving, etc etc.
I have had a bit of a time getting CMake to build the code as I expected, mostly because it was the first time I have been using it. I recently discovered that there is a cmake-gui that you can point at your source and it will show you the CMake variables and such. What is the proper way to actually use cmake-gui within QtCreator? When I just manually made my CMakelists.txt files within my project, it was enough to get the project in there. Should I just run Cmake-gui using locator and point it to those files? Should I keep the same build directory in cmake-gui that was created from QtCreator? Any tutorial links or guidance apprecaited - didnt find a whole lot googling.

The way I use cmake-gui with QtCreator is this:
Create a build directory and configure it with cmake-gui, like:
cmake/project$ mkdir build
cmake/project$ cd build
cmake/project/build$ cmake-gui ..
Open the CMakeLists.txt file in QtCreator, and set the build path to where you did the configuration:
Let QtCreator run the configuration by clicking "Run CMake", it will use the values you configured with cmake-gui in step 1:
You are done :)
When you need to reconfigure the CMake build, just fire up the command line, navigate to the build directory and re-run cmake-gui.

Related

How can I build liquidfun library with cmake?

I am trying to run SFML-LiquidFun-Water-master open source file (https://github.com/alextrevisan/SFML-LiquidFun-Water) on VS2015, but it had some errors (such as there is no proper library "Box2D", "Liquidfun"), I realized that I have to install liquidfun librabry and bring it to the source code which I want to run. I downloaded liquidfun library from https://github.com/google/liquidfun and Cmake from https://cmake.org/ and followed instructions based on here http://google.github.io/liquidfun/Building/html/md__building_windows.html but It keep saying that there is no such command name Cmake whatever.. What am I supposed to do to run source code thank you!!

Using CMake to generate multiple Code Composer build configurations

My goal is to use a script/CMake to create a "Debug" build configuration and a "Release" build configuration that can be switched between within Code Composer Studio's UI (using the "Build Configuration -> Set Active..." option).
Currently,
A script is ran that runs CMake with desired commands (toolchain, etc). A Code Composer Studio project is generated (as described in CMakeLists.txt)
CCS project is imported into CCS
The problem is this only generates a "Debug" build configuration. Is it possible to add a command to CMakeLists.txt, or to cmake command line, or even ccs command line that allows multiple build configurations to be generated?
The only difference between the two will basically be defining NDEBUG, and possibly changing optimization level.
I had this same question...then realized I am the one who originally asked this ~4 years ago! Anyways, I found a way to do this:
Using Code Composer, create the build configuration(s) as you want them to behave. When done, copy the .cproject file to a cproject.in "template". CMake will use this template to generate an identical .cproject for any future cmake builds. Make sure to replace any hardcoded values (ex: project name) with proper cmake variables.
For me, my CMakeLists.txt called configure_file(path/to/cproject.in ${CMAKE_SOURCE_DIR}/.cproject #ONLY).
Also be sure to delete your CMakeCache and CMakeFiles if they already exist...I believe those were preventing me from seeing the resulting change.

How can I configure CMake generated Eclipse project's Build Command and Project Paths?

Our project uses CMake to configure our code. We use Ninja along with a distributed build system. A number of people on our team use Eclipse CDT. We run CMake with the "Eclipse CDT4 - Ninja" generator and the result is generally pretty good.
The issues is that any time a CMake file is changed and you ask Eclipse to build the code it regenerate the eclipse project file overwriting any manual changes you've made to the project.
For example the default build command that it provides the eclipse project is /usr/bin/ninja when in fact I want to take advantage of our distributed build system and set the build command to /usr/bin/ninja -j16. It would be nice if I could have the project file that CMake generates automatically include this setting change.
The other setting I am most interested in preserving is the C/C++ Project Paths->Source. As a general rule we place our CMake build directory as a sibling to the main project directory i.e. ./project ./build. We want to include some files in the build directory in the Eclipse index to make code completion and other tools work better. The default project doesn't include the build directory in source path and thus it does not get indexed.
Is there some way to remedy these issues?
I found a solution to build command issue.
When you run cmake to generate the eclipse project include the additional argument:-DCMAKE_ECLIPSE_NINJA_ARGUMENTS=-j100. I haven't confirmed but I believe a similar command is required for eclipse make projects -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j100.
Unfortunately this feature is poorly documented and I have not found a solution to my other issue.

How to load cmake script with more than one project with Qt Creator

I have a CMake project, and until now, I was using Visual C++ for developing.
Using CMake-gui to generate a solution for VC++, it generates more than one project in the same solution.
But when the script is loaded in qt-creator, only one project is defined, with all the code and folder tree inside, so I can not compile it (or I don't know how to do it).
How can I load the cmake file to load all the projects?
More info:
The first CMakeList.txt has some common configuration. Then, with 'add_subdirectory' function, I add a project to make a library, and another project to make a sample application to use this library.
You should add multiple projects to the root cmake file with help of "add_subdirectory()". Then in Qt Creator you should open the root cmake file. After that you could choose which project to run in the select a kit for running (3) or debugging (4) application pane (check the link).
It sad that you can't (or I don't know how) build only one project. You have to build all projects are added to the root cmake file and then choose which one of them you want to run.
I use Qt Creator 4.0 .
Here is the offical doc http://qt-project.org/doc/qtcreator-2.8/creator-project-cmake.html
My project have a similar structure, just open the top-most CMakeLists.txt file of the project, and qtcreator will import your project.

cmake suppress finding package and set path manually

I'm currently automating my the installation process for multiple instances of an application. This application uses cmake for building and uses some libraries for which no findModule.cmake files exist. Since I'm could find a good example how to generate a findModule.cmake file for existing libraries for example OpenCascade. When setting up the buildprocess manually one can easily adapt the include and lib path in ccmake. Since I want to automate this I'm looking for a way to do this by passing the options to cmake on the command line. Here is how I try to achieve this for OpenCascade:
cmake -DOCC_FOUND:INTERNAL=TRUE -DOCC_INCLUDE_DIR:PATH=/usr/include/opencascade -DOCC_LIBRARY:FILEPATH=/usr/lib/libTKernel.so -DCMAKE_BUILD_TYPE:STRING=Release ..
Unfortunately this doesn't work. Since the option for building are build-depended, passing a previously configured CMakeCache.txt file is not working.
Thanks for any suggestions to achieve what I'm trying to do.