Modernize premake5 file.

Removed a lot of duplicated declarations.  Tests no longer links to SDL for no reason, removed a lot of surgical compiler parameters to silence warnings about some questionable code.
This commit is contained in:
Graham Pentheny
2026-02-08 00:46:16 -05:00
parent 87b2419574
commit 89d215d551
4 changed files with 65 additions and 145 deletions

View File

@@ -93,10 +93,10 @@ jobs:
- name: Run premake
working-directory: RecastDemo
run: ./premake5 --cc=clang gmake2
run: ./premake5 --cc=clang gmake
- name: Build
working-directory: RecastDemo/Build/gmake2
working-directory: RecastDemo/Build/gmake
run: make config=${{matrix.conf}} verbose=true
linux-cmake:

View File

@@ -60,10 +60,10 @@ jobs:
- name: Run premake
working-directory: RecastDemo
run: ./premake5 --cc=clang gmake2
run: ./premake5 --cc=clang gmake
- name: Build
working-directory: RecastDemo/Build/gmake2
working-directory: RecastDemo/Build/gmake
run: make config=debug verbose=true
- name: Run Tests

View File

@@ -29,8 +29,8 @@ You can also reference the github actions build script `.github/Build.yaml` for
### Linux
- Install SDL2 and its dependencies according to your distro's guidelines.
- Navigate to the `RecastDemo` folder and run `premake5 gmake2`
- Navigate to `RecastDemo/Build/gmake2` and run `make`
- Navigate to the `RecastDemo` folder and run `premake5 gmake`
- Navigate to `RecastDemo/Build/gmake` and run `make`
- Navigate to `RecastDemo/Bin` and run `./RecastDemo`
## Preprocessor Defines

View File

@@ -1,18 +1,22 @@
--
-- premake5 file to build RecastDemo
-- http://premake.github.io/
--
local action = _ACTION or ""
local todir = "Build/" .. action
local buildDir = "Build/" .. _ACTION or ""
workspace "recastnavigation"
location (buildDir)
startproject "RecastDemo"
configurations {
"Debug",
"Release"
}
location (todir)
architecture "x64"
symbols "On"
exceptionhandling "Off"
rtti "Off"
-- Use fast math operations. This is not required, but it speeds up some calculations
-- at the expense of accuracy. Because there are some functions like dtMathIsfinite
@@ -21,116 +25,60 @@ workspace "recastnavigation"
floatingpoint "Fast"
defines { "RC_FAST_MATH" }
exceptionhandling "Off"
rtti "Off"
symbols "On"
-- debug configs
filter "configurations:Debug"
defines { "DEBUG" }
targetdir ( todir .. "/lib/Debug" )
optimize "Off"
targetdir ( buildDir .. "/lib/Debug" )
-- release configs
filter "configurations:Release"
defines { "RC_DISABLE_ASSERTS" }
optimize "On"
targetdir ( todir .. "/lib/Release" )
optimize "Speed"
targetdir ( buildDir .. "/lib/Release" )
filter "system:windows"
defines {
"WIN32",
"_WINDOWS",
"_HAS_EXCEPTIONS=0"
}
filter "system:not windows"
warnings "Extra"
-- windows specific
filter "system:windows"
platforms { "Win32", "Win64" }
defines { "WIN32", "_WINDOWS", "_CRT_SECURE_NO_WARNINGS", "_HAS_EXCEPTIONS=0" }
-- warnings "Extra" uses /W4 which is too aggressive for us, so use W3 instead.
-- Disable:
-- * C4351: new behavior for array initialization
buildoptions { "/W3", "/wd4351" }
filter "platforms:Win32"
architecture "x32"
filter "platforms:Win64"
architecture "x64"
filter {"system:linux", "toolset:gcc"}
buildoptions {
"-Wno-error=class-memaccess",
"-Wno-error=maybe-uninitialized"
}
project "DebugUtils"
local function libproject(name, dependencies)
project(name)
language "C++"
cppdialect "C++98"
kind "StaticLib"
flags { "FatalCompileWarnings" }
includedirs {
"../DebugUtils/Include",
"../Detour/Include",
"../DetourTileCache/Include",
"../Recast/Include"
}
files {
"../DebugUtils/Include/*.h",
"../DebugUtils/Source/*.cpp"
}
project "Detour"
language "C++"
cppdialect "C++98"
kind "StaticLib"
flags { "FatalCompileWarnings" }
includedirs {
"../Detour/Include"
}
files {
"../Detour/Include/*.h",
"../Detour/Source/*.cpp"
}
warnings "Extra"
fatalwarnings { "All" }
project "DetourCrowd"
language "C++"
cppdialect "C++98"
kind "StaticLib"
flags { "FatalCompileWarnings" }
includedirs {
"../DetourCrowd/Include",
"../Detour/Include",
"../Recast/Include"
}
files {
"../DetourCrowd/Include/*.h",
"../DetourCrowd/Source/*.cpp"
local includes = {
"../" .. name .. "/Include"
}
for _,dependency in ipairs(dependencies) do
table.insert(includes, "../" .. dependency .. "/Include")
end
includedirs(includes)
project "DetourTileCache"
language "C++"
cppdialect "C++98"
kind "StaticLib"
flags { "FatalCompileWarnings" }
includedirs {
"../DetourTileCache/Include",
"../Detour/Include",
"../Recast/Include"
}
files {
"../DetourTileCache/Include/*.h",
"../DetourTileCache/Source/*.cpp"
"../" .. name .. "/Include/*.h",
"../" .. name .. "/Source/*.cpp"
}
end
project "Recast"
language "C++"
cppdialect "C++98"
kind "StaticLib"
flags { "FatalCompileWarnings" }
includedirs {
"../Recast/Include"
}
files {
"../Recast/Include/*.h",
"../Recast/Source/*.cpp"
}
libproject("Recast", {})
libproject("Detour", {})
libproject("DetourCrowd", {"Detour", "Recast"})
libproject("DetourTileCache", {"Detour", "Recast"})
libproject("DebugUtils", {"Detour", "DetourTileCache", "Recast"})
project "Contrib"
language "C++"
@@ -166,6 +114,7 @@ project "RecastDemo"
cppdialect "C++20" -- we don't care about this being compatible in the same way we do with the library code.
kind "WindowedApp"
targetdir "Bin"
debugdir "Bin"
includedirs {
"../RecastDemo/Include",
@@ -181,12 +130,12 @@ project "RecastDemo"
"../RecastDemo/Contrib/implot",
"../RecastDemo/Contrib/imgui/backends",
}
files {
"../RecastDemo/Include/*.h",
"../RecastDemo/Source/*.cpp",
}
-- project dependencies
links {
"DebugUtils",
"Detour",
@@ -196,7 +145,6 @@ project "RecastDemo"
"Contrib"
}
filter "system:linux"
buildoptions {
"`pkg-config --cflags sdl2`",
@@ -211,8 +159,11 @@ project "RecastDemo"
filter "system:windows"
includedirs { "../RecastDemo/Contrib/SDL/include" }
libdirs { "../RecastDemo/Contrib/SDL/lib/%{cfg.architecture:gsub('x86_64', 'x64')}" }
libdirs { "../RecastDemo/Contrib/SDL/lib/x64" }
debugdir "../RecastDemo/Bin/"
defines {
"_CRT_SECURE_NO_WARNINGS",
}
links {
"glu32",
"opengl32",
@@ -221,10 +172,9 @@ project "RecastDemo"
}
postbuildcommands {
-- Copy the SDL2 dll to the Bin folder.
'{COPY} "%{path.getabsolute("Contrib/SDL/lib/" .. cfg.architecture:gsub("x86_64", "x64") .. "/SDL2.dll")}" "%{cfg.targetdir}"'
'{COPY} "%{path.getabsolute("Contrib/SDL/lib/x64/SDL2.dll")}" "%{cfg.targetdir}"'
}
-- mac includes and libs
filter "system:macosx"
kind "ConsoleApp"
includedirs { "Bin/SDL2.framework/Headers" }
@@ -240,7 +190,9 @@ project "Tests"
language "C++"
cppdialect "C++20" -- Catch requires newer C++ features
kind "ConsoleApp"
flags { "FatalCompileWarnings" }
targetdir "Bin"
debugdir "Bin"
fatalwarnings { "All" }
-- Catch requires RTTI and exceptions
exceptionhandling "On"
@@ -258,18 +210,11 @@ project "Tests"
"../Tests/Contrib"
}
files {
"../Tests/*.h",
"../Tests/*.hpp",
"../Tests/*.cpp",
"../Tests/Recast/*.h",
"../Tests/Recast/*.cpp",
"../Tests/Detour/*.h",
"../Tests/Detour/*.cpp",
"../Tests/DetourCrowd/*.cpp",
"../Tests/Contrib/catch2/*.cpp"
"../Tests/**.h",
"../Tests/**.hpp",
"../Tests/**.cpp"
}
-- project dependencies
links {
"DebugUtils",
"DetourCrowd",
@@ -278,9 +223,6 @@ project "Tests"
"Recast",
}
-- distribute executable in RecastDemo/Bin directory
targetdir "Bin"
-- enable ubsan and asan when compiling with clang
filter "toolset:clang"
-- Disable `-Wnan-infinity-disabled` because Catch uses functions like std::isnan() that
@@ -289,36 +231,14 @@ project "Tests"
buildoptions { "-fsanitize=undefined", "-fsanitize=address" } -- , "-fsanitize=memory" }
linkoptions { "-fsanitize=undefined", "-fsanitize=address" } --, "-fsanitize=memory" }
-- linux library cflags and libs
filter "system:linux"
buildoptions {
"`pkg-config --cflags sdl2`",
"`pkg-config --cflags gl`",
"`pkg-config --cflags glu`",
"-Wno-parentheses" -- Disable parentheses warning for the Tests target, as Catch's macros generate this everywhere.
}
linkoptions {
"`pkg-config --libs sdl2`",
"`pkg-config --libs gl`",
"`pkg-config --libs glu`",
"-lpthread"
}
-- windows library cflags and libs
filter "system:windows"
includedirs { "../RecastDemo/Contrib/SDL/include" }
libdirs { "../RecastDemo/Contrib/SDL/lib/%{cfg.architecture:gsub('x86_64', 'x64')}" }
debugdir "../RecastDemo/Bin/"
links {
"glu32",
"opengl32",
"SDL2",
"SDL2main",
}
-- mac includes and libs
filter "system:macosx"
kind "ConsoleApp"
links {
"Cocoa.framework",
}
links { "Cocoa.framework" }