|
| 1 | +# --- Function definitions --- |
| 2 | +function Invoke-CMake { |
| 3 | + param ( |
| 4 | + $Arguments |
| 5 | + ) |
| 6 | + $process = Start-Process "cmake" -ArgumentList "$Arguments" -NoNewWindow -Wait -PassThru |
| 7 | + If ($process.ExitCode -ne 0) { |
| 8 | + Write-Host "Abort script execution due to CMake error." |
| 9 | + Exit(42) |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +function Get-VariableOrEnv { |
| 14 | + param ( |
| 15 | + [string]$Name |
| 16 | + ) |
| 17 | + |
| 18 | + $envValue = [Environment]::GetEnvironmentVariable($Name) |
| 19 | + if ($envValue -ne $null) { |
| 20 | + return $envValue |
| 21 | + } |
| 22 | + |
| 23 | + if (Get-Variable -Name $Name -ErrorAction SilentlyContinue) { |
| 24 | + return (Get-Variable -Name $Name).Value |
| 25 | + } |
| 26 | + |
| 27 | + return $null |
| 28 | +} |
| 29 | + |
| 30 | +# --- Variable definitions --- |
| 31 | +$cpp_standard = Get-VariableOrEnv -Name "cpp_standard" |
| 32 | + |
| 33 | +$nlohmann_json_DIR = Get-VariableOrEnv -Name "nlohmann_json_DIR" |
| 34 | +$Asio_ROOT = Get-VariableOrEnv -Name "Asio_ROOT" |
| 35 | +$TCLAP_ROOT = Get-VariableOrEnv -Name "TCLAP_ROOT" |
| 36 | +$Env:BOOST_ROOT = "boost_${Env:BOOST_VERSION}".Replace(".","_") |
| 37 | + |
| 38 | +$Env:CTEST_OUTPUT_ON_FAILURE="ON" |
| 39 | + |
| 40 | + |
| 41 | +# --- Script --- |
| 42 | + |
| 43 | +Invoke-CMake "-E","make_directory","build" |
| 44 | + |
| 45 | +$cmake_params = "-E chdir build cmake", |
| 46 | + "-DBUILD_SHARED_LIBS=`"${BUILD_SHARED_LIBS}`"", |
| 47 | + "-DCMAKE_INSTALL_PREFIX=${HOME}/.local" |
| 48 | + |
| 49 | +$cmake_params += "-DCMAKE_CXX_STANDARD=${cpp_standard}" |
| 50 | + |
| 51 | +$cmake_params += "-DCUKE_ENABLE_BOOST_TEST=OFF" |
| 52 | +$cmake_params += "-DCUKE_ENABLE_GTEST=OFF" |
| 53 | +$cmake_params += "-DCUKE_ENABLE_QT_6=OFF" |
| 54 | +$cmake_params += "-DCUKE_ENABLE_EXAMPLES=OFF" |
| 55 | +$cmake_params += "-DCUKE_TESTS_UNIT=OFF" |
| 56 | +$cmake_params += "-DCUKE_CODE_COVERAGE=OFF" |
| 57 | + |
| 58 | +$cmake_params += "-Dnlohmann_json_DIR=${nlohmann_json_DIR}" |
| 59 | +$cmake_params += "-DAsio_ROOT=${Asio_ROOT}" |
| 60 | +$cmake_params += "-DTCLAP_ROOT=${TCLAP_ROOT}" |
| 61 | + |
| 62 | +$cmake_params += ".." |
| 63 | + |
| 64 | + |
| 65 | +Invoke-CMake "$cmake_params" |
| 66 | +Invoke-CMake "--build","build" #,"--parallel" |
0 commit comments