Skip to content

Commit

Permalink
build: updated cmake file
Browse files Browse the repository at this point in the history
- Added architecture detection
- Add CPU_AARCH64 definition if that arch is detected
  • Loading branch information
midwan committed Nov 13, 2023
1 parent 52d7432 commit 0c02e00
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ include_directories(
)

add_subdirectory(external/libguisan)
add_definitions(-DAMIBERRY -D_FILE_OFFSET_BITS=64 -DUSE_RENDER_THREAD)
add_definitions(-DAMIBERRY -D_FILE_OFFSET_BITS=64)

include(CheckSymbolExists)
function(detect_architecture symbol arch)
if (NOT DEFINED ARCHITECTURE)
set(CMAKE_REQUIRED_QUIET 1)
check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
unset(CMAKE_REQUIRED_QUIET)

# The output variable needs to be unique across invocations otherwise
# CMake's crazy scope rules will keep it defined
if (ARCHITECTURE_${arch})
set(ARCHITECTURE "${arch}" PARENT_SCOPE)
endif()
endif()
endfunction()

detect_architecture("__x86_64__" x86_64)
detect_architecture("__aarch64__" arm64)
message(STATUS "Target architecture: ${ARCHITECTURE}")

add_executable(${PROJECT_NAME}
src/akiko.cpp
Expand Down Expand Up @@ -288,6 +307,10 @@ add_executable(${PROJECT_NAME}
# src/jit/compemu_support.cpp
)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR ARCHITECTURE MATCHES "arm64")
add_definitions(-DCPU_AARCH64)
endif()

INCLUDE(FindPkgConfig)

PKG_SEARCH_MODULE(SDL2 REQUIRED SDL2)
Expand Down

0 comments on commit 0c02e00

Please sign in to comment.