<< March 2020 | Home | May 2020 >>

building qt-creator from source

Since qt-creator(4.11/4.12) integrated support for cmake's source_groups, headers and sources are split in two separate folders. 'Header-Files','Source-Files' which is a bit annoying (not so annoying as the initial lack of subfolders...). Because of that I downgraded a couple of time ago back to 4.10 till today one qt-creator issue-tracker topic was active again, what triggered me to dive in again.

To make it short, I decided to have a look if I can somehow merge both folders into one. For that I needed to be able to compile qt-creator from source-code. Which actually worked like a charme. Here the steps(hope I can recall all):

My setup: ubuntu mate/bionic

Obviously nothing is older than not maintained build instructions. These steps are valid for qt-creator 4.12 git-hash(91536ae7812e904334b0007445a64aecf3e120ad / 2020/04/23 )

  1. install qt5.12:
sudo add-apt-repository ppa:beineri/opt-qt-5.12.0-bionic
sudo apt-get update
sudo apt-get install qt512-meta-full

In order for some environment-variables to be set you have to call:

source /opt/qt512/bin/qt512-env.sh
  1. install llvm/clang-8 ( Important for c++17 features to work... )
sudo apt-get install llvm-8
sudo apt-get install libclang-8-dev
# not sure if clang-tools are needed:
sudo apt-get install clang-8 clang-tools-8
export LLVM_INSTALL_DIR=/usr/lib/llvm-8

  1. download source from git
git clone --recursive https://code.qt.io/qt-creator/qt-creator.git

# create a build-folder
mkdir qt-creator-build
cd qt-creator-build
qmake -r ../qt-creator
make -j8
  1. finished! The result is in qt-creator-build/bin

btw, in order to merge "Source-Files" and "Header-Files" you only need to alter: src/plugins/cmakeprojectmanager/fileapidataextractor.cpp (lines at about 421, I copy the whole method, but I added only the marked lines):

FolderNode *createSourceGroupNode(const QString &sourceGroupName,
                                  const FilePath &sourceDirectory,
                                  FolderNode *targetRoot)
    FolderNode *currentNode = targetRoot;

    if (!sourceGroupName.isEmpty()) { // new
        QString _srcgrpName = (sourceGroupName=="Header Files" || sourceGroupName=="Source Files") // new
                                ? "Source" // new
                                : sourceGroupName; // new

        const QStringList parts = _srcgrpName.split("\\"); // modified

        for (const QString &p : parts) {
            FolderNode *existingNode = Utils::findOrDefault(currentNode->folderNodes(),
                                                            [&p](const FolderNode *fn) {
                                                                return fn->displayName() == p;

            if (!existingNode) {
                auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
                node->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));

                existingNode = node.get();


            currentNode = existingNode;
    return currentNode;

Hope that helps. (As always, this blog is mainly a reminder for myself. :D )

cmake,emscripten and c++17

Trying to compile my c++17 based project (using entt) makes problems with using my urho3d-docker-web-image that uses emscripten for compilation to web.

emcc (Emscripten gcc/clang-like replacement) 1.39.8 ((unknown revision))

Using (I'm mainly using gcc for compilation, android uses clang afaik?)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)

leads to an error like that:

CMake Error at CMakeLists.txt:95 (target_compile_features):
  target_compile_features no known features for CXX compiler


  version 1.39.8.

I tried a couple of approaches, but the only one that worked for me was a 'brutal' add_definitions(..)

add_definitions(-std=c++1z -std=gnu++1z)

I didn't dig too deep into the problem...but for now it works... ;)

text(X)text or 'textX - lightweight xtext alternative for python'

Just stumpled over textX an xText inspired python-toolbox for creating DSLs. Super simple to use. I love xText but it can be really a pain in the ass here an there. Mainly because you (at least me) always forget about the internal concept and/or structure. Especially how to wire what and how to get the dependency injection working.... :D

I actually wanted to give the xText Theia-Workflow a go but instead stumpled over textX. It is a super lightweight DSL generator and AST-Parser and seems to have an addon to create Visual Studio Code addons via Language Server Protocol. Didn't tried that, yet.

A grammar would look like this (very similiar to xText):

  Entity DSL grammar.

    types*=SimpleType       // At the beginning of model we can define
                            // zero or more simple types.
    entities+=Entity        // Each model has one or more entities.

    'entity' name=ID '{'
        properties+=Property // Each entity has one or more properties.

    name=ID ':' type=[Type]     // type is a reference to Type instance.
                                // There are two built-in simple types 
                                // registered on meta-model in entity_test.py

// Type can be SimpleType or Entity
    SimpleType | Entity

    'type' name=ID

// Special rule for comments. Comments start with //

A sample Model using this grammar:

entity Person {
  name : string       // A comment is everything after // to the end of line
  address: Address    // It is defined by the Comment rule in the grammar
  age: integer        // integer and string are built-in objects
}                     // See entity_test.py

entity Address {
  street : string
  city : string
  country : string

And to let it work. This couple of lines including custom type (SimpleType),predefined data, obviously parsing and and simple generation:

from os import mkdir
from os.path import exists, dirname, join
from textx import metamodel_from_file

this_folder = dirname(__file__)

class SimpleType(object):
    def __init__(self, parent, name):
        self.parent = parent
        self.name = name

    def __str__(self):
        return self.name

def get_entity_mm():
    Builds and returns a meta-model for Entity language.
    type_builtins = {
            'integer': SimpleType(None, 'integer'),
            'string': SimpleType(None, 'string')
    entity_mm = metamodel_from_file(join(this_folder, 'entity.tx'),

    return entity_mm

def main(debug=False):

    # Instantiate the Entity meta-model
    entity_mm = get_entity_mm()

    def javatype(s):
        Maps type names from SimpleType to Java.
        return {
                'integer': 'int',
                'string': 'String'
        }.get(s.name, s.name)

    # Create the output folder
    srcgen_folder = join(this_folder, 'srcgen')
    if not exists(srcgen_folder):

    # Build a Person model from person.ent file
    person_model = entity_mm.model_from_file(join(this_folder, 'person.ent'))

    # Generate Java code
    for entity in person_model.entities:
        # For each entity generate java file
        with open(join(srcgen_folder,
                      "%s.java" % entity.name.capitalize()), 'w') as f:
            f.write("%s.java" % entity.name)

if __name__ == "__main__":

Would have to port my own templating engine, but I guess with python that would be super easy. Definitely interesting...

More examples: https://github.com/textX/textX/tree/master/examples
Documentation: http://textx.github.io/textX/stable/

git: get short hash of remote repo

Atm I'm maintaining my urho3d-minimal-new-project to use the latest version of urho3d in its docker-images. To make this a smoother 'one-click' process I want the new docker-images to have an additional flag like 'githash-$HASH' where the $HASH is the current short-version of the urho3d's git-HEAD. Based on this stackoverflow post:

git ls-remote  https://github.com/urho3d/Urho3D.git HEAD | awk '{ print substr($1,1,10) }'

This will get the first 10 chars of the long-hash. That should be enough. Be aware that the uniqueness of the short-hash depends on the size of the project. Here some hint this git doc:

Generally, eight to ten characters are more than enough to be unique within a project. For example, as of February 2019, the Linux kernel (which is a fairly sizable project) has over 875,000 commits and almost seven million objects in its object database, with no two objects whose SHA-1s are identical in the first 12 characters.

Tags : ,

<< March 2020 | Home | May 2020 >>