mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Simplify configuration and use of vcpkg
* Simplify configuration and use of vcpkg * Use 22.04 * Set and use BUILD_TYPE = Release * Use -DVCPKG_BUILD_TYPE=release
This commit is contained in:
parent
4f5a0d8bdf
commit
1e07b239d1
89
.github/workflows/ResInsightWithCache.yml
vendored
89
.github/workflows/ResInsightWithCache.yml
vendored
@ -12,6 +12,7 @@ env:
|
||||
BUILDCACHE_VERSION: 0.27.6
|
||||
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
|
||||
BUILDCACHE_ACCURACY: SLOPPY
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
|
||||
concurrency:
|
||||
group: build-${{ github.event.pull_request.number || github.ref }}
|
||||
@ -23,45 +24,43 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Release]
|
||||
config:
|
||||
- {
|
||||
name: "Windows Latest MSVC",
|
||||
os: windows-2022,
|
||||
cc: "cl",
|
||||
cxx: "cl",
|
||||
vcpkg-response-file: vcpkg_x64-windows.txt,
|
||||
vcpkg-triplet: x64-windows,
|
||||
build-python-module: true,
|
||||
execute-unit-tests: true,
|
||||
execute-pytests: true,
|
||||
unity-build: true,
|
||||
publish-to-pypi: false,
|
||||
vcpkg-bootstrap: bootstrap-vcpkg.bat,
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu 20.04 gcc",
|
||||
os: ubuntu-20.04,
|
||||
name: "Ubuntu 22.04 gcc",
|
||||
os: ubuntu-22.04,
|
||||
cc: "gcc",
|
||||
cxx: "g++",
|
||||
vcpkg-response-file: vcpkg_x64-linux.txt,
|
||||
vcpkg-triplet: x64-linux,
|
||||
build-python-module: true,
|
||||
execute-unit-tests: true,
|
||||
execute-pytests: true,
|
||||
unity-build: false,
|
||||
publish-to-pypi: true,
|
||||
vcpkg-bootstrap: bootstrap-vcpkg.sh,
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu 22.04 clang-16",
|
||||
os: ubuntu-22.04,
|
||||
cc: "clang-16",
|
||||
cxx: "clang++-16",
|
||||
vcpkg-response-file: vcpkg_x64-linux.txt,
|
||||
vcpkg-triplet: x64-linux,
|
||||
build-python-module: true,
|
||||
execute-unit-tests: true,
|
||||
execute-pytests: false,
|
||||
unity-build: false,
|
||||
publish-to-pypi: false,
|
||||
vcpkg-bootstrap: bootstrap-vcpkg.sh,
|
||||
}
|
||||
steps:
|
||||
- name: Checkout
|
||||
@ -177,55 +176,43 @@ jobs:
|
||||
cache: true
|
||||
modules: "qtnetworkauth"
|
||||
|
||||
- name: Restore from cache and install vcpkg
|
||||
uses: lukka/run-vcpkg@v7
|
||||
id: runvcpkg
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}"
|
||||
vcpkgDirectory:
|
||||
"${{ github.workspace }}/ThirdParty/vcpkg"
|
||||
appendedCacheKey: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-cache-key-v2
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
|
||||
- name: vcpkg bootstrap
|
||||
run: |
|
||||
ThirdParty/vcpkg/${{ matrix.config.vcpkg-bootstrap }}
|
||||
|
||||
- name: Configure
|
||||
shell: cmake -P {0}
|
||||
run: |
|
||||
set(ENV{CC} ${{ matrix.config.cc }})
|
||||
set(ENV{CXX} ${{ matrix.config.cxx }})
|
||||
shell: bash
|
||||
env:
|
||||
CC: ${{ matrix.config.cc }}
|
||||
CXX: ${{ matrix.config.cxx }}
|
||||
run: >
|
||||
cmake -S . -B cmakebuild
|
||||
-DVCPKG_BUILD_TYPE=release
|
||||
-DCMAKE_INSTALL_PREFIX=cmakebuild/install
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
-DRESINSIGHT_QT5_BUNDLE_LIBRARIES=true
|
||||
-DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
|
||||
-DRESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
|
||||
-DRESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
|
||||
-DRESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
|
||||
-DRESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
|
||||
-DRESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
|
||||
-DRESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
|
||||
-DRESINSIGHT_ENABLE_HDF5=false
|
||||
-DRESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
|
||||
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
-G Ninja
|
||||
|
||||
execute_process(
|
||||
COMMAND cmake
|
||||
-S .
|
||||
-B cmakebuild
|
||||
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
|
||||
-D CMAKE_INSTALL_PREFIX=cmakebuild/install
|
||||
-D RESINSIGHT_QT5_BUNDLE_LIBRARIES=true
|
||||
-D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
|
||||
-D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
|
||||
-D RESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
|
||||
-D RESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
|
||||
-D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
|
||||
-D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
|
||||
-D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
|
||||
-D RESINSIGHT_ENABLE_HDF5=false
|
||||
-D RESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
|
||||
-D CMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
-G Ninja
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
if (NOT result EQUAL 0)
|
||||
message(FATAL_ERROR "Bad exit status")
|
||||
endif()
|
||||
- name: Build
|
||||
shell: cmake -P {0}
|
||||
run: |
|
||||
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
|
||||
execute_process(
|
||||
COMMAND cmake --build cmakebuild --target install
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
if (NOT result EQUAL 0)
|
||||
message(FATAL_ERROR "Bad exit status")
|
||||
endif()
|
||||
cmake --build cmakebuild --target install
|
||||
|
||||
- name: Stats for buildcache
|
||||
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
|
||||
|
@ -81,13 +81,6 @@ if(MSVC)
|
||||
add_definitions(-D_USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
||||
# ##############################################################################
|
||||
# Eigen
|
||||
# ##############################################################################
|
||||
if(RESINSIGHT_VCPKG_AUTO_INSTALL)
|
||||
vcpkg_install(eigen3)
|
||||
endif()
|
||||
|
||||
find_package(Eigen3 REQUIRED)
|
||||
|
||||
# ##############################################################################
|
||||
|
@ -38,16 +38,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
option(RESINSIGHT_BUNDLE_TESTMODELS "Copy TestModels into the installation" OFF)
|
||||
mark_as_advanced(RESINSIGHT_BUNDLE_TESTMODELS)
|
||||
|
||||
option(RESINSIGHT_VCPKG_AUTO_INSTALL
|
||||
"Automatically download build pre-requisites with VCPKG" OFF
|
||||
)
|
||||
mark_as_advanced(RESINSIGHT_VCPKG_AUTO_INSTALL)
|
||||
|
||||
if(RESINSIGHT_VCPKG_AUTO_INSTALL)
|
||||
include(AutoVcpkg)
|
||||
set(AUTO_VCPKG_ROOT "${CMAKE_SOURCE_DIR}/ThirdParty/vcpkg")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@ -436,12 +426,6 @@ endif() # MSVC
|
||||
# Opm
|
||||
# ##############################################################################
|
||||
|
||||
if(RESINSIGHT_VCPKG_AUTO_INSTALL)
|
||||
vcpkg_install(boost-filesystem)
|
||||
vcpkg_install(boost-spirit)
|
||||
include(${CMAKE_TOOLCHAIN_FILE})
|
||||
endif()
|
||||
|
||||
add_subdirectory(ThirdParty/custom-opm-flowdiagnostics)
|
||||
add_subdirectory(ThirdParty/custom-opm-flowdiag-app)
|
||||
|
||||
|
@ -3,10 +3,6 @@ project(GrpcInterface)
|
||||
message(STATUS "GRPC enabled")
|
||||
add_definitions(-DENABLE_GRPC)
|
||||
|
||||
if(RESINSIGHT_VCPKG_AUTO_INSTALL)
|
||||
vcpkg_install(grpc)
|
||||
endif()
|
||||
|
||||
set(CMAKE_UNITY_BUILD false)
|
||||
set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE
|
||||
""
|
||||
|
@ -1,148 +0,0 @@
|
||||
# ~~~
|
||||
# Copyright 2019 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ~~~
|
||||
|
||||
#
|
||||
#
|
||||
# AUTO_VCPKG_GIT_TAG - which vcpkg tag to clone if building ourselves
|
||||
#
|
||||
# AUTO_VCPKG_ROOT - root where `vcpkg` is (or should be installed)
|
||||
# NOTE: it should be fullpath to the place otherwise it will be relative to CMAKE_SOURCE_DIR
|
||||
#
|
||||
|
||||
set(AUTO_VCPKG_GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git")
|
||||
if (DEFINED AUTO_VCPKG_GIT_TAG)
|
||||
set(USE_AUTO_VCPKG_GIT_TAG "GIT_TAG ${AUTO_VCPKG_GIT_TAG}")
|
||||
endif ()
|
||||
|
||||
function (vcpkg_setroot)
|
||||
if (DEFINED AUTO_VCPKG_ROOT)
|
||||
return()
|
||||
endif ()
|
||||
set(AUTO_VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE STRING "")
|
||||
set(ENV{VCPKG_ROOT} "${AUTO_VCPKG_ROOT}")
|
||||
message(STATUS "AutoVcpkg: using vcpkg root ${AUTO_VCPKG_ROOT}")
|
||||
endfunction()
|
||||
|
||||
function (vcpkg_download)
|
||||
vcpkg_setroot()
|
||||
set(vcpkg_download_contents [===[
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(vcpkg-download)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(vcpkg
|
||||
GIT_REPOSITORY @AUTO_VCPKG_GIT_REPOSITORY@
|
||||
@USE_AUTO_VCPKG_GIT_TAG@
|
||||
GIT_SHALLOW ON
|
||||
SOURCE_DIR @AUTO_VCPKG_ROOT@
|
||||
PATCH_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD ON
|
||||
LOG_CONFIGURE ON
|
||||
LOG_INSTALL ON)
|
||||
]===])
|
||||
get_filename_component(AUTO_VCPKG_ROOT_FULL ${AUTO_VCPKG_ROOT} ABSOLUTE)
|
||||
string(REPLACE "@AUTO_VCPKG_GIT_REPOSITORY@" "${AUTO_VCPKG_GIT_REPOSITORY}" vcpkg_download_contents "${vcpkg_download_contents}")
|
||||
string(REPLACE "@USE_AUTO_VCPKG_GIT_TAG@" "${USE_AUTO_VCPKG_GIT_TAG}" vcpkg_download_contents "${vcpkg_download_contents}")
|
||||
string(REPLACE "@AUTO_VCPKG_ROOT@" "${AUTO_VCPKG_ROOT_FULL}" vcpkg_download_contents "${vcpkg_download_contents}")
|
||||
if(CCACHE_BIN)
|
||||
set(CMAKE_COMPILER_WRAPPER "-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_BIN} -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE_BIN}")
|
||||
endif()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/vcpkg-download/CMakeLists.txt" "${vcpkg_download_contents}")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||
"-H${CMAKE_BINARY_DIR}/vcpkg-download"
|
||||
"-B${CMAKE_BINARY_DIR}/vcpkg-download"
|
||||
${CMAKE_COMPILER_WRAPPER}
|
||||
${USE_AUTO_VCPKG_TRIPLET})
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||
"--build" "${CMAKE_BINARY_DIR}/vcpkg-download")
|
||||
endfunction ()
|
||||
|
||||
function (vcpkg_bootstrap)
|
||||
find_program(AUTO_VCPKG_EXECUTABLE
|
||||
vcpkg PATHS ${AUTO_VCPKG_ROOT})
|
||||
if (NOT AUTO_VCPKG_EXECUTABLE)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/cmake/vcpkg-bootstrap.cmake" "${AUTO_VCPKG_ROOT}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -P "${AUTO_VCPKG_ROOT}/vcpkg-bootstrap.cmake"
|
||||
WORKING_DIRECTORY ${AUTO_VCPKG_ROOT})
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
function (vcpkg_configure AUTO_VCPKG_BOOTSTRAP_SKIP)
|
||||
if (AUTO_VCPKG_EXECUTABLE AND DEFINED AUTO_VCPKG_ROOT)
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
"${AUTO_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
message(STATUS "AutoVcpkg: searching for vcpkg in ${AUTO_VCPKG_ROOT}")
|
||||
find_program(AUTO_VCPKG_EXECUTABLE
|
||||
vcpkg vcpkg.exe PATHS ${AUTO_VCPKG_ROOT})
|
||||
if (NOT AUTO_VCPKG_EXECUTABLE)
|
||||
message(STATUS "AutoVcpkg: vcpkg not found, bootstrapping a new installation")
|
||||
if (NOT AUTO_VCPKG_BOOTSTRAP_SKIP)
|
||||
vcpkg_download()
|
||||
vcpkg_bootstrap()
|
||||
endif ()
|
||||
# Validate now we have something
|
||||
find_program(AUTO_VCPKG_EXECUTABLE
|
||||
vcpkg vcpkg.exe PATHS ${AUTO_VCPKG_ROOT})
|
||||
if (NOT AUTO_VCPKG_EXECUTABLE)
|
||||
message(FATAL_ERROR "AutoVcpkg: Cannot find vcpkg executable")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(AUTO_VCPKG_ROOT)
|
||||
mark_as_advanced(AUTO_VCPKG_EXECUTABLE)
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
"${AUTO_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
|
||||
endfunction ()
|
||||
|
||||
function (vcpkg_install)
|
||||
cmake_parse_arguments(_vcpkg_install "" "TRIPLET" "" ${ARGN})
|
||||
if (NOT ARGN)
|
||||
message(STATUS "AutoVcpkg: vcpkg_install() called with no packages to install")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
set(packages ${ARGN})
|
||||
if (NOT _vcpkg_install_TRIPLET)
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Windows)")
|
||||
if (NOT "${CMAKE_GENERATOR}" MATCHES "(Win32|IA32|x86)")
|
||||
set(_vcpkg_install_TRIPLET "x64-windows")
|
||||
else ()
|
||||
set(_vcpkg_install_TRIPLET "x86-windows")
|
||||
endif ()
|
||||
#set(USE_AUTO_VCPKG_TRIPLET "-DVCPKG_TARGET_TRIPLET=${_vcpkg_install_TRIPLET}")
|
||||
#set(VCPKG_TARGET_TRIPLET ${_vcpkg_install_TRIPLET})
|
||||
list(TRANSFORM packages APPEND ":${_vcpkg_install_TRIPLET}")
|
||||
endif ()
|
||||
endif ()
|
||||
string(CONCAT join ${packages})
|
||||
string(TOLOWER "${AUTO_VCPKG_GIT_TAG}:${packages}" packages_cache)
|
||||
message(STATUS "AutoVcpkg: vcpkg packages: ${packages}")
|
||||
|
||||
vcpkg_setroot()
|
||||
if (NOT EXISTS "${AUTO_VCPKG_ROOT}/vcpkg" OR NOT EXISTS "${AUTO_VCPKG_ROOT}/.vcpkg-root")
|
||||
vcpkg_configure(off)
|
||||
else ()
|
||||
vcpkg_configure(on) # skip bootstrap
|
||||
endif ()
|
||||
|
||||
message(STATUS "AutoVcpkg: vcpkg_install() called to install: ${join}")
|
||||
execute_process (COMMAND "${AUTO_VCPKG_EXECUTABLE}" "install" ${packages})
|
||||
endfunction ()
|
@ -1,27 +0,0 @@
|
||||
# ~~~
|
||||
# Copyright 2019 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ~~~
|
||||
|
||||
find_program(VCPKG_EXECUTABLE
|
||||
vcpkg PATHS "${CMAKE_CURRENT_LIST_DIR}")
|
||||
if (NOT VCPKG_EXECUTABLE)
|
||||
if (WIN32)
|
||||
execute_process(COMMAND "${CMAKE_CURRENT_LIST_DIR}/bootstrap-vcpkg.bat" -disableMetrics
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
|
||||
else ()
|
||||
execute_process(COMMAND "${CMAKE_CURRENT_LIST_DIR}/bootstrap-vcpkg.sh" -disableMetrics
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif ()
|
||||
endif ()
|
14
vcpkg-configuration.json
Normal file
14
vcpkg-configuration.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6",
|
||||
"repository": "https://github.com/microsoft/vcpkg"
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"kind": "artifact",
|
||||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||
"name": "microsoft"
|
||||
}
|
||||
]
|
||||
}
|
9
vcpkg.json
Normal file
9
vcpkg.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"arrow",
|
||||
"boost-filesystem",
|
||||
"boost-spirit",
|
||||
"eigen3",
|
||||
"grpc"
|
||||
]
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
grpc
|
||||
boost-filesystem
|
||||
boost-spirit
|
||||
eigen3
|
||||
arrow
|
||||
--triplet
|
||||
x64-linux
|
@ -1,7 +0,0 @@
|
||||
grpc
|
||||
boost-filesystem
|
||||
boost-spirit
|
||||
eigen3
|
||||
arrow
|
||||
--triplet
|
||||
x64-osx
|
@ -1,7 +0,0 @@
|
||||
grpc
|
||||
boost-filesystem
|
||||
boost-spirit
|
||||
eigen3
|
||||
arrow
|
||||
--triplet
|
||||
x64-windows
|
Loading…
Reference in New Issue
Block a user