dcourtois / premake-qt

Premake module adding support for Qt to actions (Visual Studio, makefiles, etc.)
Do What The F*ck You Want To Public License
45 stars 11 forks source link

Moc files are not generated when build #20

Closed skfzyy closed 2 years ago

skfzyy commented 2 years ago

sorry for disturbing you. I encounter some issues when using premake-qt

there is my premake script:

require("cmake/cmake")
require("QTModules/qt")

local qt=premake.extensions.qt

qt.enable()

solution "testQtGenerate"
    configurations {"Debug","Release"}
    project "TestQt"
        language "C++"
        kind "ConsoleApp"
        cppdialect "c++17"
        files{"*.hpp","*.cpp"}
        location ("./testQt")
        symbols "ON"
        optimize "Off"
        architecture "x86_64"
        qt.enable()
        qtsuffix "d"
        qtmodules { "core", "gui", "widgets", "opengl" }
        qtprefix "Qt5"
        qtgenerateddir("QTMoc")
        optimize "Off"
        staticruntime "off"

and there is my c++ file which needs to generate a moc file:

#include <QtWidgets/qwidget.h>

class TestMoc:public QWidget{
    Q_OBJECT
public:
    TestMoc(QWidget* parent): QWidget(parent){
        this->setGeometry(0,0,200,200);
    }
    ~TestMoc(){};
};

I plan to use the CMake module of premake to generate CMakeLists.txt. when I run "premake5 cmake" , it runs succeeded but next, when I run cmake -B Build, the cmake report does not find QtMoc moc_XXXX.h error.

and I find the QtMoc folder does not have anything(or it means that the moc files are not generated)

I don't know whether I use premake-qt in the wrong way or should I change my premake script?

dcourtois commented 2 years ago

Hi,

This type of error usually happen if the generator doesn't support custom commands. I think that this is a problem coming from this cmake/cmake addon that you seem to be using.

Try to use a custom command in your project, and check if the generated CMake file contains that command. If it doesn't, I suggest to open an issue on the cmake addon page, because I can't do anything. And if it does contain the custom command, it might be some bug in my addon, in which case I will need the link to that cmake addon, in order to reproduce the issue.

Jarod42 commented 2 years ago

premake-cmake has been updated to support custom build.

For info, I'm in the process to add premake-qt in my testing project premake-sample-projects. It currently (partially) works for cmake/codeblocks/codelite/ninja/vs*. (I have quote issues). It doesn't work for gmake2 which seems to work differently to visit files :-/.

dcourtois commented 2 years ago

Hi, thanks for the update, so it indeed was an issue with the cmake addon :) I'm closing this issue then. For the problems with gmake2 action, there's the specific issue (still opened unfortunately, I wish I had more time T_T) and if you have any other issue with other actions, feel free to open issues for those.

Regards, Damien.