Skip to content

Commit

Permalink
CMake: Add autodetection for 32-bit x86 CRC assembly usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Larhzu committed Jun 20, 2024
1 parent 4501de8 commit 01fc94a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,24 @@ add_compile_definitions(

# Support 32-bit x86 assembly files.
if(NOT MSVC)
option(XZ_ASM_I386 "Enable 32-bit x86 assembly code" OFF)
# Autodetection isn't so simple as in configure.ac because with
# CMake we don't have as reliable variable as Autoconf's $host_cpu.
# CMAKE_SYSTEM_PROCESSOR could indicate x86-64 even if building
# for 32-bit x86 because one doesn't necessarily use a toolchain
# file when building 32-bit executables on 64-bit system. Also,
# the strings that mean 32-bit or 64-bit x86 aren't standardized
# in CMake... So it's safer to ask the compiler when we seem to
# be building for a compatible platform.
if(MINGW OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES
"^FreeBSD$|^GNU$|^Linux$|^MirBSD$|^NetBSD$|^OpenBSD$")
check_symbol_exists("__i386__" "" ASM_I386_DEFAULT)
else()
set(ASM_I386_DEFAULT OFF)
endif()

option(XZ_ASM_I386 "Enable 32-bit x86 assembly code"
"${ASM_I386_DEFAULT}")

if(XZ_ASM_I386)
enable_language(ASM)
endif()
Expand Down

0 comments on commit 01fc94a

Please sign in to comment.