Some of Qt classes require that QApplication must be constructed first. So, I wrote some code for calling singleton constructor in an appropriate place. Here is a "pure" C++ code for this.
#include <functional>
#include <iostream>
#include <list>
#define INITIALIZABLE(NAME)                        \
private:                                            \
    template <typename T>                           \
    friend struct Initializer;                      \
    inline static NAME* m_instance = nullptr;       \
    static void create() { m_instance = new NAME; } \
    inline static Initializer<NAME> m_initializer{};
struct InitQueue {
    static std::list<std::function<void(void)>>& getList()
    {
        static std::list<std::function<void(void)>> s_list;
        return s_list;
    }
};
template <class T>
struct Initializer {
    Initializer()
    {
        auto initializer = []() {
            T::create();
        };
        InitQueue::getList().push_back(initializer);
    }
};
void initialize()
{
    for (auto func : InitQueue::getList()) {
        func();
    }
}
class Foo {
    INITIALIZABLE(Foo)
public:
    Foo()
    {
        m_count++;
        std::cout << "Ctor was called: " << m_count << "\n";
    }
private:
    static inline int m_count = 0;
};
int main(int, char**)
{
    initialize();
    return 0;
}
It worked as I expected. BUT then I make a Foo Inherited from QObject, somehow ctor of Foo is calling twice.
Foo.cpp
#include "Foo.hpp"
Foo::Foo(QObject* parent)
    : QObject(parent)
{
    m_count++;
    std::cout << "Ctor was called: " << m_count << "\n";
}
std::list<std::function<void(void)>>& InitQueue::getList()
{
    static std::list<std::function<void(void)>> s_list;
    return s_list;
}
void initialize()
{
    for (auto func : InitQueue::getList()) {
        func();
    }
}
Foo.hpp
#pragma once
#include <functional>
#include <iostream>
#include <list>
#include <qobject.h>
#define INITIALIZABLE(NAME)                        \
private:                                            \
    template <typename T>                           \
    friend struct Initializer;                      \
    inline static NAME* m_instance = nullptr;       \
    static void create() { m_instance = new NAME; } \
    inline static Initializer<NAME> m_initializer{};
struct InitQueue {
    static std::list<std::function<void(void)>>& getList();
};
template <class T>
struct Initializer {
    Initializer()
    {
        auto initializer = []() {
            T::create();
        };
        InitQueue::getList().push_back(initializer);
    }
};
void initialize();
class Foo : public QObject {
    INITIALIZABLE(Foo)
public:
    Foo(QObject* parent = nullptr);
private:
    static inline int m_count = 0;
};
main.cpp
#include "Foo.hpp"
int main(int, char**)
{
    initialize();
    std::cin.get();
    return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(DoubleCtorCall)
set(CMAKE_CXX_STANDARD 17)
#Qt specific
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
#Qt
find_package(Qt5Core CONFIG REQUIRED)
set(SOURCES 
    Main.cpp Foo.cpp Foo.hpp) 
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} Qt5::Core) 
So. I have two questions: Why does this happened and how to avoid it (except once flags)?
Windows 10. MSVC 2017. Qt 5.12. 
 
    