Skip to content

Instantly share code, notes, and snippets.

@masterflitzer
Last active February 17, 2025 00:22
Show Gist options
  • Save masterflitzer/014abf277e117487f86e43056276c9de to your computer and use it in GitHub Desktop.
Save masterflitzer/014abf277e117487f86e43056276c9de to your computer and use it in GitHub Desktop.

compile cheat engine

prerequisites

  • lazarus 2.2.2 (win64 + cross win32): https://sourceforge.net/projects/lazarus (Lazarus Windows 64 bits / Lazarus 2.2.2)
    • win64: lazarus-2.2.2-fpc-3.2.2-win64.exe
    • cross win32: lazarus-2.2.2-fpc-3.2.2-cross-i386-win32-win64.exe
  • visual studio build tools: https://visualstudio.microsoft.com/downloads/
    • workloads:
      • desktop development with c++
        including optional components:
        • msvc
        • windows sdk
      • .net desktop build tools
        including optional components:
        • .net sdk
        • .net framework 4.8.1 sdk
        • .net framework 4.8.1 targeting pack
        • .net framework 4.8 targeting pack
        • .net framework 4.7.2 targeting pack
        • .net framework 4.7.1 targeting pack
        • .net framework 4.7 targeting pack
        • .net framework 4.6.2 targeting pack
        • .net framework 4.6.1 targeting pack
        • .net framework 4.6 targeting pack

compile

mkdir cheat-engine
cd cheat-engine

git clone git@github.com:cheat-engine/cheat-engine.git .
git tag
# switch to tag of version
git switch -d 7.5

# before executing check the variables and adapt them if needed
compile-cheat-engine.ps1
#/usr/bin/env pwsh
#Requires -PSEdition Core
Set-StrictMode -Version Latest
# check where lazarus and visual studio buildtools are installed
$pathLazarus = "C:\lazarus"
$pathLazarusFpc = "C:\lazarus\fpc\3.2.2\bin\x86_64-win64"
$pathVsBuildTools = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools"
# paths to be set
$pathList = @(
"$env:Path",
"$pathLazarus",
"$pathLazarusFpc",
"$pathVsBuildTools\Common7\Tools",
"$pathVsBuildTools\MSBuild\Current\Bin",
"$pathVsBuildTools\VC\Auxiliary\Build"
)
# projects to be compiled
$projectList = @(
"Cheat Engine/cheatengine.lpi",
"Cheat Engine/Direct x mess/Direct x mess.sln",
"Cheat Engine/DotNetCompiler/CSCompiler/CSCompiler.sln",
"Cheat Engine/DotNetDataCollector/DotNetDataCollector.sln",
"Cheat Engine/DotNetInvasiveDataCollector/DotNetInvasiveDataCollector.sln",
"Cheat Engine/luaclient/luaclient.lpi",
"Cheat Engine/MonoDataCollector/MonoDataCollector.sln",
"Cheat Engine/speedhack/speedhack.lpi",
"Cheat Engine/tcclib/win32/tcc/tcc.sln",
"Cheat Engine/VEHDebug/vehdebug.lpi"
)
$env:Path = $pathList | Join-String -Separator ";"
$lazbuildProjectList = $projectList | Where-Object { $_.ToLower().EndsWith(".lpi") }
$msbuildProjectList = $projectList | Where-Object { $_.ToLower().EndsWith(".sln") }
Launch-VsDevShell.ps1
Write-Output "`n# preparation`n"
# platform toolset depending on installed version of msvc
$platformToolset = (
where.exe Microsoft.VCToolsVersion.v*.txt | Sort-Object -Bottom 1 | Split-Path -Leaf | Select-String -Pattern ".*\.(v\d+)\..*"
).Matches.Groups[1].Value
if ($platformToolset.Length -eq 0) {
Write-Output "failed to auto detect platform toolset"
Write-Output "set platform toolset (e.g. v143) manually below and comment out the throw line after"
Write-Output "see: https://learn.microsoft.com/cpp/build/how-to-modify-the-target-framework-and-platform-toolset#platform-toolset"
# $platformToolset = ""
throw "failed to auto detect platform toolset"
}
Write-Output "`n# done`n"
Write-Output "`n# lazarus`n"
foreach ($project in $lazbuildProjectList) {
$buildModeList = @()
if ($project.ToLower().EndsWith("cheatengine.lpi")) {
$buildModeList = @("Release 64-Bit O4 AVX2", "Release 64-Bit", "Release 32-Bit")
}
if ($project.ToLower().EndsWith("luaclient.lpi")) {
$buildModeList = @("Release 64", "Release 32")
}
if ($project.ToLower().EndsWith("speedhack.lpi")) {
$buildModeList = @("64-bit", "32-bit")
}
if ($project.ToLower().EndsWith("vehdebug.lpi")) {
$buildModeList = @("release 64", "release 32")
}
foreach ($buildMode in $buildModeList) {
lazbuild --build-all --build-mode="$buildMode" "$project"
Write-Output ""
}
}
Write-Output "`n# done`n"
Write-Output "`n# msbuild`n"
foreach ($project in $msbuildProjectList) {
# legacy .net framework fix
(Get-ChildItem -Include @("*.csproj", "*.vcxproj") -Path $(Split-Path -Parent $project) -Recurse).FullName | Where-Object {
Select-String -Path $_ -Pattern "<TargetFrameworkVersion>"
} | ForEach-Object {
$content = Get-Content -Path $_ -Raw
$content = [regex]::Replace(
$content,
"<TargetFrameworkVersion>v4.*</TargetFrameworkVersion>",
"<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>"
)
Set-Content -Path $_ -Value $content
}
$buildConfigList = @()
if ($project.ToLower().EndsWith("direct x mess.sln")) {
$buildConfigList = @("Release|x64", "Release|Win32")
}
if ($project.ToLower().EndsWith("cscompiler.sln")) {
$buildConfigList = @("Release|Any CPU")
}
if ($project.ToLower().EndsWith("dotnetdatacollector.sln")) {
$buildConfigList = @("Release|x64", "Release|Win32")
}
if ($project.ToLower().EndsWith("dotnetinvasivedatacollector.sln")) {
$buildConfigList = @("Release|Any CPU")
}
if ($project.ToLower().EndsWith("monodatacollector.sln")) {
$buildConfigList = @("Release|x64", "Release|Win32")
}
if ($project.ToLower().EndsWith("tcc.sln")) {
$buildConfigList = @("Output to 64 (Release)|x64", "Output to 32 (Release)|Win32")
}
foreach ($buildConfig in $buildConfigList) {
$configuration, $platform = $buildConfig.Split("|")
msbuild -restore -p:Configuration="$configuration" -p:Platform="$platform" -p:PlatformToolset="$platformToolset" -p:WindowsTargetPlatformVersion=10.0 "$project"
Write-Output ""
}
}
Write-Output "`n# done`n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment