Add cross-compilation for arm64 on macOS (#8758)
[cvc5.git] / cmake / Toolchain-aarch64.cmake
1 ###############################################################################
2 # Top contributors (to current version):
3 # Mathias Preiner, Andres Noetzli, Gereon Kremer
4 #
5 # This file is part of the cvc5 project.
6 #
7 # Copyright (c) 2009-2022 by the authors listed in the file AUTHORS
8 # in the top-level source directory and their institutional affiliations.
9 # All rights reserved. See the file COPYING in the top-level source
10 # directory for licensing information.
11 # #############################################################################
12 #
13 # Toolchain file for building for ARM on Ubuntu host.
14 #
15 # Use: cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-aarch64.cmake
16 ##
17
18 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
19
20 set(CMAKE_SYSTEM_NAME Linux)
21 set(CMAKE_SYSTEM_PROCESSOR aarch64)
22
23 set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
24
25 set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
26 set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
27
28 # Set target environment path
29 set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
30
31 # Adjust the default behaviour of the find_XXX() commands:
32 # search headers and libraries in the target environment, search
33 # programs in the host environment
34 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
35 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
36 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
37
38 elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
39
40 set(CMAKE_SYSTEM_NAME Darwin)
41 set(CMAKE_SYSTEM_PROCESSOR arm64)
42
43 set(TOOLCHAIN_PREFIX arm64-apple-darwin)
44
45 set(CMAKE_CROSSCOMPILING_MACOS TRUE)
46 set(CMAKE_OSX_ARCHITECTURES arm64 CACHE INTERNAL "")
47
48 endif()