Commit 8e356f48f86495fb9efd76d422e22a4853f2bf67

Patrick Steinhardt 2019-07-20T18:35:20

azure: explicitly specify CMake generator We currently specify the CMake generator as part of the CMAKE_OPTIONS variable. This is fine in the current setup, but during the conversion to drop PowerShell scripts this will prove problematic for all generators that have spaces in their names due to quoting issues. Convert to use an explicit CMAKE_GENERATOR variable that makes it easier to get quoting right.

diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 98e8097..abe0c3e 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -16,6 +16,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
 
 - job: linux_amd64_trusty_gcc_mbedtls
@@ -28,6 +29,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
 
 - job: linux_amd64_trusty_clang_openssl
@@ -40,6 +42,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=clang
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
 
 - job: linux_amd64_trusty_clang_mbedtls
@@ -52,6 +55,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=clang
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
 
 - job: macos
@@ -66,7 +70,8 @@ jobs:
       environmentVariables:
         TMPDIR: $(Agent.TempDirectory)
         PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
-        CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
+        CMAKE_GENERATOR: Ninja
+        CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
         SKIP_SSH_TESTS: true
 
 - job: windows_vs_amd64
@@ -76,7 +81,8 @@ jobs:
   - template: azure-pipelines/powershell.yml
     parameters:
       environmentVariables:
-        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: Visual Studio 12 2013 Win64
+        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
 
 - job: windows_vs_x86
   displayName: 'Windows (x86; Visual Studio)'
@@ -85,7 +91,8 @@ jobs:
   - template: azure-pipelines/powershell.yml
     parameters:
       environmentVariables:
-        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
+        CMAKE_GENERATOR: Visual Studio 12 2013
+        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
 
 - job: windows_mingw_amd64
   displayName: 'Windows (amd64; MinGW)'
@@ -100,7 +107,8 @@ jobs:
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
-        CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: MinGW Makefiles
+        CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
 
 - job: windows_mingw_x86
   displayName: 'Windows (x86; MinGW)'
@@ -116,7 +124,8 @@ jobs:
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
-        CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: MinGW Makefiles
+        CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
 
 - job: documentation
   displayName: 'Generate Documentation'
diff --git a/azure-pipelines/build.ps1 b/azure-pipelines/build.ps1
index dbc458d..96f39db 100644
--- a/azure-pipelines/build.ps1
+++ b/azure-pipelines/build.ps1
@@ -18,7 +18,7 @@ Write-Host "####################################################################
 Write-Host "## Configuring build environment"
 Write-Host "##############################################################################"
 
-Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON ${Env:CMAKE_OPTIONS}"
+Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON -G '${Env:CMAKE_GENERATOR}' ${Env:CMAKE_OPTIONS}"
 if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) }
 
 Write-Host ""
diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh
index 319666b..ac4d37b 100755
--- a/azure-pipelines/build.sh
+++ b/azure-pipelines/build.sh
@@ -42,8 +42,8 @@ echo "##########################################################################
 echo "## Configuring build environment"
 echo "##############################################################################"
 
-echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
-env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
+echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS}
+env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS}
 
 echo ""
 echo "##############################################################################"
diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml
index c494037..b6d5ed8 100644
--- a/azure-pipelines/nightly.yml
+++ b/azure-pipelines/nightly.yml
@@ -12,6 +12,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -25,6 +26,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -38,6 +40,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=clang
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -51,6 +54,7 @@ jobs:
       imageName: 'libgit2/trusty-amd64:latest'
       environmentVariables: |
        CC=clang
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -66,7 +70,8 @@ jobs:
       environmentVariables:
         TMPDIR: $(Agent.TempDirectory)
         PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
-        CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
+        CMAKE_GENERATOR: Ninja
+        CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks
         RUN_INVASIVE_TESTS: true
         SKIP_SSH_TESTS: true
 
@@ -77,7 +82,8 @@ jobs:
   - template: powershell.yml
     parameters:
       environmentVariables:
-        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: Visual Studio 12 2013 Win64
+        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
         RUN_INVASIVE_TESTS: true
 
 - job: windows_vs_x86
@@ -87,7 +93,8 @@ jobs:
   - template: powershell.yml
     parameters:
       environmentVariables:
-        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
+        CMAKE_GENERATOR: Visual Studio 12 2013
+        CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
         RUN_INVASIVE_TESTS: true
 
 - job: windows_mingw_amd64
@@ -103,7 +110,8 @@ jobs:
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
-        CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: MinGW Makefiles
+        CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
         RUN_INVASIVE_TESTS: true
 
 - job: windows_mingw_x86
@@ -120,7 +128,8 @@ jobs:
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
-        CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
+        CMAKE_GENERATOR: MinGW Makefiles
+        CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
         RUN_INVASIVE_TESTS: true
 
 - job: linux_x86_bionic_gcc_openssl
@@ -134,6 +143,7 @@ jobs:
       imageName: 'libgit2/bionic-x86:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -148,6 +158,7 @@ jobs:
       imageName: 'libgit2/bionic-x86:latest'
       environmentVariables: |
        CC=clang
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
        RUN_INVASIVE_TESTS=true
 
@@ -162,6 +173,7 @@ jobs:
       imageName: 'libgit2/bionic-arm32:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
        RUN_INVASIVE_TESTS=true
        SKIP_PROXY_TESTS=true
@@ -177,6 +189,7 @@ jobs:
       imageName: 'libgit2/bionic-arm64:latest'
       environmentVariables: |
        CC=gcc
+       CMAKE_GENERATOR=Unix Makefiles
        CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
        RUN_INVASIVE_TESTS=true
        SKIP_PROXY_TESTS=true