Kshitij Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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. |
| 21 | include_guard(GLOBAL) |
| 22 | |
| 23 | # Variables used by all other scripts |
Hugues Kamba-Mpiana | 27c169d | 2024-06-12 16:42:10 +0100 | [diff] [blame] | 24 | set(MLEK_ROOT ${CMAKE_CURRENT_LIST_DIR}) |
| 25 | set(MLEK_SCRIPTS_DIR ${MLEK_ROOT}/scripts) |
| 26 | set(MLEK_DEPENDENCY_ROOT_DIR ${MLEK_ROOT}/dependencies) |
| 27 | set(MLEK_HAL_PLATFORM_DIR ${MLEK_ROOT}/source/hal/source/platform) |
Kshitij Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 28 | set(MLEK_DOWNLOAD_DEP_DIR ${CMAKE_BINARY_DIR}/dependencies) |
| 29 | set(MLEK_CMAKE_TOOLCHAIN_DIR ${MLEK_SCRIPTS_DIR}/cmake/toolchains) |
| 30 | set(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. |
| 35 | list(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. |
| 39 | list(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. |
| 45 | include(source_gen_utils) |
| 46 | |
| 47 | # Enable testing - allows top level to add tests. |
| 48 | enable_testing() |
| 49 | |
| 50 | # Check that the source and build directories are different. |
| 51 | if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) |
| 52 | message(FATAL_ERROR "Source and build are in the same directory") |
| 53 | else() |
| 54 | message(STATUS "Source directory: ${CMAKE_SOURCE_DIR}") |
| 55 | message(STATUS "Binary directory: ${CMAKE_BINARY_DIR}") |
| 56 | endif() |
| 57 | |
| 58 | # Include common configuration options. |
| 59 | include(common_opts) |
| 60 | |
| 61 | # Check if the resources_downloaded needs update. |
Hugues Kamba-Mpiana | 27c169d | 2024-06-12 16:42:10 +0100 | [diff] [blame] | 62 | check_update_public_resources(${RESOURCES_PATH}) |
Kshitij Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 63 | |
| 64 | # Find the platform's build configuration and then add it. |
| 65 | add_platform_build_configuration(TARGET_PLATFORM ${TARGET_PLATFORM}) |
| 66 | set_platform_global_defaults() |
| 67 | |
| 68 | message(STATUS "Using CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}") |
| 69 | |
| 70 | # Make sure the following options are defined before proceeding. |
| 71 | assert_defined(LOG_LEVEL) |
| 72 | assert_defined(TENSORFLOW_SRC_PATH) |
| 73 | assert_defined(TARGET_PLATFORM) |
| 74 | assert_defined(USE_CASE_BUILD) |
| 75 | assert_defined(CPU_PROFILE_ENABLED) |
| 76 | assert_defined(CMAKE_TOOLCHAIN_FILE) |
| 77 | |
| 78 | # Explicit policy definitions. |
| 79 | if(POLICY CMP0123) |
| 80 | cmake_policy(SET CMP0123 NEW) |
| 81 | endif() |