Skip to content

Commit

Permalink
Merge pull request #525 from ssrobins/msvc_archs
Browse files Browse the repository at this point in the history
Support MSVC architectures
  • Loading branch information
memsharded authored Oct 27, 2023
2 parents 451fa97 + 706921a commit b3482e1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
17 changes: 12 additions & 5 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
32 changes: 32 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b3482e1

Please sign in to comment.