ladybird/Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake
Andrew Kaster 8e5d28de3c CMake: Force vcpkg to use CMAKE_CXX_COMPILER as specified to CMake
Override the vcpkg/scripts/detect_compiler behavior of always pulling
$CC and $CXX at the time that vcpkg install is determined to need called
by forcing $ENV{CXX} and $ENV{CC} to our CMake-determined compiler.

This prevents strange behavior such as running the following:

./Meta/ladybird.sh run
    make changes...
ninja -C Build/ladybird

Where the second build step would be run without CC or CXX set in the
environment, causing a total cache miss from vcpkg and a full rebuild.

It also helps prevent full rebuilds when an IDE passes a slightly
different compiler to the build step than ladybird.sh.
2024-07-18 14:48:20 +02:00

12 lines
530 B
CMake

# The generated file here is read by vcpkg/base-triplets/base.cmake to ensure consistency between the project
# build and the vcpkg build.
set(EXTRA_VCPKG_VARIABLES "")
if (NOT "${CMAKE_C_COMPILER}" STREQUAL "")
string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CC} ${CMAKE_C_COMPILER})\n")
endif()
if (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "")
string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CXX} ${CMAKE_CXX_COMPILER})\n")
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build-vcpkg-variables.cmake" "${EXTRA_VCPKG_VARIABLES}")