October 22, 2024
Chicago 12, Melborne City, USA
C#

Using clang and trying to generate a visual studio solution with premake doesn't compile correctly


I have 2 premake files 1 for my renderer, and one for my engine but when I generate a vs2022 solution via the command premake5 vs2022 trying to build said solution hits me with a error

I would like to know why this behavior happens, as building on the command line (with gmake) works perfectly fine, and being able to build in VS would greatly increase the productivity of debugging

Here are the aforementioned solution files

workspace "Wrenderer"
configurations { "Debug", "Release"}
project "Wrenderer"
    language "C"
    targetname "Wrenderer"
    architecture "x64"
    kind "StaticLib"
    outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"

    toolset "clang"
    cdialect "C99"

    targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
    objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
    files { "**.h", "**.c" }
    libdirs { "./libs/" }
    includedirs { "./include/" }
    includedirs { "./include/libs/" }
    includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
    buildoptions { "-Wextra -Wall" }
    links { "vulkan-1", "glfw3" }
    removefiles { "test/**.**" }
    filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"
    filter "configurations:Release"
        optimize "On"

    filter "system:windows"
        links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
        defines { "VK_USE_PLATFORM_WIN32_KHR" }

    filter "system:linux"
        defines { "VK_USE_PLATFORM_XLIB_KHR" }

    filter "action:gmake"
    prebuildcommands {

        "mkdir -p" .. " %{wks.location}/Binaries/",
        "mkdir -p" .. " %{wks.location}/Binaries/Intermediates/",

        "mkdir -p" .. " %{wks.location}/Binaries/" .. outputdir,
        "mkdir -p" .. " %{wks.location}/Binaries/Intermediates/" .. outputdir,
    }
    filter "not action:gmake"
        prebuildcommands {

            "{MKDIR}" .. " %{wks.location}/Binaries/",
            "{MKDIR}" .. " %{wks.location}/Binaries/Intermediates/",

            "{MKDIR}" .. " %{wks.location}/Binaries/" .. outputdir,
            "{MKDIR}" .. " %{wks.location}/Binaries/Intermediates/" .. outputdir,
        }
    project "WrenTest"
        architecture "x64"
        kind "ConsoleApp"  
        language "C"   

        files { "**.h", "test/**.c" }
        outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"

        toolset "clang"
        cdialect "C99"
    
        targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
        objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")

        libdirs { "./libs/" }
        includedirs { "./include/" }
        includedirs { "./include/libs/" }
        includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
        links { "Wrenderer" }
        buildoptions { "-Wextra -Wall" }
        links { "vulkan-1", "glfw3" }

        filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"
        sanitize { "Address", "Fuzzer" }

        filter "configurations:Release"
            optimize "On"

        filter "system:windows"
            links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
            defines { "VK_USE_PLATFORM_WIN32_KHR" }

        filter "system:linux"
            defines { "VK_USE_PLATFORM_XLIB_KHR" }
        filter "action:gmake"
            prebuildcommands {

                "mkdir -p" .. " %{wks.location}/Binaries/",
                "mkdir -p" .. " %{wks.location}/Binaries/Intermediates/",

                "mkdir -p" .. " %{wks.location}/Binaries/" .. outputdir,
                "mkdir -p" .. " %{wks.location}/Binaries/Intermediates/" .. outputdir,
            }
            filter "not action:gmake"
                prebuildcommands {

                    "{MKDIR}" .. " %{wks.location}/Binaries/",
                    "{MKDIR}" .. " %{wks.location}/Binaries/Intermediates/",

                    "{MKDIR}" .. " %{wks.location}/Binaries/" .. outputdir,
                    "{MKDIR}" .. " %{wks.location}/Binaries/Intermediates/" .. outputdir,
                }
newaction {
    trigger     = "clean",
    description = "clean the software",
    execute     = function ()
       print("Cleaning")
       os.rmdir("./Binaries")
       os.remove("./Lib/*.lib")
       os.remove("*.make")
       os.remove("Makefile")
       os.remove("*.vcxproj")
       os.remove("*.vcxproj.filters")
       os.remove("*.vcxproj.user")
       os.remove("*.sln")
       print("done.")
    end
}

and the one for the engine

workspace "Wrenderer"
project "Wrengine"
    language "C"
    targetname "Wrengine"
    architecture "x64"
    outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"
    kind "ConsoleApp"
    toolset "clang"
    cdialect "C99"

    targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
    objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
    files { "include/**.h", "src/**.c" }
    libdirs { "./libs/" }
    includedirs { "./include/" }
    includedirs { "./Wrenderer/include/" }
    includedirs { "./include/libs/" }
    includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
    libdirs { os.getenv("VULKAN_SDK") .. "/Lib" }
    buildoptions { "-Wextra -Wall" }
    links { "vulkan-1", "glfw3" }
    links { "Wrenderer" }

    filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"
        sanitize {"Address"}
    filter "configurations:Release"
        optimize "On"

    filter "system:windows"
        links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
        defines { "VK_USE_PLATFORM_WIN32_KHR" }

    filter "system:linux"
        defines { "VK_USE_PLATFORM_XLIB_KHR" }

    filter "action:gmake"


    prebuildcommands {
        "compileShaders.bat"
    }
include "Wrenderer/premake5.lua"

my file tree looks like so
file tree

from what I’ve been messing around with it sort of looks like its trying to force the msvc c standard on it, which might contribute to the issue, but still evades me



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video