cmake: refactor the architecture detection
This commit is contained in:
@@ -62,7 +62,7 @@ find_package(PNG REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIRS})
|
||||
target_link_libraries(86Box PNG::PNG)
|
||||
|
||||
if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386")
|
||||
if(ARCH STREQUAL "i386")
|
||||
if(MSVC)
|
||||
set_target_properties(86Box PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||
elseif(MINGW)
|
||||
|
||||
27
src/arch_detect.c
Normal file
27
src/arch_detect.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Configure-time architecture detection for the CMake build.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: David Hrdlička, <hrdlickadavid@outlook.com>
|
||||
*
|
||||
* Copyright 2020-2021 David Hrdlička.
|
||||
*/
|
||||
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#error ARCH arm
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#error ARCH arm64
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#error ARCH i386
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
#error ARCH x86_64
|
||||
#endif
|
||||
#error ARCH unknown
|
||||
@@ -16,16 +16,15 @@
|
||||
if(DYNAREC)
|
||||
add_library(dynarec OBJECT codegen.c codegen_ops.c)
|
||||
|
||||
if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386")
|
||||
if(ARCH STREQUAL "i386")
|
||||
target_sources(dynarec PRIVATE codegen_x86.c
|
||||
codegen_accumulate_x86.c)
|
||||
elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "x86_64")
|
||||
elseif(ARCH STREQUAL "x86_64")
|
||||
target_sources(dynarec PRIVATE codegen_x86-64.c
|
||||
codegen_accumulate_x86-64.c)
|
||||
else()
|
||||
message(SEND_ERROR
|
||||
"Dynarec is incompatible with target platform "
|
||||
${CMAKE_TARGET_ARCHITECTURES})
|
||||
"Dynarec is incompatible with target platform ${ARCH}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box dynarec cgt)
|
||||
|
||||
@@ -25,27 +25,26 @@ if(DYNAREC)
|
||||
codegen_ops_mmx_pack.c codegen_ops_mmx_shift.c codegen_ops_mov.c
|
||||
codegen_ops_shift.c codegen_ops_stack.c codegen_reg.c)
|
||||
|
||||
if(CMAKE_TARGET_ARCHITECTURES STREQUAL "i386")
|
||||
if(ARCH STREQUAL "i386")
|
||||
target_sources(dynarec PRIVATE codegen_backend_x86.c
|
||||
codegen_backend_x86_ops.c codegen_backend_x86_ops_fpu.c
|
||||
codegen_backend_x86_ops_sse.c
|
||||
codegen_backend_x86_uops.c)
|
||||
elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "x86_64")
|
||||
elseif(ARCH STREQUAL "x86_64")
|
||||
target_sources(dynarec PRIVATE codegen_backend_x86-64.c
|
||||
codegen_backend_x86-64_ops.c
|
||||
codegen_backend_x86-64_ops_sse.c
|
||||
codegen_backend_x86-64_uops.c)
|
||||
elseif(CMAKE_TARGET_ARCHITECTURES STREQUAL "armv8")
|
||||
elseif(ARCH STREQUAL "arm64")
|
||||
target_sources(dynarec PRIVATE codegen_backend_arm64.c
|
||||
codegen_backend_arm64_ops.c codegen_backend_arm64_uops.c
|
||||
codegen_backend_arm64_imm.c)
|
||||
elseif(CMAKE_TARGET_ARCHITECTURES MATCHES "arm")
|
||||
elseif(ARCH STREQUAL "arm")
|
||||
target_sources(dynarec PRIVATE codegen_backend_arm.c
|
||||
codegen_backend_arm_ops.c codegen_backend_arm_uops.c)
|
||||
else()
|
||||
message(SEND_ERROR
|
||||
"Dynarec is incompatible with target platform "
|
||||
${CMAKE_TARGET_ARCHITECTURES})
|
||||
"Dynarec is incompatible with target platform ${ARCH}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box dynarec cgt)
|
||||
|
||||
Reference in New Issue
Block a user