Detect architecture from the compiler instead of the host

This commit is contained in:
smallmodel authored and Tim Angus committed 2025-08-07 15:10:25 +01:00
1 parent 404aa1bdb2
commit 074c0ecc4a
2 files changed
+9 -12

No files matched your search

+1 -1
View File
@@ -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)
include(identity)
+8 -11
View File
@@ -4,20 +4,17 @@ set(DETECT_ARCH_C ${CMAKE_BINARY_DIR}/detect_arch.c)
file(WRITE ${DETECT_ARCH_C}
"#include \"${SOURCE_DIR}/qcommon/q_platform.h\"
#include <stdio.h>
int main()
{
puts(ARCH_STRING);
return 0;
}
#pragma message(\"@\" ARCH_STRING \"@\")
int main(void) { return 0; }
")
try_run(RUN_EXITCODE COMPILE_SUCCESS
${CMAKE_BINARY_DIR} ${DETECT_ARCH_C}
RUN_OUTPUT_VARIABLE ARCH)
try_compile(COMPILE_SUCCESS
SOURCES ${DETECT_ARCH_C}
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")
endif()