Repository: conan-io/conan-center-index

Issue:
[package] boost/1.73.0: boost can not be crosscompiled when CXX contains sysroot
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **boost/1.73.0**
  * Operating System+version: **Ubuntu 19.10**
  * Compiler+version: **GCC 9**
  * Docker image: **conanio/gcc9-armv7hf**
  * Conan version: **Conan version 1.28.1**
  * Python version: **Python 3.7.5**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Linux
os_build=Linux
arch=armv7hf
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]

[env]
```


### Steps to reproduce (Include if Applicable)
> export CXX="arm-linux-gnueabihf-g++-9  --sysroot=<your_sysroot>"
> conan install boost/1.73.0@ --build missing


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
notice: found boost-build.jam at /home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/boost-build.jam
notice: loading B2 from /home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src
notice: Searching '/etc' '/home/conan' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src' '/home/conan/.conan/data/b2/4.2.0/_/_/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/bin/b2_src/src/kernel' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/kernel' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/util' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/tools' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/contrib' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/.' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/conan' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src' '/home/conan/.conan/data/b2/4.2.0/_/_/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/bin/b2_src/src/kernel' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/kernel' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/util' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/tools' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/contrib' '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/.'.
notice: Loading explicitly specified user configuration file:
    /home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/user-config.jam
notice: Searching '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build'.
notice: [zlib] Using pre-installed library
notice: [zlib] Condition
notice: [bzip2] Using pre-installed library
notice: [bzip2] Condition
warning: toolset gcc initialization:
warning: can not find user-provided command 'arm-linux-gnueabihf-g++-9  --sysroot=/whatever'
warning: initialized from /home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/user-config.jam:5
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/tools/gcc.jam:164: in gcc.init from module gcc
error: toolset gcc initialization:
error: provided command 'arm-linux-gnueabihf-g++-9  --sysroot=<sysroot>' not found
error: initialized from /home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/user-config.jam:5
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build/toolset.jam:44: in toolset.using from module toolset
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build/project.jam:1104: in using from module project-rules
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/user-config.jam:5: in modules.load from module user-config
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:255: in load-config from module build-system
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:449: in load-configuration-files from module build-system
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:607: in load from module build-system
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/kernel/modules.jam:295: in import from module modules
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/tools/build/src/kernel/bootstrap.jam:139: in boost-build from module
/home/conan/.conan/data/boost/1.73.0/_/_/source/source_subfolder/boost-build.jam:17: in module scope from module

```
</details>

NOTE: this did work with boost 1.72.0



Discussion:
Does it work when adding `--sysroot=...` to `CPPFLAGS+CFLAGS+CXXFLAGS`?
I have just quickly tried with `CXXFLAGS` and it looks like it is working 
I'm facing this exact issue when building boost using a SDK generated with yocto : 

```
error: provided command 'aarch64-poky-linux-g++  -march=armv8-a+crc -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/root/yocto-sdk/sysroots/aarch64-poky-linux' not found
```

This error only happens with the version from conan-io (`boost/1.71.0@`) : I do not have this issue if using the old recipe from deprecated conan center (`boost/1.71.0@conan/stable`).

Any idea of how to resolve this issue ?

Resolving patch:
diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py
--- a/recipes/boost/all/conanfile.py
+++ b/recipes/boost/all/conanfile.py
@@ -753,7 +753,7 @@ def create_library_config(deps_name, name):
 
         # Specify here the toolset with the binary if present if don't empty parameter :
         contents += '\nusing "%s" : %s : ' % (self._toolset, self._toolset_version)
-        contents += ' "%s"' % self._cxx.replace("\\", "/")
+        contents += ' %s' % self._cxx.replace("\\", "/")
 
         if tools.is_apple_os(self.settings.os):
             if self.settings.compiler == "apple-clang":
@@ -770,6 +770,8 @@ def create_library_config(deps_name, name):
             contents += '<cxxflags>"%s" ' % os.environ["CXXFLAGS"]
         if "CFLAGS" in os.environ:
             contents += '<cflags>"%s" ' % os.environ["CFLAGS"]
+        if "CPPFLAGS" in os.environ:
+            contents += '<compileflags>"%s" ' % os.environ["CPPFLAGS"]
         if "LDFLAGS" in os.environ:
             contents += '<linkflags>"%s" ' % os.environ["LDFLAGS"]
         if "ASFLAGS" in os.environ:


Test patch: