# Generated by the Vitis IDE. Do not modify.

cmake_minimum_required(VERSION 3.20)
project(aie_component
LANGUAGES
C CXX
)

# Including the cmake modules from the Vitis Install.
set(CMAKE_MODULE_PATH
"$ENV{XILINX_VITIS}/vitis-server/scripts/cmake"
${CMAKE_MODULE_PATH}
)
find_package(Aie REQUIRED)

# Default Target is x86sim, can be overridden by passing cmake argument. Valid
# values are x86sim or hw Example: -DVITIS_TARGET=hw  builds the project for
# target hw
set(VITIS_TARGET
x86sim
CACHE STRING
"Target for which the project should be built"
)
set_property(CACHE VITIS_TARGET
   PROPERTY
    STRINGS x86sim hw
)

set(VITIS_PLATFORM_PATH
/opt/amd/2025.1/Vitis/base_platforms/xilinx_vck190_base_202510_1/xilinx_vck190_base_202510_1.xpfm
CACHE STRING
"Vitis Platform"
)
set(VITIS_PART
""
CACHE STRING
"Vitis Part"
)

# Generated by the Vitis IDE. Only modify the sections marked as USER SETTINGS.
set(_AIE_COMPILER
${Vitis_AIE_COMPILER}
)


set(USER_COMPILER_OPTIONS

)


####    Start of variables auto-updated by the Vitis IDE. Do not modify.    ####


# These setting are required to build the application as per the projecttemplate
# used. Update below only to modify the default settings.Below options are
# derived from the application template used to createthis project. Update them
# to suite your requirement. They will not be modifiedfurther by the tool.
# Below variables will be auto-updated based on the binary container.
set(_AIE_GRAPH_FILES
AIE/graph.cpp
)

set(_AIE_OUT_DIR
./Work
)

set(_AIE_LIB_ADF
libadf.a
)

set(_AIE_CFG
aiecompiler.cfg
)

##  End of variables auto-updated by the tool ##

file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.cc *.h *.hpp)
string(REGEX REPLACE "build/[^;]+;?" "" SRCS "${SRCS}")
string(REGEX REPLACE "_ide/[^;]+;?" "" SRCS "${SRCS}")

list(TRANSFORM _AIE_CFG PREPEND "${CMAKE_SOURCE_DIR}/")
list(TRANSFORM _AIE_GRAPH_FILES PREPEND "${CMAKE_SOURCE_DIR}/")
list(TRANSFORM _AIE_OUT_DIR PREPEND "${CMAKE_BINARY_DIR}/")

set(CONFIG_OPTIONS "")
foreach( cfg ${_AIE_CFG})
  list(APPEND CONFIG_OPTIONS "--config")
  list(APPEND CONFIG_OPTIONS ${cfg})
endforeach()

set(DEVICE_CONFIG "")
if( NOT ${VITIS_PLATFORM_PATH} STREQUAL "" )
  list(APPEND CONFIG_OPTIONS "--platform")
  list(APPEND CONFIG_OPTIONS ${VITIS_PLATFORM_PATH})
elseif( NOT ${VITIS_PART} STREQUAL "" )
  list(APPEND CONFIG_OPTIONS "--part")
  list(APPEND CONFIG_OPTIONS ${VITIS_PART})
endif()

# For adding pre build step.
# Any script can be used as a pre build step
# Uncomment the PRE_BUILD section to use the pre-build step.
# Example: run make to build a C/C++ traffic generator
#          Assumes traffic generator directory is available in AIE component.

# For adding post build step.
# Any script can be used as a post build step, it can take the build output as input.
# Uncomment POST_BUILD section to use the post build step.
# Example:  To copy the binary to a pre-defined location.
ADD_CUSTOM_COMMAND(OUTPUT ${_AIE_LIB_ADF}
	BYPRODUCTS ${CMAKE_BINARY_DIR}/AIECompiler.log ${_AIE_OUT_DIR}
		${CMAKE_BINARY_DIR}/xcd.log

    #PRE_BUILD - uncomment below line
    #COMMAND make -C ${CMAKE_SOURCE_DIR}/TrafficGenerator/Cpp/ compile

	COMMAND unset MAKEFLAGS&&${Vitis_COMPILER} -c --mode aie ${DEVICE_SETTING}
			--target ${VITIS_TARGET} ${CONFIG_OPTIONS}
			--work_dir ${_AIE_OUT_DIR} ${_AIE_GRAPH_FILES} ${USER_COMPILER_OPTIONS}
	DEPENDS ${_AIE_CFG} ${_AIE_GRAPH_FILES} ${SRCS}

    #POST_BUILD - uncomment below line
    #COMMAND cp  ${CMAKE_BINARY_DIR}/libadf.a  ${CMAKE_SOURCE_DIR}/../
    )

ADD_CUSTOM_TARGET(${CMAKE_PROJECT_NAME}_${_AIE_LIB_ADF} ALL
	DEPENDS ${_AIE_LIB_ADF} ${_AIE_GRAPH_FILES} )
