- - cd src
- - echo project (Stockfish) >> CMakeLists.txt
- - echo add_executable(stockfish benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp >> CMakeLists.txt
- - echo main.cpp material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp >> CMakeLists.txt
- - echo search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp syzygy/tbprobe.cpp) >> CMakeLists.txt
- - echo set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src) >> CMakeLists.txt
-# - echo target_compile_options(stockfish PUBLIC "/Ox") >> CMakeLists.txt
+ - ps: |
+ # Get sources
+ $src = get-childitem -Path *.cpp -Recurse | select -ExpandProperty FullName
+ $src = $src -join ' '
+ $src = $src.Replace("\", "/")
+
+ # Build CMakeLists.txt
+ $t = 'cmake_minimum_required(VERSION 3.8)',
+ 'project(Stockfish)',
+ 'set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src)',
+ 'set(source_files', $src, ')',
+ 'add_executable(stockfish ${source_files})'
+
+ # Write CMakeLists.txt withouth BOM
+ $MyPath = (Get-Item -Path "." -Verbose).FullName + '\CMakeLists.txt'
+ $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
+ [System.IO.File]::WriteAllLines($MyPath, $t, $Utf8NoBomEncoding)
+
+ # Obtain bench reference from git log
+ $b = git log HEAD | sls "\b[Bb]ench[ :]+[0-9]{7}" | select -first 1
+ $bench = $b -match '\D+(\d+)' | % { $matches[1] }
+ Write-Host "Reference bench:" $bench
+ $g = "Visual Studio 15 2017"
+ If (${env:PLATFORM} -eq 'x64') { $g = $g + ' Win64' }
+ cmake -G "${g}" .
+ Write-Host "Generated files for: " $g