-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] conan_cmake_autodetect()
doesn't specify arch
setting for MinGW compilers.
#448
Comments
DemonstrationFirst 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 {
"environment": {
"PATH": "C:/msys64/mingw32/bin;$penv{PATH}"
}
} The following are my example Click to expand CMakePresets.json{
"version": 3,
"configurePresets": [
{
"name": "win32-msvc-x64-nmake-debug",
"displayName": "Windows MSVC x64 (NMake Makefiles) Debug",
"description": "Using MSVC x64 compilers with \"NMake Makefiles\" generator on Windows - Debug",
"generator": "NMake Makefiles",
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win32-msvc-x86-nmake-debug",
"displayName": "Windows MSVC x86 (NMake Makefiles) Debug",
"description": "Using MSVC x86 compilers with \"NMake Makefiles\" generator on Windows - Debug",
"generator": "NMake Makefiles",
"toolset": {
"value": "host=x86",
"strategy": "external"
},
"architecture": {
"value": "x86",
"strategy": "external"
},
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win32-gcc-x64-mingw-debug",
"displayName": "Windows GCC x64 (MinGW Makefiles) Debug",
"description": "Using GCC x64 compiler with \"MinGW Makefiles\" geneartor on Windows - Debug",
"generator": "MinGW Makefiles",
"environment": {
"PATH": "C:/msys64/mingw64/bin;$penv{PATH}"
},
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc.exe",
"CMAKE_CXX_COMPILER": "g++.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "win32-gcc-x86-mingw-debug",
"displayName": "Windows GCC x86 (MinGW Makefiles) Debug",
"description": "Using GCC x86 compiler with \"MinGW Makefiles\" geneartor on Windows - Debug",
"generator": "MinGW Makefiles",
"environment": {
"PATH": "C:/msys64/mingw32/bin;$penv{PATH}"
},
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc.exe",
"CMAKE_CXX_COMPILER": "g++.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
} Click to expand CMakeLists.txtcmake_minimum_required(VERSION 3.21)
get_filename_component(folder_name "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
project(${folder_name} LANGUAGES C CXX)
message("========== ${PROJECT_NAME} ==========")
# Download 'conan.cmake' from "https://github.com/conan-io/cmake-conan"
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD
"https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
TLS_VERIFY ON)
endif()
include("${CMAKE_BINARY_DIR}/conan.cmake")
conan_cmake_autodetect(settings)
message("settings = ${settings}") Click to expand conanfile.pyfrom conans import ConanFile, CMake
class ConsumerConan(ConanFile):
settings = [ "os", "compiler", "build_type", "arch" ]
generators = [
"CMakeDeps",
"CMakeToolchain"
]
requires = [
"fmt/8.1.1@"
] Prepare the above three files in the same folder, and then configure the corresponding preset:
As we can see, there isn't |
Hi @hwhsu1231 , Thanks for the question. |
@czoido Then how about improving the autodetection of |
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. |
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
The text was updated successfully, but these errors were encountered: