1
votes

I've recently found this amazing new gem called premake and I was all "FINALLY!"

I'm trying to make a simple "Test" configuration, that works like this: when in Test configuration, exclude source/Main.cpp when not in Test configuration, exclude source/Test.cpp (that contains another main)

This is the premake4.lua code that tries to do this

solution "Foo" configurations {"Debug", "Release", "Test"} location "build"

project "Bar"
    targetname "Bar"
    language "C++"
    kind "WindowedApp"
    files {"source/**.h","source/**.cpp","source/**.c"}
    flags {"StaticRuntime","ExtraWarnings", "FatalWarnings"}

    configuration "Test"
        excludes "source/Main.cpp"
        targetsuffix "_Test"
        defines {"DEBUG", "TEST"}
        flags {"Symbols"}

    configuration "not Test"
        excludes "source/Test.cpp"

    -- And so on ...

But when I compile with "make -Cbuild config=test" it will regardless compile and link with "Main.cpp".

What am I doing wrong?

2

2 Answers

1
votes

Premake doesn't support per-configuration file or exclude lists currently, only files specified at the project level (outside of any configuration) are considered when generating the build files.

Per-configuration file lists are on the short list for the next release (4.5).

0
votes

You could do like this instead.

project "Bar"
    targetname "Bar"
    language "C++"
    kind "WindowedApp"
    files {"source/**.h","source/**.cpp","source/**.c"}
    flags {"StaticRuntime","ExtraWarnings", "FatalWarnings"}

    configurations { "Test", "notTest" }

    filter { "configurations:Test" }
        excludes "source/Main.cpp"
        targetsuffix "_Test"
        defines {"DEBUG", "TEST"}
        flags {"Symbols"}
    filter {}

    filter { "configurations:notTest" }
        excludes "source/Test.cpp"
    filter {}