premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.22k stars 620 forks source link

Premake and Qt on MacOS #924

Closed rhythmchicago closed 6 years ago

rhythmchicago commented 7 years ago

Hello, everyone.

I've been using Qt and Premake together on Windows for awhile, but I'm having trouble adapting the project to be built on MacOS. I installed the typical open-source installation on MacOS, same as I had on Windows. However, it turns out the header and library directory layout is a bit different on Mac.

Therefore, I've been trying to adapt the Qt premake extension I've been using, but I can't get it to work right, despite following advice I'd seen here and other sites..

Here is what I've done so far:

            if _TARGET_OS == "macosx" then

                local fwname =  module.include .. ".framework"
                local fwheaders = fwname .. "/Headers"
                table.insert(config.links, fwname)
                local fwloc = path.join(qtlib, fwname)
                table.insert(config.includedirs, fwloc)
                table.insert(config.includedirs, path.join(qtlib, fwheaders))
                table.insert(config.linkoptions, "-framework " .. module.include )
                local fwf = "-F " .. qtlib .. "/" .. module.include
                table.insert(config.buildoptions, fwf)

If I run the following:

# premake5 gmake
# make config=debug_macos64

The compiler is able to find header files called from my code. For example:

#include <QPixmap>

But, from within QPixmap (qpixmap.h), the compiler is lost.

../../../../Qt/5.9.2/clang_64/lib/QtGui.framework/Headers/qpixmap.h:43:10: fatal error: 
      'QtGui/qtguiglobal.h' file not found
#include <QtGui/qtguiglobal.h>
         ^~~~~~~~~~~~~~~~~~~~~

The problem is that, unlike on a Windows or Linux machine, there is no QtGui/gtguiglobal.h; the file is actually at $QTDIR/lib/QtGui.framework/Headers/qtguiglobal.h

qmake and cmake are able to make this work, and the structure of Frameworks on MacOS is standardized; I'm assuming there is a solution to this issue. Can anyone tell me the trick I'm missing?

Thanks in advance for any advice.

Tom

samsinsane commented 6 years ago

@rhythmchicago I think you might be better off asking this question over in the premake-qt issue tracker. Having said that, @dcourtois are you able to shed any light on this?

dcourtois commented 6 years ago

Hmm, right now I at work and unable to access a Mac machine, but I can have a look at this when I get back home. I hope my old Mac Book will be able to boot though :D

@rhythmchicago What Premake extension are you using exactly ? If it's https://github.com/dcourtois/premake-qt could you please report this issue there ?

In any case, this doesn't seem to be an issue with Premake.

dcourtois commented 6 years ago

Hi again !

In case it's indeed my addon which is being used, I updated it to support Qt on MacOS (I spent more time trying to update my crappy old Mac Book than working on the actual fix ...)

I could compile and link an application I'm working on, so I hope it can fix your issue. The commit is: https://github.com/dcourtois/premake-qt/commit/735cb810f12e7347f1894bbed32a41ad85709405

And if it is indeed my addon you're using, please, report issues on the addon GitHub page, and when you start working on fixes, take the time to create pull requests: your fixes could benefit to a lot more people than just you :) (and it's a good way to give back to open source projects in general)

rhythmchicago commented 6 years ago

@dcourtois : It is indeed your plugin that I've been using. I posted the issue here because I felt I was having an issue getting premake to do what I wanted; I was trying to configure the compiler and linker. I probably should have just posted in your forum.

I'm at work handling another project right now, but I'll test your fix sometime this weekend, as well as create this issue, as you requested.

Also, I'm back to running a Mac full-time, so if you ever need the plugin tested on that OS, just let me know.

dcourtois commented 6 years ago

Great, thanks :)