mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-27 19:28:59 +08:00
[vcpkg-cmake-get-vars] Handle CMAKE_SYSROOT_COMPILE/CMAKE_SYSROOT_LINK (#41116)
This commit is contained in:
parent
0b63bdd30d
commit
52fc0d8c1e
@ -159,12 +159,37 @@ if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
||||
string(APPEND EXTRA_FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN} \"${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}\"")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_SYSROOT AND CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
|
||||
string(APPEND EXTRA_FLAGS " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
|
||||
set(extra_flags_compile "")
|
||||
set(extra_flags_link "")
|
||||
if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
|
||||
if(CMAKE_SYSROOT_COMPILE)
|
||||
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}\"")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
endif()
|
||||
|
||||
foreach(flags ${VCPKG_LANGUAGES} SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER)
|
||||
if(CMAKE_SYSROOT_LINK)
|
||||
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_LINK}\"")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(flags_to_add_target_compile "${VCPKG_LANGUAGES}")
|
||||
set(flags_to_add_target_link SHARED_LINKER EXE_LINKER STATIC_LINKER MODULE_LINKER)
|
||||
|
||||
foreach(flags IN LISTS flags_to_add_target_compile flags_to_add_target_link)
|
||||
set(${flags}_FLAGS "${target_param} ${CMAKE_${flags}_FLAGS} ${CMAKE_${flags}_FLAGS_${VCPKG_CONFIGS}} ${EXTRA_FLAGS}")
|
||||
endforeach()
|
||||
|
||||
foreach(flags IN LISTS flags_to_add_target_compile)
|
||||
string(APPEND ${flags}_FLAGS " ${extra_flags_compile}")
|
||||
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
|
||||
endforeach()
|
||||
|
||||
foreach(flags IN LISTS flags_to_add_target_link)
|
||||
string(APPEND ${flags}_FLAGS " ${extra_flags_link}")
|
||||
string(STRIP ${flags}_FLAGS "${${flags}_FLAGS}")
|
||||
endforeach()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vcpkg-cmake-get-vars",
|
||||
"version-date": "2023-12-31",
|
||||
"version-date": "2024-09-22",
|
||||
"documentation": "https://vcpkg.io/en/docs/README.html",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
|
@ -111,8 +111,21 @@ if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
||||
string(APPEND extra_flags " ${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN} \"${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}\"")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_SYSROOT AND CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
|
||||
string(APPEND extra_flags " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
|
||||
set(extra_flags_compile "")
|
||||
set(extra_flags_link "")
|
||||
if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT)
|
||||
if(CMAKE_SYSROOT_COMPILE)
|
||||
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}\"")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
string(APPEND extra_flags_compile " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSROOT_LINK)
|
||||
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_LINK}\"")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
string(APPEND extra_flags_link " \"${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
macro(_vcpkg_adjust_flags flag_var)
|
||||
@ -142,7 +155,9 @@ macro(_vcpkg_adjust_flags flag_var)
|
||||
endif()
|
||||
unset(flags_to_add_osx_arch_sysroot)
|
||||
endif()
|
||||
set(flags_to_add_target "${VCPKG_LANG_FLAGS}" CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
|
||||
set(flags_to_add_target_compile "${VCPKG_LANG_FLAGS}")
|
||||
set(flags_to_add_target_link CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
|
||||
set(flags_to_add_target "${flags_to_add_target_compile}" "${flags_to_add_target_link}")
|
||||
list(GET VCPKG_LANGUAGES 0 lang)
|
||||
if(CMAKE_${lang}_COMPILER_TARGET AND "${flag_var}" IN_LIST flags_to_add_target)
|
||||
if (CMAKE_${lang}_COMPILER_ID STREQUAL Clang)
|
||||
@ -154,6 +169,12 @@ macro(_vcpkg_adjust_flags flag_var)
|
||||
if("${flag_var}" IN_LIST flags_to_add_target)
|
||||
string(APPEND ${flag_var} " ${extra_flags}")
|
||||
endif()
|
||||
if("${flag_var}" IN_LIST flags_to_add_target_compile)
|
||||
string(APPEND ${flag_var} " ${extra_flags_compile}")
|
||||
endif()
|
||||
if("${flag_var}" IN_LIST flags_to_add_target_link)
|
||||
string(APPEND ${flag_var} " ${extra_flags_link}")
|
||||
endif()
|
||||
unset(lang)
|
||||
unset(flags_to_add_target)
|
||||
endmacro()
|
||||
|
@ -9285,7 +9285,7 @@
|
||||
"port-version": 0
|
||||
},
|
||||
"vcpkg-cmake-get-vars": {
|
||||
"baseline": "2023-12-31",
|
||||
"baseline": "2024-09-22",
|
||||
"port-version": 0
|
||||
},
|
||||
"vcpkg-get-python": {
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "f23148add155147f3d95ae622d3b0031beb25acf",
|
||||
"version-date": "2024-09-22",
|
||||
"port-version": 0
|
||||
},
|
||||
{
|
||||
"git-tree": "725c841810ceb8de33da68ea879eb8f0b4d6c94c",
|
||||
"version-date": "2023-12-31",
|
||||
|
Loading…
Reference in New Issue
Block a user