Detect architecture from the compiler instead of the host
This commit is contained in:
parent
404aa1bdb2
commit
074c0ecc4a
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.18)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
include(identity)
|
include(identity)
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,17 @@ set(DETECT_ARCH_C ${CMAKE_BINARY_DIR}/detect_arch.c)
|
||||||
|
|
||||||
file(WRITE ${DETECT_ARCH_C}
|
file(WRITE ${DETECT_ARCH_C}
|
||||||
"#include \"${SOURCE_DIR}/qcommon/q_platform.h\"
|
"#include \"${SOURCE_DIR}/qcommon/q_platform.h\"
|
||||||
#include <stdio.h>
|
#pragma message(\"@\" ARCH_STRING \"@\")
|
||||||
int main()
|
int main(void) { return 0; }
|
||||||
{
|
|
||||||
puts(ARCH_STRING);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
")
|
")
|
||||||
|
|
||||||
try_run(RUN_EXITCODE COMPILE_SUCCESS
|
try_compile(COMPILE_SUCCESS
|
||||||
${CMAKE_BINARY_DIR} ${DETECT_ARCH_C}
|
SOURCES ${DETECT_ARCH_C}
|
||||||
RUN_OUTPUT_VARIABLE ARCH)
|
OUTPUT_VARIABLE COMPILE_OUTPUT)
|
||||||
|
|
||||||
string(STRIP ${ARCH} ARCH)
|
string(REGEX MATCH "^[^\@]+@([a-zA-Z0-9_]+)@.*$" HAVE_MATCH ${COMPILE_OUTPUT})
|
||||||
|
set(ARCH ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
if(NOT COMPILE_SUCCESS OR RUN_EXITCODE OR NOT ARCH)
|
if(NOT COMPILE_SUCCESS OR RUN_EXITCODE OR NOT HAVE_MATCH OR NOT ARCH)
|
||||||
message(FATAL_ERROR "Architecture detection failed")
|
message(FATAL_ERROR "Architecture detection failed")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user