@@ -60,8 +60,8 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
60
60
self ._build = self ._conanfile .conf .get ("tools.gnu:build_triplet" )
61
61
self ._target = None
62
62
63
- is_cross_building = cross_building (self ._conanfile )
64
- if is_cross_building :
63
+ self . _is_cross_building = cross_building (self ._conanfile )
64
+ if self . _is_cross_building :
65
65
os_host = conanfile .settings .get_safe ("os" )
66
66
arch_host = conanfile .settings .get_safe ("arch" )
67
67
os_build = conanfile .settings_build .get_safe ('os' )
@@ -84,11 +84,12 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
84
84
self .autoreconf_args = self ._default_autoreconf_flags ()
85
85
self .make_args = []
86
86
# Apple stuff
87
- is_cross_building_osx = (is_cross_building
87
+ is_cross_building_osx = (self . _is_cross_building
88
88
and conanfile .settings_build .get_safe ('os' ) == "Macos"
89
89
and is_apple_os (conanfile ))
90
- min_flag , arch_flag , isysroot_flag = resolve_apple_flags (conanfile ,
91
- is_cross_building = is_cross_building_osx )
90
+ min_flag , arch_flag , isysroot_flag = (
91
+ resolve_apple_flags (conanfile , is_cross_building = is_cross_building_osx )
92
+ )
92
93
# https://man.archlinux.org/man/clang.1.en#Target_Selection_Options
93
94
self .apple_arch_flag = arch_flag
94
95
# -isysroot makes all includes for your library relative to the build directory
@@ -102,7 +103,8 @@ def _get_msvc_runtime_flag(self):
102
103
return flag
103
104
104
105
def _msvc_extra_flags (self ):
105
- if is_msvc (self ._conanfile ) and check_min_vs (self ._conanfile , "180" , raise_invalid = False ):
106
+ if is_msvc (self ._conanfile ) and check_min_vs (self ._conanfile , "180" ,
107
+ raise_invalid = False ):
106
108
return ["-FS" ]
107
109
return []
108
110
@@ -160,7 +162,8 @@ def environment(self):
160
162
compilers_by_conf = self ._conanfile .conf .get ("tools.build:compiler_executables" , default = {},
161
163
check_type = dict )
162
164
if compilers_by_conf :
163
- compilers_mapping = {"c" : "CC" , "cpp" : "CXX" , "cuda" : "NVCC" , "fortran" : "FC" , "rc" : "RC" }
165
+ compilers_mapping = {"c" : "CC" , "cpp" : "CXX" , "cuda" : "NVCC" , "fortran" : "FC" ,
166
+ "rc" : "RC" }
164
167
for comp , env_var in compilers_mapping .items ():
165
168
if comp in compilers_by_conf :
166
169
compiler = compilers_by_conf [comp ]
@@ -172,6 +175,16 @@ def environment(self):
172
175
env .append ("CFLAGS" , self .cflags )
173
176
env .append ("LDFLAGS" , self .ldflags )
174
177
env .prepend_path ("PKG_CONFIG_PATH" , self ._conanfile .generators_folder )
178
+ # Issue related: https://github.com/conan-io/conan/issues/15486
179
+ if self ._is_cross_building and self ._conanfile .conf_build :
180
+ compilers_build_mapping = (
181
+ self ._conanfile .conf_build .get ("tools.build:compiler_executables" , default = {},
182
+ check_type = dict )
183
+ )
184
+ if "c" in compilers_build_mapping :
185
+ env .define ("CC_FOR_BUILD" , compilers_build_mapping ["c" ])
186
+ if "cpp" in compilers_build_mapping :
187
+ env .define ("CXX_FOR_BUILD" , compilers_build_mapping ["cpp" ])
175
188
return env
176
189
177
190
def vars (self ):
0 commit comments