mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
FASTBuild: make it work with non-US installations of MSVC
The fastbuild generator uses clui.dll directly, and assumed it is in the 1033/ subdirectory. But this doesn't exist on non-US installations of Visual Studio. With this patch cmake searches for clui.dll, so it can use the correct path. If the env. var VSLANG is set, it tries that first, then it tries 1033/ and if none of the two exists, it takes the first one it finds. Fixes: #27535
This commit is contained in:
committed by
Brad King
parent
6741ac7186
commit
8bb0eef8e6
@@ -22,6 +22,7 @@ set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
|
||||
set(CMAKE_C_COMPILER_ARCHITECTURE_ID "@CMAKE_C_COMPILER_ARCHITECTURE_ID@")
|
||||
@_SET_CMAKE_C_COMPILER_SYSROOT@
|
||||
@SET_MSVC_C_ARCHITECTURE_ID@
|
||||
@SET_CMAKE_C_MSVC_I18N_DIR@
|
||||
@SET_CMAKE_XCODE_ARCHS@
|
||||
set(CMAKE_AR "@CMAKE_AR@")
|
||||
set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@")
|
||||
|
||||
@@ -24,6 +24,7 @@ set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
|
||||
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "@CMAKE_CXX_COMPILER_ARCHITECTURE_ID@")
|
||||
@_SET_CMAKE_CXX_COMPILER_SYSROOT@
|
||||
@SET_MSVC_CXX_ARCHITECTURE_ID@
|
||||
@SET_CMAKE_CXX_MSVC_I18N_DIR@
|
||||
@SET_CMAKE_XCODE_ARCHS@
|
||||
set(CMAKE_AR "@CMAKE_AR@")
|
||||
set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@")
|
||||
|
||||
@@ -214,6 +214,11 @@ if(MSVC_C_ARCHITECTURE_ID)
|
||||
"set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_MSVC_I18N_DIR)
|
||||
set(SET_CMAKE_C_MSVC_I18N_DIR
|
||||
"set(CMAKE_C_MSVC_I18N_DIR ${CMAKE_C_MSVC_I18N_DIR})")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_XCODE_ARCHS)
|
||||
set(SET_CMAKE_XCODE_ARCHS
|
||||
"set(CMAKE_XCODE_ARCHS \"${CMAKE_C_XCODE_ARCHS}\")")
|
||||
|
||||
@@ -220,6 +220,11 @@ if(MSVC_CXX_ARCHITECTURE_ID)
|
||||
"set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_MSVC_I18N_DIR)
|
||||
set(SET_CMAKE_CXX_MSVC_I18N_DIR
|
||||
"set(CMAKE_CXX_MSVC_I18N_DIR ${CMAKE_CXX_MSVC_I18N_DIR})")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_XCODE_ARCHS)
|
||||
set(SET_CMAKE_XCODE_ARCHS
|
||||
"set(CMAKE_XCODE_ARCHS \"${CMAKE_CXX_XCODE_ARCHS}\")")
|
||||
|
||||
@@ -256,6 +256,12 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
||||
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "")
|
||||
endif()
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "^FASTBuild"
|
||||
AND CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC")
|
||||
cmake_determine_msvc_i18n_dir(${lang})
|
||||
set(CMAKE_${lang}_MSVC_I18N_DIR ${CMAKE_${lang}_MSVC_I18N_DIR} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_EFFECTIVE_SYSTEM_NAME STREQUAL "Apple" AND CMAKE_${lang}_COMPILER_ID MATCHES "Clang$")
|
||||
cmake_path(GET src EXTENSION LAST_ONLY ext)
|
||||
set(apple_sdk_dir "${CMAKE_${lang}_COMPILER_ID_DIR}")
|
||||
@@ -1340,3 +1346,40 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
|
||||
endif()
|
||||
message(CONFIGURE_LOG "Detecting ${lang} compiler /showIncludes prefix:\n${msg}\n")
|
||||
endfunction()
|
||||
|
||||
function(CMAKE_DETERMINE_MSVC_I18N_DIR lang)
|
||||
# The FASTBuild generator needs the full path to clui.dll:
|
||||
cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH cldir)
|
||||
|
||||
# if the VSLANG env.var is set, prefer that.
|
||||
# If that doesn't exist, try 1033, the US version.
|
||||
# Otherwise, search for any clui.dll, and use the first one that is found.
|
||||
if(DEFINED ENV{VSLANG})
|
||||
if(EXISTS "${cldir}/$ENV{VSLANG}/clui.dll")
|
||||
set(MSVC_I18N_DIR "$ENV{VSLANG}")
|
||||
else()
|
||||
message(WARNING "The environment variable VSLANG is set to $ENV{VSLANG}, but could not find ${cldir}/$ENV{VSLANG}/clui.dll")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT MSVC_I18N_DIR)
|
||||
if(EXISTS "${cldir}/1033/clui.dll")
|
||||
set(MSVC_I18N_DIR "1033")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT MSVC_I18N_DIR)
|
||||
file(GLOB_RECURSE cluis "${cldir}/*/clui.dll")
|
||||
list(GET cluis 0 firstClui)
|
||||
if (firstClui)
|
||||
cmake_path(GET firstClui PARENT_PATH cluiParentPath)
|
||||
cmake_path(GET cluiParentPath FILENAME MSVC_I18N_DIR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC_I18N_DIR)
|
||||
set(CMAKE_${lang}_MSVC_I18N_DIR ${MSVC_I18N_DIR} PARENT_SCOPE )
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find clui.dll !")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -983,9 +983,6 @@ void cmGlobalFastbuildGenerator::AddCompiler(std::string const& language,
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate the i18n number.
|
||||
std::string i18nNum = "1033";
|
||||
|
||||
// Add the language to the compiler's name
|
||||
FastbuildCompiler compilerDef;
|
||||
compilerDef.ExtraVariables["Root"] =
|
||||
@@ -1027,6 +1024,10 @@ void cmGlobalFastbuildGenerator::AddCompiler(std::string const& language,
|
||||
compilerDef.CmakeCompilerID == "MSVC") {
|
||||
// https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||
|
||||
// Calculate the i18n number.
|
||||
std::string const i18nNum =
|
||||
mf->GetSafeDefinition(cmStrCat("CMAKE_", language, "_MSVC_I18N_DIR"));
|
||||
|
||||
// Visual Studio 17 (19.30 to 19.39)
|
||||
// TODO
|
||||
|
||||
|
||||
Reference in New Issue
Block a user