forked from Xilinx/mlir-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmlir_aie_init.cmake
More file actions
51 lines (47 loc) · 1.97 KB
/
mlir_aie_init.cmake
File metadata and controls
51 lines (47 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2026 Advanced Micro Devices, Inc.
# Encapsulates the pre-project() preamble shared by every example
# CMakeLists.txt under programming_guide/. Must be a macro (not a
# function) so that CMAKE_*_COMPILER settings and the cache/local
# variables it sets are visible in the caller's scope before project()
# runs.
#
# Intended usage in a template:
#
# cmake_minimum_required(VERSION 3.30)
# include(<path-to>/mlir_aie_init.cmake)
# mlir_aie_init_example() # WSL + compilers + ProjectName/currentTarget
# project(${ProjectName}) # MUST be a literal call in the top-level
# # CMakeLists.txt (CMake requirement)
# include(<path-to>/common.cmake)
#
# Why this exists: common.cmake calls find_package(XRT), which loads
# xrt-targets.cmake and runs add_library(... SHARED IMPORTED). That
# requires project() to have been called first. Centralising the
# preamble here keeps the ordering rule in one place rather than
# duplicated across ~50 templates. See Xilinx/mlir-aie#3048.
#
# Templates that need to override anything (extra cache vars, a
# different default TARGET_NAME, custom XRT paths, etc.) should set it
# BEFORE calling this macro. The CACHE-form set() calls below are no-ops
# if the value is already in the cache.
macro(mlir_aie_init_example)
find_program(WSL NAMES powershell.exe)
if(NOT WSL)
if(NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER gcc-13)
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER g++-13)
endif()
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
add_compile_options(/Zc:__cplusplus)
endif()
set(TARGET_NAME test CACHE STRING "Target to be built")
set(ProjectName proj_${TARGET_NAME})
set(currentTarget ${TARGET_NAME})
endmacro()