Open hwhsu1231 opened 1 year ago
First of all, I installed MinGW x86 and MinGW x64 compilers by running the following commands on MSYS2.
pacman -S mingw-w64-i686-toolchain
pacman -S mingw-w64-x64_86-toolchain
And I append the bin directory into PATH
env when configure the preset, like:
{
"environment": {
"PATH": "C:/msys64/mingw32/bin;$penv{PATH}"
}
}
The following are my example CMakePresets.json
, CMakeLists.txt
, and conanfile.py
.
Prepare the above three files in the same folder, and then configure the corresponding preset:
For MSVC x64 compiler, configure with win32-msvc-x64-nmake-debug preset.
For MSVC x86 compiler, configure with win32-msvc-x86-nmake-debug preset.
For MinGW x64 compiler, configure with win32-msvc-x64-mingw-debug preset.
For MinGW x86 compiler, configure with win32-msvc-x86-mingw-debug preset.
As we can see, there isn't arch=x86
or arch=x86_64
in settings
variable when using MinGW x86 or MinGW x64 compiler.
Hi @hwhsu1231 ,
Thanks for the question. conan_cmake_autodetect()
just implements basic autodetection, for more advanced cases like using Windows subsystems and different x86 and x64 compilers I would recommend you to pass the ARCH
argument to conan_cmake_autodetect()
because as you say, cmake-conan is not clever enough to support those cases.
@czoido Then how about improving the autodetection of conan_cmake_autodetect()
?
@czoido Then how about improving the autodetection of
conan_cmake_autodetect()
?
Yes, we could check in the future if there is a demand by users but I'm afraid that right now is not a priority as the intention of that helper was to cover basic use cases. We may also accept contributions for that if they don't complicate too much the code or have the risk of breaking cases that currently work.
Maybe we can use gcc -dumpmachine
to check the architecture.
x86_64-w64-mingw32
.i686-w64-mingw32
.x86_64-pc-msys
.
Problem Desciprtion
It seems that
conan_cmake_autodetect()
doesn't specifyarch
setting for MinGW compilers. Therefore, some errors will occur when using MinGW x86 compiler since Conan will set it toarch=x86_64
by default.Environments and Versions