-
-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: What is the 'correct' way to add Frameworks for gmake projects on macos #196
Comments
It probably should be enough to specify: links { "/Library/Frameworks/SDL2.framework" } Premake should be smart enough to split that path up on its own into the appropriate flags. But you are correct that it does not do that currently. |
I can make a pull request for that if you want. |
So just to clarify, I'm not missing some global configuration that makes it so that In other words, is there something I'm missing that would make |
Well the exact same problem occurs when handling regular libraries. We have |
since |
If we introduce a "frameworkdirs", I don't really see why frameworks still need to be in links... I rather either have links and libdirs correctly support frameworks...
and
and not allow .framework files in links. |
As a side note, this stackoverflow question seems to be dealing with the same issue: http://stackoverflow.com/questions/29465141/linking-mac-frameworks-using-premake-and-gnu-make I think, for the sake of backwards compatibility it would make sense to keep frameworks in |
Also, since non-system frameworks are typically located in one of two places ( So effectively the pseudocode for premake's logic when creating a gmake project would be:
That should resolve this problem in most standard cases where the user is not storing the framework in another location, at which point we could still use something like what is being discussed above, regarding |
Keep in mind that Premake is not always run on the same system that will build the project. I frequently output project files for Linux and Mac OS X while running on Windows, and vice versa. |
Ah yes, that does make things more complicated than what I had assumed. I'm not really sure how to best have premake account for that, if at all. If you are distributing a a cross-platform project and want to make sure that mac users that have a given framework (ex. SDL2) in various locations can all run 'make' on the makefiles that premake created with |
I think in that case it would be better to ask your developers to run Premake locally to configure their projects? But for the sake of improving the Makefiles, perhaps we should automatically add |
At the very least I do agree that your suggestion (tvandijck's suggestion) would be a great start. |
Summary
I was wondering what the 'correct' way would be to include non-system *.framework files on macos in Premake5, with the ultimate goal of using gmake with clang or gnu compiler.
My assumptions about compiling with frameworks
Correct me if I'm wrong, but as far as I've been able to find out, when compiling a program with a non-system framework under clang or gcc/g++ you need to:
-framework <FRAMEWORK NAME>
-F <PATH TO FRAMEWORK>
So for example, if I'm compiling a program using SDL2, where SDL2.framework is located at
/Library/Frameworks/
then I would add-framework SDL2 -F /Library/Frameworks
to my compile string.From some experimentation - see snippet: https://gist.github.com/JohannesMP/6ff3463482ebbdc82c2e - I've established that, at least on my machine, step 2. is required and not including it causes the compiler to not be able to find the header file in the framework when compiling the object files, and also results in an error when linking them.
Question regarding Premake5
When using Premake, I've seen some projects only do the following:
But, at least when using gmake, this seems to create a make file that does not include step 2. above, and so I get the same error as I did in my snippet above (lines 15 and 27)
To be able to account for this I've so far done the following:
However that has the problem of not being portable - for example some users don't have their frameworks located in the global frameworks directory and instead have it in their user directory, ie
~/Library/Frameworks
. Furthermore if I try to include both locations, there is a good chance that one of them may not yet exist on a user's machine (they're not created by default) and so they may get an error when running make:So instead of using
buildoptions
andlinkoptions
, is there a better, portable way to include frameworks in Premake5?Alternatively, is there some global configuration that I am missing on my mac that would make it so that I don't need to include the
-F /Path/To/Framework
compile/link flag? It seems that it's not required for system frameworks, at least those located in/System/Library/Frameworks
.For reference, here are the premake5.lua file and the c file for a simple SDL2 'hello window' program that I've been using for testing: https://gist.github.com/JohannesMP/9a9b5263c127103f1861#file-premake5-lua-L24-L26 - The highlighted lines are what my question is about.
The text was updated successfully, but these errors were encountered: