build: use GNUInstallDirs where possible
[vpp.git] / src / cmake / api.cmake
index f3af687..10e89d7 100644 (file)
@@ -38,7 +38,7 @@ function(vpp_generate_api_c_header file)
   add_custom_command (
     OUTPUT ${OUTPUT_HEADERS}
     COMMAND mkdir -p ${output_dir}
-    COMMAND ${VPP_APIGEN}
+    COMMAND ${PYENV} ${VPP_APIGEN}
     ARGS ${includedir} --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --outputdir ${output_dir} --output ${output_name}
     DEPENDS ${VPP_APIGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${file}
     COMMENT "Generating API header ${output_name}"
@@ -49,6 +49,7 @@ function(vpp_generate_api_c_header file)
     add_custom_target(${t} ALL DEPENDS ${OUTPUT_HEADERS})
     add_dependencies(api_headers ${t})
   endif()
+
 endfunction()
 
 function(vpp_generate_api_json_header file dir component)
@@ -62,14 +63,14 @@ function(vpp_generate_api_json_header file dir component)
   endif()
   add_custom_command (OUTPUT ${output_name}
     COMMAND mkdir -p ${output_dir}
-    COMMAND ${VPP_APIGEN}
-    ARGS ${includedir} --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} JSON --output ${output_name}
+    COMMAND ${PYENV} ${VPP_APIGEN}
+    ARGS ${includedir} --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} JSON --outputdir ${output_dir} --output ${output_name}
     DEPENDS ${VPP_APIGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${file}
     COMMENT "Generating API header ${output_name}"
   )
   install(
     FILES ${output_name}
-    DESTINATION share/vpp/api/${dir}/
+    DESTINATION ${CMAKE_INSTALL_DATADIR}/vpp/api/${dir}/
     COMPONENT ${component}
   )
 endfunction()
@@ -79,7 +80,7 @@ endfunction()
 ##############################################################################
 function(vpp_generate_vapi_c_header f)
   get_filename_component(output ${f}.vapi.h NAME)
-  set (output_name ${CMAKE_BINARY_DIR}/vpp-api/vapi/${output})
+  set (output_name ${VPP_BINARY_DIR}/vpp-api/vapi/${output})
   if(NOT VPP_VAPI_C_GEN)
     set(VPP_VAPI_C_GEN ${CMAKE_SOURCE_DIR}/vpp-api/vapi/vapi_c_gen.py)
     set(VPP_VAPI_C_GEN_DEPENDS
@@ -92,22 +93,22 @@ function(vpp_generate_vapi_c_header f)
   set(input ${CMAKE_CURRENT_BINARY_DIR}/${f}.json)
   add_custom_command(
     OUTPUT ${output_name}
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vpp-api/vapi
-    COMMAND ${VPP_VAPI_C_GEN}
+    WORKING_DIRECTORY ${VPP_BINARY_DIR}/vpp-api/vapi
+    COMMAND ${PYENV} ${VPP_VAPI_C_GEN}
     ARGS --remove-path ${input}
     DEPENDS ${input} ${VPP_VAPI_C_GEN_DEPENDS}
     COMMENT "Generating VAPI C header ${output_name}"
   )
   install(
     FILES ${output_name}
-    DESTINATION include/vapi
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vapi
     COMPONENT vpp-dev
   )
 endfunction ()
 
 function (vpp_generate_vapi_cpp_header f)
   get_filename_component(output ${f}.vapi.hpp NAME)
-  set (output_name ${CMAKE_BINARY_DIR}/vpp-api/vapi/${output})
+  set (output_name ${VPP_BINARY_DIR}/vpp-api/vapi/${output})
   if(NOT VPP_VAPI_CPP_GEN)
     set(VPP_VAPI_CPP_GEN ${CMAKE_SOURCE_DIR}/vpp-api/vapi/vapi_cpp_gen.py)
     set(VPP_VAPI_CPP_GEN_DEPENDS
@@ -119,15 +120,15 @@ function (vpp_generate_vapi_cpp_header f)
   set(input ${CMAKE_CURRENT_BINARY_DIR}/${f}.json)
   add_custom_command(
     OUTPUT ${output_name}
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vpp-api/vapi
-    COMMAND ${VPP_VAPI_CPP_GEN}
+    WORKING_DIRECTORY ${VPP_BINARY_DIR}/vpp-api/vapi
+    COMMAND ${PYENV} ${VPP_VAPI_CPP_GEN}
     ARGS --gen-h-prefix=vapi --remove-path ${input}
     DEPENDS ${input} ${VPP_VAPI_CPP_GEN_DEPENDS}
     COMMENT "Generating VAPI C++ header ${output_name}"
   )
   install(
     FILES ${output_name}
-    DESTINATION include/vapi
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vapi
     COMPONENT vpp-dev
   )
 endfunction ()
@@ -160,12 +161,15 @@ function(vpp_add_api_files name dir component)
     get_filename_component(name ${file} NAME)
     list(APPEND header_files
       ${file}.h
+      ${file}_enum.h
+      ${file}_types.h
       ${file}.json
-      ${CMAKE_BINARY_DIR}/vpp-api/vapi/${name}.vapi.h
-      ${CMAKE_BINARY_DIR}/vpp-api/vapi/${name}.vapi.hpp
+      ${VPP_BINARY_DIR}/vpp-api/vapi/${name}.vapi.h
+      ${VPP_BINARY_DIR}/vpp-api/vapi/${name}.vapi.hpp
     )
   endforeach()
   add_custom_target(${target} DEPENDS ${header_files})
+  add_dependencies(api_headers ${target})
 endfunction()
 
 add_custom_target(api_headers