Replies: 4 comments 6 replies
-
It sounds like what you describing is what the uses/usage proposals have been aiming for. |
Beta Was this translation helpful? Give feedback.
-
Completely agree that this is something that should be aimed for in 6.x. I'm not sure how I feel about having a separate list of include directories for exported, as it's a place where users (or implementers) could easily mess up having to make sure the paths are the same. I do think having the public/private inline is something worth striving for. Don't be afraid to break APIs, as this is a new major revision. |
Beta Was this translation helpful? Give feedback.
-
Definitely not afraid to break APIs, but just more concerned about the ergonomics of it. However I think if we allow folks to continue to specify project('MyLib', function()
files { 'src/mylib.c' }
-- For shared libraries, links should link the libraries as normal with
-- nothing bubbling up to the project referencing the library.
--
-- For static libraries, links should bubble up to the project referencing
-- the library. This lets static libs specify their dependencies even though
-- they can't directly link themselves.
links {
'opengl32',
}
-- libDirs should follow the same shared vs static convention as links so
-- that projects referencing static libraries can automatically have the
-- right libDirs configured for the necessary links.
libDirs { }
-- includeDirs is now a table of tables where each one specifies the
-- "visibility" of the include directory.
--
-- public include dirs are automatically referenced by projects that
-- reference this one.
--
-- Private include dirs are only referenced by this library
--
-- Maybe for simplicity of folks writing apps (where public/private doesn't
-- make sense) we allow additional paths separately. These would implicitly
-- be private.
includeDirs {
public = {
'include',
},
private = {
'private/include1',
'private/include2',
},
'private/include3',
}
end)
project('MyApp', function()
-- Continue to use links for linking projects but now it automatically
-- handles the links, libDirs, and includeDirs from the referenced project.
links { 'MyLib' }
-- Auto-generate build commands to copy shared libraries to the output
-- directory of MyApp. This allows us to build each project to separate
-- output directories while ensuring MyApp has the DLLs/dylibs required to
-- run.
copyRuntimeDependencies 'On'
end) We'd need to think about what other properties need to either be inherited or bubble up, or other ways in which things need to be wired up for successful project references. Some things that immediately jump to mind as maybe things to think about are:
|
Beta Was this translation helpful? Give feedback.
-
I've opened up #1927 with what I have so far to try and get some feedback on the general approach. It's a basic working prototype and there's likely a bit of cleanup left to do, but the rough idea is there and it is working for pulling include dirs up to projects that reference other projects. Also, I noticed 6.x doesn't have Happy to discuss further here or in the PR itself. |
Beta Was this translation helpful? Give feedback.
-
I've been off using CMake for a while and I miss Premake for my project because frankly I find the CMake syntax a little too awkward. However there are a few features I've used in CMake that I'd like to see if we could support in 6.x and it's really down to having better relationships for projects.
So in CMake when you add include directories you can specify them to be public like this:
Which not only adds the directory to
mylib
's include paths, but then if another target linksmylib
it also gets that include directory automatically. This is a huge time saver for incorporating third party libraries since I can simplyadd_subdirectory
to include their CMakeLists.txt and then add the library to my target's links and all the include directories are set up.In Premake land we'd have to think about how one would specify such a thing. I don't really like the way CMake mixes the include directories with a "scope" like public/private but it also is nice because there isn't a second list of include directories to maintain. For me personally I'd probably lean towards a separate function so a library project might have:
Naming not the point but the project is now in control of specifying all the include directories that a project referencing it would need.
The other piece I really like, which is only available on Windows, is the ability to copy all the DLLs referenced by my target to the output directory:
This syntax is really ugly IMO but functionally it's really great. Again I just add projects to my targets links and if they produce a DLL it'll get copied for me. I don't have to do anything manual to get all the DLLs I need in my output directory.
In this case it feels like something that still needs an API but is a little easier since Premake knows if something is a shared library or not and therefore could easily wire up a copy step. Could be as easy as
copyLinkedSharedLibsToOutput 'on'
(not a great function name but you get the idea anyway).Curious if anyone more core to the project has done thinking around this type of thing. Is there any interest in this kind of project relationship? Is there a reason why adding this isn't a good idea?
Beta Was this translation helpful? Give feedback.
All reactions