From 824b28c9e9720e76d6ecff8d2b8347576ead30aa Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Fri, 12 Jan 2024 21:39:01 +0100 Subject: [PATCH] cmake: Fix 64bit host CPU detection In cases where we don't cross-compile, we might want to detect if a CPU is 32bit or 64bit. CMake provides functionality for this case starting in CMake 3.10. Let's use it. Ubuntu 20.04 uses CMake 3.16. From the top of my head, this is the oldest supported distribution. Debian buster ships with CMake 3.13. Signed-off-by: Johannes Demel --- CMakeLists.txt | 2 +- lib/CMakeLists.txt | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ff536a7..33216510 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.10) # We use `IS_64BIT now: https://cmake.org/cmake/help/latest/command/cmake_host_system_information.html set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index dc8d4e6e..433d4ac8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -244,17 +244,16 @@ endif() ######################################################################## if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86) include(CheckTypeSize) - check_type_size("void*[8]" SIZEOF_CPU BUILTIN_TYPES_ONLY) - if (${SIZEOF_CPU} EQUAL 64) + cmake_host_system_information(RESULT ASSUME_64BIT_HOST QUERY IS_64BIT) + if (ASSUME_64BIT_HOST) OVERRULE_ARCH(32 "CPU width is 64 bits") - endif() - if (${SIZEOF_CPU} EQUAL 32) + else() OVERRULE_ARCH(64 "CPU width is 32 bits") endif() #MSVC 64 bit does not have MMX, overrule it if (MSVC) - if (${SIZEOF_CPU} EQUAL 64) + if (ASSUME_64BIT_HOST) OVERRULE_ARCH(mmx "No MMX for Win64") endif() FORCE_ARCH(sse "Built-in for MSVC > 2013")