Skip to content

Allow specifying root directory for the project sources #2129

@vadz

Description

@vadz

For various reasons, I can't have Premake files in the root directory of the project, but have to put it into a subdirectory, let's call it build/premake. This means that even my simplest project definitions look like this:

project "foo"
  kind "StaticLib"
  symbols "On"

  local srcdir = "../../foo/"

  vpaths {
     ["Source Files"] = srcdir .. "**.cpp",
     ["Header Files"] = srcdir .. "**.h",
  }

  includedirs { srcdir .. "include" }

  files {
    srcdir .. "include/foo/bar.h",
    -- a dozen more of them...
    srcdir .. "src/foo/foo.cpp",
    -- and a dozen more of those...
  }

Having to write srcdir .. everywhere is aggravating.

My existing build system allows to do this instead

srcdir ../../foo; // This line makes all the paths relative to this directory.

library foo {
  includedirs = include;

  headers {
    include/foo/foo.h
    ...
  }

  sources {
    src/foo/foo.cpp
    ...
  }

}

and I find this much more convenient.

So I wonder if a similar option could be added to Premake? I'd be willing to implement it, but I'd appreciate any hints about how to do it because I am not sure how to get an option set at the current project level in translate() function which is where, I think, prepending of srcdir should be implemented.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions