mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
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.
This commit is contained in:
parent
1e4720700c
commit
8e5d28de3c
Notes:
sideshowbarker
2024-07-18 23:45:52 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/8e5d28de3cb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/689
7 changed files with 22 additions and 4 deletions
|
@ -7,6 +7,11 @@ if (VCPKG_TARGET_ANDROID)
|
|||
include("Ladybird/Android/vcpkg_android.cmake")
|
||||
endif()
|
||||
|
||||
# Pass additional information to vcpkg toolchain files if we are using vcpkg.
|
||||
if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake$")
|
||||
set(CMAKE_PROJECT_ladybird_INCLUDE_BEFORE "Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake")
|
||||
endif()
|
||||
|
||||
project(ladybird
|
||||
VERSION 0.1.0
|
||||
LANGUAGES C CXX
|
||||
|
|
|
@ -2,4 +2,4 @@ set(VCPKG_CMAKE_SYSTEM_NAME Linux)
|
|||
set(VCPKG_TARGET_ARCHITECTURE arm64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../user-variables.cmake OPTIONAL)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
|
||||
|
|
|
@ -3,4 +3,4 @@ set(VCPKG_TARGET_ARCHITECTURE arm64)
|
|||
set(VCPKG_OSX_ARCHITECTURES arm64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../user-variables.cmake OPTIONAL)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
|
||||
|
|
2
Meta/CMake/vcpkg/base-triplets/base.cmake
Normal file
2
Meta/CMake/vcpkg/base-triplets/base.cmake
Normal file
|
@ -0,0 +1,2 @@
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/../user-variables.cmake OPTIONAL)
|
||||
include(${_VCPKG_INSTALLED_DIR}/../build-vcpkg-variables.cmake OPTIONAL)
|
|
@ -2,4 +2,4 @@ set(VCPKG_CMAKE_SYSTEM_NAME Linux)
|
|||
set(VCPKG_TARGET_ARCHITECTURE x64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../user-variables.cmake OPTIONAL)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
|
||||
|
|
|
@ -3,4 +3,4 @@ set(VCPKG_TARGET_ARCHITECTURE x64)
|
|||
set(VCPKG_OSX_ARCHITECTURES x86_64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../user-variables.cmake OPTIONAL)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
|
||||
|
|
11
Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake
Normal file
11
Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake
Normal file
|
@ -0,0 +1,11 @@
|
|||
# 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}")
|
Loading…
Reference in a new issue