From 228e195e115a195b408d90e25a85dbbd8560059d Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 21 Jun 2024 17:17:09 +0200 Subject: 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 --- src/cmake/api.cmake | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cmake/api.cmake b/src/cmake/api.cmake index cbda4008a28..999bbf91be1 100644 --- a/src/cmake/api.cmake +++ b/src/cmake/api.cmake @@ -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}) -- cgit 1.2.3-korg