mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
* Select RHEL8 vcpkg-configuration.json via CMake instead of renaming the tracked file RHEL8 CI jobs previously ran 'cp vcpkg-configuration-rhel8.json vcpkg-configuration.json' before configuring, temporarily overwriting the tracked default configuration in the checkout. The vcpkg toolchain file only defaults VCPKG_MANIFEST_DIR to CMAKE_SOURCE_DIR when it is not already defined, and reads it while processing project(), so setting VCPKG_MANIFEST_DIR earlier -- before project() -- lets vcpkg read a different vcpkg-configuration.json without ever touching the tracked file. Add a RESINSIGHT_VCPKG_PROFILE cache variable, implemented in the new cmake/ResInsightVcpkgProfile.cmake (included from the root CMakeLists.txt before project(), which is required for VCPKG_MANIFEST_DIR to take effect). When set (e.g. to 'rhel8'), it copies vcpkg.json and vcpkg-configuration-<profile>.json into a profile-specific directory under the build tree and points VCPKG_MANIFEST_DIR there. The copy is regenerated on every configure, so it can never drift from the root vcpkg.json. overlay-ports/overlay-triplets entries (e.g. 'ThirdParty/vcpkg-overlay-ports') are resolved by vcpkg relative to the directory vcpkg-configuration.json lives in, so repo-relative 'ThirdParty/...' paths are rewritten to absolute paths right after the copy is generated, keeping them valid from the new location. Update the RHEL8 workflows and Dockerfile.rhel8 build-warmup stage to pass -DRESINSIGHT_VCPKG_PROFILE=rhel8 instead of the cp step, and update vcpkg-readme.md to describe the new mechanism. * #14733 Use x64-linux-release vcpkg triplet explicitly in RHEL8 CI The RHEL8 CI workflows and the Docker image's warmup/vcpkg-cache stages did not set VCPKG_TARGET_TRIPLET/VCPKG_HOST_TRIPLET, so vcpkg fell back to its plain x64-linux default triplet, which builds both debug and release variants of every dependency even though the CI build is Release-only. Set both to x64-linux-release consistently across the image's vcpkg install, the warmup CMake configure, and the two consuming workflows so the baked binary cache and the CI configure use matching ABI hashes and skip the unused debug builds.
68 lines
2.7 KiB
CMake
68 lines
2.7 KiB
CMake
# Select an alternate vcpkg-configuration.json without renaming/copying any
|
|
# tracked file. The vcpkg toolchain
|
|
# (ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake) defaults
|
|
# VCPKG_MANIFEST_DIR to CMAKE_SOURCE_DIR only when it is not already defined,
|
|
# and it must see the final value before project() triggers toolchain-file
|
|
# processing. This file must therefore be include()'d from the root
|
|
# CMakeLists.txt before project() is called -- code that runs after project()
|
|
# is too late.
|
|
#
|
|
# A profile's vcpkg-configuration file is expected at
|
|
# "vcpkg-configuration-${RESINSIGHT_VCPKG_PROFILE}.json" in the source root,
|
|
# e.g. vcpkg-configuration-rhel8.json for -DRESINSIGHT_VCPKG_PROFILE=rhel8.
|
|
# vcpkg.json is copied alongside it so both manifest files live in the same
|
|
# directory, as vcpkg requires; the copy is regenerated on every configure so it
|
|
# can never drift from the root vcpkg.json.
|
|
set(RESINSIGHT_VCPKG_PROFILE
|
|
""
|
|
CACHE
|
|
STRING
|
|
"Optional vcpkg-configuration profile, e.g. 'rhel8' to use vcpkg-configuration-rhel8.json"
|
|
)
|
|
if(RESINSIGHT_VCPKG_PROFILE)
|
|
set(_resinsight_vcpkg_profile_config
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg-configuration-${RESINSIGHT_VCPKG_PROFILE}.json"
|
|
)
|
|
if(NOT EXISTS "${_resinsight_vcpkg_profile_config}")
|
|
message(
|
|
FATAL_ERROR "RESINSIGHT_VCPKG_PROFILE='${RESINSIGHT_VCPKG_PROFILE}' but "
|
|
"${_resinsight_vcpkg_profile_config} does not exist"
|
|
)
|
|
endif()
|
|
|
|
set(_resinsight_vcpkg_manifest_dir
|
|
"${CMAKE_BINARY_DIR}/vcpkg-manifest-${RESINSIGHT_VCPKG_PROFILE}"
|
|
)
|
|
file(MAKE_DIRECTORY "${_resinsight_vcpkg_manifest_dir}")
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json"
|
|
"${_resinsight_vcpkg_manifest_dir}/vcpkg.json" COPYONLY
|
|
)
|
|
configure_file(
|
|
"${_resinsight_vcpkg_profile_config}"
|
|
"${_resinsight_vcpkg_manifest_dir}/vcpkg-configuration.json" COPYONLY
|
|
)
|
|
|
|
# overlay-ports/overlay-triplets entries (e.g.
|
|
# "ThirdParty/vcpkg-overlay-ports") are resolved by vcpkg relative to the
|
|
# directory vcpkg-configuration.json lives in. Since the copy above now lives
|
|
# under the build tree instead of the source root, rewrite those repo-relative
|
|
# "ThirdParty/..." paths to absolute paths so they still resolve to the real
|
|
# source tree.
|
|
file(READ "${_resinsight_vcpkg_manifest_dir}/vcpkg-configuration.json"
|
|
_resinsight_vcpkg_profile_json
|
|
)
|
|
string(REPLACE "\"ThirdParty/" "\"${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/"
|
|
_resinsight_vcpkg_profile_json
|
|
"${_resinsight_vcpkg_profile_json}"
|
|
)
|
|
file(WRITE "${_resinsight_vcpkg_manifest_dir}/vcpkg-configuration.json"
|
|
"${_resinsight_vcpkg_profile_json}"
|
|
)
|
|
|
|
set(VCPKG_MANIFEST_DIR
|
|
"${_resinsight_vcpkg_manifest_dir}"
|
|
CACHE PATH "" FORCE
|
|
)
|
|
endif()
|