From bdcd826311853659d3fd601d4fdf4b6a5c179f25 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 17 Sep 2020 19:27:29 +0200 Subject: [PATCH 1/8] WIP: Use vcpkg to get ITK See also https://discourse.itk.org/t/how-to-avoid-rebuilding-itk-by-azure-ci-at-the-github-of-another-project-elastix/2002 --- Testing/CI/Azure/ci.yml | 109 +++------------------------------------- 1 file changed, 7 insertions(+), 102 deletions(-) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index 7e10034b1..813d2248a 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -1,128 +1,33 @@ variables: - ITKv5_VERSION: v5.1.1 - ITK_GIT_URL: https://github.com/InsightSoftwareConsortium/ITK - ITK_SOURCE_DIR: $(Agent.BuildDirectory)/ITK-source - ITK_BINARY_DIR: $(Agent.BuildDirectory)/ITK-build ELASTIX_SOURCE_DIR: $(Build.Repository.LocalPath) ELASTIX_BINARY_DIR: $(Agent.BuildDirectory)/Elastix-build - + jobs: -- job: Windows +- job: WindowsVcpkg timeoutInMinutes: 0 pool: vmImage: 'vs2017-win2016' - strategy: - matrix: - ITKv5: - itk.version: $(ITKv5_VERSION) steps: - script: | - git clone $(ITK_GIT_URL) --branch $(itk.version) --depth 1 "$(ITK_SOURCE_DIR)" - displayName: Clone ITK + set VCPKG_DEFAULT_TRIPLET=x64-windows + vcpkg.exe install itk + displayName: vcpkg install itk - script: | - mkdir "$(ITK_BINARY_DIR)" mkdir "$(ELASTIX_BINARY_DIR)" displayName: Make build directories - - task: CMake@1 - displayName: 'CMake Generate ITK' - inputs: - cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DITK_LEGACY_REMOVE=ON "$(ITK_SOURCE_DIR)" - workingDirectory: "$(ITK_BINARY_DIR)" - - task: CMake@1 - displayName: 'CMake Build ITK' - inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: "$(ITK_BINARY_DIR)" - task: CMake@1 displayName: 'CMake Generate Elastix' inputs: - cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DITK_DIR="$(ITK_BINARY_DIR)" -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON "$(ELASTIX_SOURCE_DIR)" + cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DBUILD_TESTING=ON -DUSE_ALL_COMPONENTS=ON "$(ELASTIX_SOURCE_DIR)" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" workingDirectory: "$(ELASTIX_BINARY_DIR)" - task: CMake@1 displayName: 'CMake Build Elastix' inputs: cmakeArgs: --build . --config Release -j 2 workingDirectory: "$(ELASTIX_BINARY_DIR)" - - script: | + - script: | pushd "$(ELASTIX_BINARY_DIR)" # We exclude two flaky tests whose output depend on the runtime environment which cause them to fail on Azure ctest -C Release -VV -j 2 -E "elastix_run_example_COMPARE_IM|elastix_run_3DCT_lung.MI.bspline.ASGD.001_COMPARE_TP" popd displayName: 'CTest Elastix' -- job: Ubuntu1604 - timeoutInMinutes: 0 - pool: - vmImage: 'ubuntu-16.04' - strategy: - matrix: - ITKv5: - itk.version: $(ITKv5_VERSION) - steps: - - script: | - git clone $(ITK_GIT_URL) --branch $(itk.version) --depth 1 "$(ITK_SOURCE_DIR)" - - script: | - mkdir $(ITK_BINARY_DIR) - mkdir $(ELASTIX_BINARY_DIR) - displayName: Clone ITK - - task: CMake@1 - displayName: 'CMake Generate ITK' - inputs: - cmakeArgs: -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DITK_LEGACY_REMOVE=ON $(ITK_SOURCE_DIR) - workingDirectory: $(ITK_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Build ITK' - inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: $(ITK_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Generate Elastix' - inputs: - cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON $(ELASTIX_SOURCE_DIR) - workingDirectory: $(ELASTIX_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Build Elastix' - inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: $(ELASTIX_BINARY_DIR) - - bash: ctest --config Release -VV -j 2 - displayName: 'CTest Elastix' - workingDirectory: $(ELASTIX_BINARY_DIR) -- job: macOS - timeoutInMinutes: 0 - pool: - vmImage: 'macOS-10.14' - strategy: - matrix: - ITKv5: - itk.version: $(ITKv5_VERSION) - steps: - - script: | - git clone $(ITK_GIT_URL) --branch $(itk.version) --depth 1 "$(ITK_SOURCE_DIR)" - displayName: Clone ITK - - script: | - mkdir $(ITK_BINARY_DIR) - mkdir $(ELASTIX_BINARY_DIR) - displayName: Make build directories - - task: CMake@1 - displayName: 'CMake Generate ITK' - inputs: - cmakeArgs: -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DITK_LEGACY_REMOVE=ON $(ITK_SOURCE_DIR) - workingDirectory: $(ITK_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Build ITK' - inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: $(ITK_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Generate Elastix' - inputs: - cmakeArgs: -DITK_DIR=$(ITK_BINARY_DIR) -DBUILD_TESTING=ON -DELASTIX_USE_GTEST=ON -DUSE_ALL_COMPONENTS=ON $(Build.Repository.LocalPath) - workingDirectory: $(ELASTIX_BINARY_DIR) - - task: CMake@1 - displayName: 'CMake Build Elastix' - inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: $(ELASTIX_BINARY_DIR) - - bash: ctest --config Release -VV -j 2 - displayName: 'CTest Elastix' - workingDirectory: $(ELASTIX_BINARY_DIR) From 8ed6103103cc9720d302a2d4e8f70cb7118f2a9c Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sun, 11 Aug 2019 12:23:07 +0200 Subject: [PATCH 2/8] COMP: CI now does git pull vcpkg and bootstrap-vcpkg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hoping to fix: > LINK : fatal error LNK1181: cannot open input file '\lib\double-conversion.lib' Dženan Zukić @dzenanz informed us that there was some work regarding ITK_USE_SYSTEM_DOUBLECONVERSION between IK 5.0.0 and 5.0.1, which might solve this problem. --- Testing/CI/Azure/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index 813d2248a..fb3935dc7 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -8,6 +8,13 @@ jobs: pool: vmImage: 'vs2017-win2016' steps: + - script: | + cd /d C:\vcpkg + git log -1 + git pull + git log -1 + .\bootstrap-vcpkg.bat + displayName: git pull vcpkg and bootstrap-vcpkg - script: | set VCPKG_DEFAULT_TRIPLET=x64-windows vcpkg.exe install itk From 35d0f0ffd270894b890c491b1aebac0c6a5ca1b9 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 13 Aug 2019 16:46:43 +0200 Subject: [PATCH 3/8] COMP: Add vcpkg integrate install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by Dženan Zukić @dzenanz --- Testing/CI/Azure/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index fb3935dc7..ca07a7992 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -18,7 +18,8 @@ jobs: - script: | set VCPKG_DEFAULT_TRIPLET=x64-windows vcpkg.exe install itk - displayName: vcpkg install itk + vcpkg.exe integrate install + displayName: vcpkg install itk and integrate - script: | mkdir "$(ELASTIX_BINARY_DIR)" displayName: Make build directories From 418901ec5903c41f462cd1cabb43a06e83117359 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 13 Aug 2019 22:53:11 +0200 Subject: [PATCH 4/8] COMP: Fix link errors building double-conversion from vcpkg Fixed by ugly `link_directories` quick-fix. See also https://github.com/SuperElastix/elastix/pull/161#issuecomment-520978325 --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5d6f1f31..8a8e6a6be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_minimum_required( VERSION 3.10.2 ) project( elastix ) + +# TODO Niels Dekker, August 2019: Quick and dirty fix to support building ITK from vcpkg, on azure (CI). +link_directories( + C:/vcpkg/installed/x64-windows # For lib/double-conversion.lib +) + set(CMAKE_CXX_STANDARD 11) if( BUILD_SHARED_LIBS ) From 53229246c3d626f6953b2e2711c88a0e058c363e Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 14 Aug 2019 14:55:00 +0200 Subject: [PATCH 5/8] COMP: Build elastix by MSBuild, instead of CMake --build Yet another attempt to fix those link errors --- Testing/CI/Azure/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index ca07a7992..789b7fd62 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -28,11 +28,12 @@ jobs: inputs: cmakeArgs: -G "Visual Studio 15 2017 Win64" -T host=x64 -DBUILD_TESTING=ON -DUSE_ALL_COMPONENTS=ON "$(ELASTIX_SOURCE_DIR)" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" workingDirectory: "$(ELASTIX_BINARY_DIR)" - - task: CMake@1 - displayName: 'CMake Build Elastix' + - task: MSBuild@1 + displayName: 'MSBuild' inputs: - cmakeArgs: --build . --config Release -j 2 - workingDirectory: "$(ELASTIX_BINARY_DIR)" + solution: '$(ELASTIX_BINARY_DIR)/ALL_BUILD.vcxproj' + configuration: Release + platform: x64 - script: | pushd "$(ELASTIX_BINARY_DIR)" # We exclude two flaky tests whose output depend on the runtime environment which cause them to fail on Azure From 1dc914a718fbc277adfd7106068ca7c4566843bd Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 14 Aug 2019 17:05:44 +0200 Subject: [PATCH 6/8] COMP: Add msbuildArguments: /p:VcpkgEnabled=true Suggested at "Disable automatic integration for a particuar VS project" https://github.com/Microsoft/vcpkg/issues/281 --- Testing/CI/Azure/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index 789b7fd62..3288031b7 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -34,6 +34,7 @@ jobs: solution: '$(ELASTIX_BINARY_DIR)/ALL_BUILD.vcxproj' configuration: Release platform: x64 + msbuildArguments: /p:VcpkgEnabled=true - script: | pushd "$(ELASTIX_BINARY_DIR)" # We exclude two flaky tests whose output depend on the runtime environment which cause them to fail on Azure From bf2ab3bed054cdafc34fefdba5c6eb9435ad6e66 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 14 Aug 2019 23:39:20 +0200 Subject: [PATCH 7/8] COMP: Remove quickfix for double-conversion.lib Check if it still compiles with VcpkgEnabled=true --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a8e6a6be..f2b8d43d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,6 @@ cmake_minimum_required( VERSION 3.10.2 ) project( elastix ) -# TODO Niels Dekker, August 2019: Quick and dirty fix to support building ITK from vcpkg, on azure (CI). -link_directories( - C:/vcpkg/installed/x64-windows # For lib/double-conversion.lib -) - set(CMAKE_CXX_STANDARD 11) if( BUILD_SHARED_LIBS ) From 0a6ab68e3dbec6aa1f883459f3f728b66a2aad42 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Thu, 17 Sep 2020 21:53:45 +0200 Subject: [PATCH 8/8] COMP: Temporarily loosen ITK requirement from version 5.1.1 to 5.1 Work around the CMake Error at https://dev.azure.com/kaspermarstal/Elastix/_build/results?buildId=971&view=logs&j=8113fa60-6c65-540e-d189-4caa7b0fea60&t=ec6f6503-6d4b-5e80-e979-365ac800d840 > CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:493 (_find_package): > Could not find a configuration file for package "ITK" that is compatible > with requested version "5.1.1". > > The following configuration files were considered but not accepted: > > C:/vcpkg/installed/x64-windows/share/itk/ITKConfig.cmake, version: 5.1.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2b8d43d7..2c2cfb99f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ include( CTest ) #--------------------------------------------------------------------- # Find ITK. -find_package( ITK 5.1.1 REQUIRED ) +find_package( ITK 5.1 REQUIRED ) include( ${ITK_USE_FILE} ) #---------------------------------------------------------------------