build: conditional dependency handling of depfile

Older distributions like Ubuntu 20.04 uses an old version
of cmake that does not handle absolute paths.
Leave .api dependency handling like before, i.e.
not handle interdependency between .api files for those older
builds.

Type: fix
Change-Id: I3f15a4506f6c95fca7a5b00893dc354cbed42a29
Signed-off-by: Ole Troan <otroan@employees.org>
This commit is contained in:
Ole Troan
2024-06-21 17:17:09 +02:00
committed by Ole Tr�an
parent f876b69537
commit 228e195e11

View File

@ -47,15 +47,27 @@ function(vpp_generate_api_c_header file)
get_filename_component(barename ${file} NAME)
# Define a variable for common apigen arguments
set(COMMON_ARGS
OUTPUT ${OUTPUT_HEADERS}
COMMAND mkdir -p ${output_dir}
COMMAND ${PYENV} ${VPP_APIGEN}
ARGS ${includedir} --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --outputdir ${output_dir} --output ${output_name} -MF ${dependency_file}
DEPENDS ${VPP_APIGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${VPPAPIGEN_SUBMODULES}
COMMENT "Generating API header ${output_name}"
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
add_custom_command (
OUTPUT ${OUTPUT_HEADERS}
COMMAND mkdir -p ${output_dir}
COMMAND ${PYENV} ${VPP_APIGEN}
ARGS ${includedir} --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --outputdir ${output_dir} --output ${output_name} -MF ${dependency_file}
DEPENDS ${VPP_APIGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${VPPAPIGEN_SUBMODULES}
COMMENT "Generating API header ${output_name}"
${COMMON_ARGS}
DEPFILE ${dependency_file}
)
else()
message(WARNING "Your CMake version does not support DEPFILE. Consider upgrading to CMake 3.20 or later for improved dependency handling.")
add_custom_command (
${COMMON_ARGS}
)
endif()
set(t ${barename}_deps)
if (NOT TARGET ${t})