diff options
-rw-r--r-- | src/cmake/api.cmake | 24 |
1 files changed, 18 insertions, 6 deletions
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}) |