2017-01-23 14:56:08 +11:00
|
|
|
# attempt to find a consistent name for the host (the architecture on which
|
|
|
|
# the code will execute)
|
2017-01-17 19:20:12 +11:00
|
|
|
macro (canonical_host)
|
2017-01-18 21:43:30 +11:00
|
|
|
if (NOT DEFINED host_cpu)
|
2017-01-17 19:20:12 +11:00
|
|
|
message (STATUS "checking the host CPU")
|
|
|
|
|
2017-01-23 14:56:08 +11:00
|
|
|
# we have a sane compiler, so ask it directly for the architecture.
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
execute_process (
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
|
|
|
RESULT_VARIABLE __canonical_host_result
|
|
|
|
OUTPUT_VARIABLE __canonical_host_output
|
|
|
|
)
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-01-23 14:56:08 +11:00
|
|
|
if (${__canonical_host_result})
|
|
|
|
message (FATAL_ERROR "unable to query for canonical host")
|
|
|
|
endif (${__canonical_host_result})
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-01-23 14:56:08 +11:00
|
|
|
string(REGEX MATCH "^([^-\]+)" host_cpu ${__canonical_host_output})
|
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
|
|
set (host_cpu "x86_64")
|
|
|
|
else ()
|
|
|
|
message (FATAL_ERROR "unknown compiler")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (host_cpu "x86_64" CACHE INTERNAL "host cpu type")
|
2017-01-18 21:43:30 +11:00
|
|
|
message (STATUS "checking the host CPU - found '${host_cpu}'")
|
|
|
|
endif ()
|
2017-01-17 19:20:12 +11:00
|
|
|
endmacro (canonical_host)
|