$projectsForLinux = @( "executable_path", "MandelZoom", "now", "PlaySound", "StartSuspended", "wxNotepad", "yekneb" ) $cCompilerForLinux = "/usr/bin/gcc" $cxxCompilerForLinux = "/usr/bin/g++" $cmakeGeneratorForLinux = "Unix Makefiles" $cmakePathForLinux = "/usr/bin/cmake" $targetTripletForLinux = "x64-linux" $toolChainFileForLinux = "${env:HOME}/vcpkg/scripts/buildsystems/vcpkg.cmake" $projectsForWindows = @( "Clock", "cmdLauncher", "DigClock", "executable_path", "GetStartTime", "Implementing-An-Accessibility-Server/Windows-API-Accessibility-Server", "ImportCertificate", "KeyView", "MandelZoom", "now", "PlaySound", "SkeletonWin32App", "StartSuspended", "wxNotepad", "yekneb" ) $cCompilerForWindows = "c:/mingw64/bin/gcc.exe" $cxxCompilerForWindows = "c:/mingw64/bin/g++.exe" $cmakeGeneratorForWindows = "MinGW Makefiles" $cmakePathForWindows = "c:/mingw64/opt/cmake/bin/cmake.exe" $targetTripletForWindows = "x64-mingw-dynamic" $toolChainFileForWindows = "${env:VCPKG_ROOT_MINGW64}/scripts/buildsystems/vcpkg.cmake" $installPrefix = "${env:HOME}/.local" $installPrefix = $installPrefix.Replace("\", "/") if ($IsLinux) { $projects = $projectsForLinux $cCompiler = $cCompilerForLinux $cxxCompiler = $cxxCompilerForLinux $cmakeGenerator = $cmakeGeneratorForLinux $cmakePath = $cmakePathForLinux $targetTriplet = $targetTripletForLinux $toolChainFile = $toolChainFileForLinux } elseif ($IsWindows) { $projects = $projectsForWindows $cCompiler = $cCompilerForWindows $cxxCompiler = $cxxCompilerForWindows $cmakeGenerator = $cmakeGeneratorForWindows $cmakePath = $cmakePathForWindows $targetTriplet = $targetTripletForWindows $toolChainFile = $toolChainFileForWindows.Replace("\", "/") } else { Write-Error "Unsupported platform" exit 1 } foreach ($project in $projects) { $projectDir = Join-Path -Path $PSScriptRoot -ChildPath "$project/trunk" $projectDir = $projectDir.Replace("\", "/") $buildDir = Join-Path -Path $projectDir -ChildPath "build" $buildDir = $buildDir.Replace("\", "/") Write-Host "Building project: $project" if (-Not (Test-Path -Path $buildDir)) { New-Item -ItemType Directory -Path $buildDir | Out-Null } Push-Location -Path $buildDir Write-Host "Executing command: $cmakePath -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=$installPrefix -DCMAKE_VERBOSE_MAKEFILE:STRING=ON -DCMAKE_TOOLCHAIN_FILE:STRING=$toolChainFile -DVCPKG_TARGET_TRIPLET:STRING=$targetTriplet -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=$cCompiler -DCMAKE_CXX_COMPILER:FILEPATH=$cxxCompiler --no-warn-unused-cli -S $projectDir -B $buildDir -G $cmakeGenerator" & $cmakePath ` "-DCMAKE_BUILD_TYPE:STRING=Release" ` "-DCMAKE_INSTALL_PREFIX:STRING=$installPrefix" ` "-DCMAKE_VERBOSE_MAKEFILE:STRING=ON" ` "-DCMAKE_TOOLCHAIN_FILE:STRING=$toolChainFile" ` "-DVCPKG_TARGET_TRIPLET:STRING=$targetTriplet" ` "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE" ` "-DCMAKE_C_COMPILER:FILEPATH=$cCompiler" ` "-DCMAKE_CXX_COMPILER:FILEPATH=$cxxCompiler" ` "--no-warn-unused-cli" ` -S "$projectDir" ` -B "$buildDir" ` -G "$cmakeGenerator" if ($LASTEXITCODE -ne 0) { Pop-Location Write-Error "CMake configuration failed for project: $project" exit 1 } Write-Host "Executing command: $cmakePath --build $buildDir --config Release --target all" & $cmakePath --build "$buildDir" --config Release --target all if ($LASTEXITCODE -ne 0) { Pop-Location Write-Error "Build failed for project: $project" exit 1 } Write-Host "Executing command: $cmakePath --build $buildDir --config Release --target install" & $cmakePath --build "$buildDir" --config Release --target install if ($LASTEXITCODE -ne 0) { Pop-Location Write-Error "Install failed for project: $project" exit 1 } Pop-Location }