diff --git a/conan_provider.cmake b/conan_provider.cmake index 7d397ba1..91d4e043 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -66,15 +66,22 @@ function(detect_arch ARCH) message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.") endif() endif() - if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64" OR CMAKE_OSX_ARCHITECTURES MATCHES arm64) + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") + set(host_arch ${CMAKE_OSX_ARCHITECTURES}) + elseif(MSVC) + set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + else() + set(host_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if(host_arch MATCHES "aarch64|arm64|ARM64") set(_ARCH armv8) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a|armv7l" OR CMAKE_OSX_ARCHITECTURES MATCHES armv7) + elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7") set(_ARCH armv7) - elseif(CMAKE_OSX_ARCHITECTURES MATCHES armv7s) + elseif(host_arch MATCHES armv7s) set(_ARCH armv7s) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686" OR CMAKE_OSX_ARCHITECTURES MATCHES i386) + elseif(host_arch MATCHES "i686|i386|X86") set(_ARCH x86) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|amd64|x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64) + elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64") set(_ARCH x86_64) endif() message(STATUS "CMake-Conan: cmake_system_processor=${_ARCH}") diff --git a/tests/test_smoke.py b/tests/test_smoke.py index a92932ba..a915130d 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -541,3 +541,35 @@ def test_watchos_simulator(self, capfd, chdir_build): assert "os.sdk=watchsimulator" in out assert "os.version=7.0" in out assert "compiler.libcxx=libc++" + + +class TestMSVCArch: + @pytest.fixture(scope="class", autouse=True) + def msvc_setup(self): + if os.path.exists("build"): + shutil.rmtree("build") + yield + + @windows + def test_msvc_arm64(self, capfd, chdir_build): + run('cmake .. --fresh -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G "Visual Studio 16 2019" -A ARM64') + out, _ = capfd.readouterr() + assert "arch=armv8" in out + + @windows + def test_msvc_arm(self, capfd, chdir_build): + run('cmake .. --fresh -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G "Visual Studio 16 2019" -A ARM') + out, _ = capfd.readouterr() + assert "arch=armv7" in out + + @windows + def test_msvc_x86_64(self, capfd, chdir_build): + run('cmake .. --fresh -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G "Visual Studio 16 2019" -A x64') + out, _ = capfd.readouterr() + assert "arch=x86_64" in out + + @windows + def test_msvc_x86(self, capfd, chdir_build): + run('cmake .. --fresh -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -G "Visual Studio 16 2019" -A Win32') + out, _ = capfd.readouterr() + assert "arch=x86" in out