Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCons or CMake instead of qmake [closed]

Tags:

cmake

scons

qmake

I need some advice in the following matter:

I have a QT project, which is currently set up to work nicely with qmake. However, due to expansions of the requirements and future directions of the project I need to change the build system of it, since the application will require some changes in the way it will be built.

Right now every source file is compiled into a pretty big executable, this is packaged (manually) and sent to download area. All is fine.

But the direction I am aiming to is to modularize the application in a way that each "feature" will be compiled into a shared library and the user (developer) will be able to choose the components he wants to compile. These "features" are placed in directories in the source tree (for example: query_builder, reverse_engineer, mysql_DB_support, version_managemen directories, etc...) and when the user builds the application he simply tells the build system to compile an application with query builder, and mysql, but no reverse engineer and in this case the build system adds the source files from the specified directory and creates a lib from it.

I also have other requirements such as:

  • windows build, linux build
  • optionally package build (deb, rpm)
  • support for QT and possibly QT5
  • multiple executables (GUI client, CLI client)

After some "market research" I have ended up with CMake and SCons as two possible systems I might use. I have some CMake experience, and some python experience, but no SCons yet.

But I don't know which one is best for my case, this is where I need your help. Could you elaborate which should I use? And if you consider that my requirements are achievable with qmake please let me know that too,

Cheers, f.

like image 296
Ferenc Deak Avatar asked Jan 07 '13 13:01

Ferenc Deak


People also ask

Should I use CMake or Qmake?

Both are build systems, but they're not very similar at all. If your project uses Qt, you're probably best off using qmake. CMake is more generic, and fits pretty much any type of project. Both qmake and CMake generate a Makefile, which is read by make to build the project.

What is CMake and Qmake in Qt?

CMake is an alternative to qmake for automating the generation of build configurations. Setting Up Qbs. Qbs is an all-in-one build tool that generates a build graph from a high-level project description (like qmake or CMake do) and executes the commands in the low-level build graph (like make does).

What is SConscript?

It is Open Source software using Python scripts to create configuration files. SConscript files are the equivalent of the requirements files currently used with CMT, and they define the targets that Scons will create during the build process. (For a more detailed introduction, go to http://scons.org/.)


1 Answers

There is no correct answer to this question, and it usually boils down to personal preferences , kind-of like vi versus emacs (the correct answer is vi, of course :)

You should study the pros and cons of each and evaluate how those fit with your requirements and needs.

I am partial to SCons, mainly because I cant stand the CMake syntax, but that is a personal preference. Here are some pros and cons of each as I see it:

CMake

Pros:

  • Similar to QMake, considering it is a makefile generator
  • CMake is widely used, so there is alot of references and help available
  • Has a GUI (I dont know it myself, based on Calvin1602 comments below)

Cons:

  • CMake has its own, invented syntax, which many feel (myself included) is not intuitive.
  • 2 step build process, first create the Makefiles, then actually perform the compilation
  • Its next to impossible to read the generated Makefiles

SCons

Pros:

  • The syntax is Python, which is widely used and relatively easy to learn. (and Python is cool :)
  • The build process is one step, just execute SCons, and it compiles. No intermediate build files to generate or maintain.
  • In the past SCons was slower than CMake, but since then its much faster, probably as fast or faster than CMake since it doesnt have to generate makefiles.
  • Rich feature set, and many languages supported, whereas CMake is focused towards C/C++
  • Very accurate, implicit dependency system: no need to explicitly list dependent headers, libraries, etc. Explicit dependencies can be specified if needed.
  • An eclipse plugin is available. Eclipse also has plugins available for Python.
  • Has tools created for Qt projects to handle MOC and other related codegen as mentioned here.

Cons:

  • SCons may not be as widely used as CMake, but there is still plenty of support available.
  • Depending on the size of the project, SCons may use alot of memory, since it parses all of the build scripts and builds a dependency tree in memory before actually compiling anything. This does allow however for more accurate dependency checking.
like image 53
Brady Avatar answered Nov 07 '22 02:11

Brady