blob: e0c31afa34079937024fa69792832b3e5ec0f045 [file] [log] [blame]
jotman01bed7a152021-05-25 22:57:17 +08001#/** @file
jothikumar mani4a274162023-07-18 00:31:22 +08002# * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved.
jotman01bed7a152021-05-25 22:57:17 +08003# * SPDX-License-Identifier : Apache-2.0
4# *
5# * Licensed under the Apache License, Version 2.0 (the "License");
6# * you may not use this file except in compliance with the License.
7# * You may obtain a copy of the License at
8# *
9# * http://www.apache.org/licenses/LICENSE-2.0
10# *
11# * Unless required by applicable law or agreed to in writing, software
12# * distributed under the License is distributed on an "AS IS" BASIS,
13# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# * See the License for the specific language governing permissions and
15# * limitations under the License.
16#**/
17
18set(CMAKE_SYSTEM_NAME Generic)
19if(CPU_ARCH STREQUAL "armv8a")
jothikumar mani4a274162023-07-18 00:31:22 +080020 set(CMAKE_SYSTEM_PROCESSOR ARM)
jotman01bed7a152021-05-25 22:57:17 +080021else()
jothikumar mani4a274162023-07-18 00:31:22 +080022 set(CMAKE_SYSTEM_PROCESSOR x86_64)
jotman01bed7a152021-05-25 22:57:17 +080023endif()
24
25if(DEFINED COMPILER_NAME)
26 set(_C_TOOLCHAIN_NAME ${COMPILER_NAME})
27else()
28 set(_C_TOOLCHAIN_NAME gcc)
29endif()
30
31
32if(WIN32)
33 if (NOT DEFINED GCC_LINUX_PATH)
34 set(GCC_LINUX_PATH "C:" CACHE PATH "Install directory for Host GCC Compiler")
35 endif()
36else(WIN32)
37 if (NOT DEFINED GCC_LINUX_PATH)
38 set(GCC_LINUX_PATH "/" CACHE PATH "Install directory for Host GCC Compiler")
39 endif()
40endif(WIN32)
41
42find_program(
43 _C_TOOLCHAIN_PATH
44 ${_C_TOOLCHAIN_NAME}
45 PATHS env PATH
46 HINTS ${GCC_LINUX_PATH}
47 HINTS bin
48)
49
50if(_C_TOOLCHAIN_PATH STREQUAL "_C_TOOLCHAIN_PATH-NOTFOUND")
51 message(FATAL_ERROR "[PSA] : Couldn't find ${_C_TOOLCHAIN_NAME}."
52 " Either put ${_C_TOOLCHAIN_NAME} on the PATH or set GNUARM_PATH set properly.")
53endif()
54
55set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
56
57foreach(_LNG IN ITEMS "C" "ASM")
58 set(CMAKE_${_LNG}_COMPILER ${_C_TOOLCHAIN_PATH})
59 set(CMAKE_C_FLAGS "-g -Wall -Werror -Werror -std=c99")
60 message(STATUS "[PSA] : ${_LNG} compiler used '${CMAKE_${_LNG}_COMPILER}'")
61endforeach()