| 1 |
# Copyright (c) 2020-2021 Intel Corporation |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
# Prevent double invocation. |
| 16 |
if (MIPS_TOOLCHAIN_INCLUDED) |
| 17 |
return() |
| 18 |
endif() |
| 19 |
set(MIPS_TOOLCHAIN_INCLUDED TRUE) |
| 20 |
|
| 21 |
set(CMAKE_SYSTEM_NAME Linux) |
| 22 |
set(CMAKE_SYSTEM_VERSION 1) |
| 23 |
set(CMAKE_SYSTEM_PROCESSOR mips) |
| 24 |
|
| 25 |
set(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/mips-img-linux-gnu-gcc) |
| 26 |
set(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/mips-img-linux-gnu-g++) |
| 27 |
set(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/bin/mips-img-linux-gnu-ld) |
| 28 |
|
| 29 |
# Define result for try_run used in find_package(Threads). |
| 30 |
# In old CMake versions (checked on 3.5) there is invocation of try_run command in FindThreads.cmake module. |
| 31 |
# It can't be executed on host system in case of cross-compilation for MIPS architecture. |
| 32 |
# Define return code for this try_run as 0 since threads are expected to be available on target machine. |
| 33 |
set(THREADS_PTHREAD_ARG "0" CACHE STRING "Result from TRY_RUN" FORCE) |
| 34 |
|
| 35 |
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 36 |
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 37 |
|
| 38 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EL -mabi=64 -march=mips64r6 -mcrc -mfp64 -mmt -mtune=mips64r6 -ggdb -ffp-contract=off -mhard-float" CACHE INTERNAL "") |
| 39 |
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mvirt -mxpa" CACHE INTERNAL "") |
| 40 |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mvirt -mxpa" CACHE INTERNAL "") # for tests |