blob: 198b422b610eed2f0a807dc341d92d69a9a969b9 [file] [log] [blame]
Kshitij Sisodia72377a42024-05-16 09:15:12 +01001#----------------------------------------------------------------------------
2# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
3# affiliates <open-source-office@arm.com>
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#----------------------------------------------------------------------------
18
19# For any CMake project wrapping ml-embedded-eval-kit, it should include this before
20# to get the default directory settings and set up the environment.
21include_guard(GLOBAL)
22
23# Variables used by all other scripts
Hugues Kamba-Mpiana27c169d2024-06-12 16:42:10 +010024set(MLEK_ROOT ${CMAKE_CURRENT_LIST_DIR})
25set(MLEK_SCRIPTS_DIR ${MLEK_ROOT}/scripts)
26set(MLEK_DEPENDENCY_ROOT_DIR ${MLEK_ROOT}/dependencies)
27set(MLEK_HAL_PLATFORM_DIR ${MLEK_ROOT}/source/hal/source/platform)
Kshitij Sisodia72377a42024-05-16 09:15:12 +010028set(MLEK_DOWNLOAD_DEP_DIR ${CMAKE_BINARY_DIR}/dependencies)
29set(MLEK_CMAKE_TOOLCHAIN_DIR ${MLEK_SCRIPTS_DIR}/cmake/toolchains)
30set(MLEK_CORE_PLATFORM_DIR ${MLEK_DEPENDENCY_ROOT_DIR}/core-platform)
31
32# The list of directories where platform build configurations are searched for.
33# Any project including this file, should append to this list before inclusion
34# to allow searching additional directories for target configurations.
35list(APPEND MLEK_PLATFORM_BUILD_CONFIG_DIRS ${MLEK_SCRIPTS_DIR}/cmake/platforms)
36
37# Append to CMAKE_MODULE_PATH to allow top level scripts to find and include
38# utility functions.
39list(APPEND CMAKE_MODULE_PATH
40 "${MLEK_SCRIPTS_DIR}/cmake"
41 "${MLEK_SCRIPTS_DIR}/cmake/configuration_options"
42 "${MLEK_SCRIPTS_DIR}/cmake/timing_adapter")
43
44# Include source generator.
45include(source_gen_utils)
46
47# Enable testing - allows top level to add tests.
48enable_testing()
49
50# Check that the source and build directories are different.
51if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
52 message(FATAL_ERROR "Source and build are in the same directory")
53else()
54 message(STATUS "Source directory: ${CMAKE_SOURCE_DIR}")
55 message(STATUS "Binary directory: ${CMAKE_BINARY_DIR}")
56endif()
57
58# Include common configuration options.
59include(common_opts)
60
61# Check if the resources_downloaded needs update.
Hugues Kamba-Mpiana27c169d2024-06-12 16:42:10 +010062check_update_public_resources(${RESOURCES_PATH})
Kshitij Sisodia72377a42024-05-16 09:15:12 +010063
64# Find the platform's build configuration and then add it.
65add_platform_build_configuration(TARGET_PLATFORM ${TARGET_PLATFORM})
66set_platform_global_defaults()
67
68message(STATUS "Using CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
69
70# Make sure the following options are defined before proceeding.
71assert_defined(LOG_LEVEL)
72assert_defined(TENSORFLOW_SRC_PATH)
73assert_defined(TARGET_PLATFORM)
74assert_defined(USE_CASE_BUILD)
75assert_defined(CPU_PROFILE_ENABLED)
76assert_defined(CMAKE_TOOLCHAIN_FILE)
77
78# Explicit policy definitions.
79if(POLICY CMP0123)
80 cmake_policy(SET CMP0123 NEW)
81endif()