// ImGui - DLL
//------------------------------------------------------------------------------
{
    .ProjectName        = 'ImGui'
    .ProjectPath        = 'External/imgui'

    // Unity
    //--------------------------------------------------------------------------
    Unity( '$ProjectName$-Unity' )
    {
        .UnityInputFiles            = {
            '$ProjectPath$/imgui.cpp',
            '$ProjectPath$/imgui_demo.cpp',
            '$ProjectPath$/imgui_draw.cpp',
            '$ProjectPath$/imgui_tables.cpp',
            '$ProjectPath$/imgui_widgets.cpp',
            '$ProjectPath$/backends/imgui_impl_win32.cpp',
            '$ProjectPath$/backends/imgui_impl_dx12.cpp'
        }
        .UnityOutputPath            = 'Intermediate/$ProjectPath$/'
        .UnityOutputPattern         = '$ProjectName$_Unity*.cpp'
        .UnityMaxFiles              = 1
    }

    // Library
    //--------------------------------------------------------------------------
    ForEach( .BuildConfig in .BuildConfigs )
    {
        Using( .BuildConfig )
        .OutputBase + '\$Platform$-$BuildConfigName$'

        // ObjectList (no Unity for external code)
        //--------------------------------------------------------------------------
        ObjectList( '$ProjectName$-Objs-$Platform$-$BuildConfigName$' )
        {
            // Input (Unity)
            .CompilerInputUnity         = '$ProjectName$-Unity'

            // Extra Compiler Options
            .CompilerOptions            + ' "-I$ProjectPath$"'
                                        + ' "-I$ProjectPath$/backends"'
            .CompilerOptions            + ' -DIMGUI_API=__declspec(dllexport)'
                                        + ' /wd4365'  // signed/unsigned mismatch
                                        + ' /wd5219'  // implicit conversion to float
                                        + ' -WX-'     // disable warnings as errors for external code

            // Output
            .CompilerOutputPath         = '$OutputBase$/$ProjectName$/'
        }

        // --- DLL BUILD ---
        DLL( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' )
        {
            .Libraries      = { '$ProjectName$-Objs-$Platform$-$BuildConfigName$' }

            .LinkerOutput   = '$BinPath$/$Platform$-$BuildConfigName$/$ProjectName$.dll'

            #if __WINDOWS__
                .LinkerOptions          + ' /DLL'
                .LinkerOptions          + .CommonWinLibs

                .CRTLibs = .CRTLibs_Dynamic
                If ( .BuildConfigName == 'Debug' )
                {
                    ^CRTLibs = .CRTLibs_DynamicDebug
                }
                .LinkerOptions          + .CRTLibs
            #endif
        }

        Alias( '$ProjectName$-$Platform$-$BuildConfigName$' ) { .Targets = '$ProjectName$-Lib-$Platform$-$BuildConfigName$' }
        ^'Targets_$Platform$_$BuildConfigName$' + { '$ProjectName$-$Platform$-$BuildConfigName$' }

        #if __WINDOWS__
            .ProjectConfig              = [ Using( .'Project_$Platform$_$BuildConfigName$' ) .Target = '$ProjectName$-$Platform$-$BuildConfigName$' ]
            ^ProjectConfigs             + .ProjectConfig
        #endif
    }

    VCXProject( '$ProjectName$' )
    {
        .ProjectOutput              = 'External/$ProjectName$.vcxproj'
        .ProjectBasePath            = '$ProjectPath$/'
        .ProjectInputPaths          = .ProjectBasePath
        .ProjectConfigs             = .ProjectConfigs
    }
}
