François Beaune
François Beaune

Reputation: 4500

Detect x86 architecture in CMake file

Is there a simple, reliable way to detect in a CMake file that the system CMake is building for is based on the x86 instruction set (regardless of bitness)?

Upvotes: 1

Views: 9710

Answers (1)

François Beaune
François Beaune

Reputation: 4500

Here is my solution so far:

if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
    set (X86 TRUE)
else ()
    set (X86 FALSE)
endif ()

Please complete the regular expression if you know of or find x86 systems for which CMAKE_SYSTEM_PROCESSOR does not contain "x86", "X86", "amd64" or "AMD64" substrings.

Upvotes: 6

Related Questions