cmake: set packaging component for different files

Change-Id: I033a1f5cdb24f77462cb5ec90a62226d93f52925
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/cmake/api.cmake b/src/cmake/api.cmake
index 533448a..d799c54 100644
--- a/src/cmake/api.cmake
+++ b/src/cmake/api.cmake
@@ -26,7 +26,7 @@
   )
 endfunction()
 
-function(vpp_generate_api_json_header file dir)
+function(vpp_generate_api_json_header file dir component)
   set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.json)
   get_filename_component(output_dir ${output_name} DIRECTORY)
   add_custom_command (OUTPUT ${output_name}
@@ -36,7 +36,11 @@
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
     COMMENT "Generating API header ${output_name}"
   )
-  install(FILES ${output_name} DESTINATION share/vpp/api/${dir}/)
+  install(
+    FILES ${output_name}
+    DESTINATION share/vpp/api/${dir}/
+    COMPONENT ${component}
+  )
 endfunction()
 
 ##############################################################################
@@ -45,9 +49,9 @@
 #  @param dir  - the install directory under ROOT/share/vpp/api to place the
 #                generated .json file
 ##############################################################################
-function(vpp_generate_api_header file dir)
+function(vpp_generate_api_header file dir component)
     vpp_generate_api_c_header (${file})
-    vpp_generate_api_json_header (${file} ${dir})
+    vpp_generate_api_json_header (${file} ${dir} ${component})
 endfunction()
 
 function(vpp_add_api_files name)
@@ -55,7 +59,7 @@
   set(target ${name}_api_headers)
   file(RELATIVE_PATH rpath ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
   foreach(file ${ARGN})
-    vpp_generate_api_header (${file} core)
+    vpp_generate_api_header (${file} core vpp)
     list(APPEND header_files ${file}.h ${file}.json)
     set_property(GLOBAL APPEND PROPERTY VPP_API_FILES ${rpath}/${file})
   endforeach()
diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake
index cff5e3e..04165ff 100644
--- a/src/cmake/library.cmake
+++ b/src/cmake/library.cmake
@@ -76,6 +76,10 @@
 function (add_vpp_headers path)
   foreach(file ${ARGN})
     get_filename_component(dir ${file} DIRECTORY)
-    install(FILES ${file} DESTINATION include/${path}/${dir})
+    install(
+      FILES ${file}
+      DESTINATION include/${path}/${dir}
+      COMPONENT vpp-dev
+    )
   endforeach()
 endfunction()
diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake
index 9f9a646..c6f551d 100644
--- a/src/cmake/plugin.cmake
+++ b/src/cmake/plugin.cmake
@@ -20,10 +20,13 @@
   )
   set(plugin_name ${name}_plugin)
   set(api_headers)
+  if(NOT PLUGIN_COMPONENT)
+    set(PLUGIN_COMPONENT vpp-plugin-misc)
+  endif()
   file(RELATIVE_PATH rpath ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
   foreach(f ${PLUGIN_API_FILES})
     get_filename_component(dir ${f} DIRECTORY)
-    vpp_generate_api_header(${f} plugins)
+    vpp_generate_api_header(${f} plugins ${PLUGIN_COMPONENT})
     list(APPEND api_headers ${f}.h ${f}.json)
     set_property(GLOBAL APPEND PROPERTY VPP_API_FILES ${rpath}/${f})
     install(
@@ -57,9 +60,6 @@
       )
     endforeach()
   endif()
-  if(NOT PLUGIN_COMPONENT)
-    set(PLUGIN_COMPONENT vpp-plugin-misc)
-  endif()
   if(PLUGIN_API_TEST_SOURCES)
     set(test_plugin_name ${name}_test_plugin)
     add_library(${test_plugin_name} SHARED ${PLUGIN_API_TEST_SOURCES} ${api_headers})
diff --git a/src/tools/vppapigen/CMakeLists.txt b/src/tools/vppapigen/CMakeLists.txt
index 2898f50..0d982fe 100644
--- a/src/tools/vppapigen/CMakeLists.txt
+++ b/src/tools/vppapigen/CMakeLists.txt
@@ -18,6 +18,7 @@
   PERMISSIONS
     OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
     WORLD_READ WORLD_EXECUTE
+  COMPONENT vpp-dev
 )
 
-install(FILES C.py JSON.py DESTINATION share/vpp)
+install(FILES C.py JSON.py DESTINATION share/vpp COMPONENT vpp-dev)
diff --git a/src/vat/CMakeLists.txt b/src/vat/CMakeLists.txt
index feb335c..bc26c3e 100644
--- a/src/vat/CMakeLists.txt
+++ b/src/vat/CMakeLists.txt
@@ -22,7 +22,7 @@
 ##############################################################################
 # vpp_api_test
 ##############################################################################
-add_vpp_executable(vpp_api_test ENABLE_EXPORTS
+add_vpp_executable(vpp_api_test ENABLE_EXPORTS NO_INSTALL
   SOURCES
   api_format.c
   main.c
@@ -41,7 +41,7 @@
 ##############################################################################
 #  vpp_json_test
 ##############################################################################
-add_vpp_executable(vpp_json_test ENABLE_EXPORTS
+add_vpp_executable(vpp_json_test ENABLE_EXPORTS NO_INSTALL
   SOURCES json_format.c json_test.c
   LINK_LIBRARIES vppinfra m
 )
@@ -49,7 +49,11 @@
 ##############################################################################
 # vat headers
 ##############################################################################
-install(FILES vat.h json_format.h DESTINATION include/vat)
+install(
+  FILES vat.h json_format.h
+  DESTINATION include/vat
+  COMPONENT vpp-dev
+)
 
 ##############################################################################
 # restart
diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt
index 59c725f..c3dfba9 100644
--- a/src/vlib/CMakeLists.txt
+++ b/src/vlib/CMakeLists.txt
@@ -19,7 +19,11 @@
   ${CMAKE_SOURCE_DIR}/vlib/config.h.in
   ${CMAKE_BINARY_DIR}/vlib/config.h
 )
-install(FILES ${CMAKE_BINARY_DIR}/vlib/config.h DESTINATION include/vlib)
+install(
+  FILES ${CMAKE_BINARY_DIR}/vlib/config.h
+  DESTINATION include/vlib
+  COMPONENT vpp-dev
+)
 
 ##############################################################################
 # vlib shared library
diff --git a/src/vlibapi/CMakeLists.txt b/src/vlibapi/CMakeLists.txt
index 6c67008..55f87b8 100644
--- a/src/vlibapi/CMakeLists.txt
+++ b/src/vlibapi/CMakeLists.txt
@@ -20,4 +20,6 @@
 
   DESTINATION
   include/vlibapi
+
+  COMPONENT vpp-dev
 )
diff --git a/src/vpp-api/vapi/CMakeLists.txt b/src/vpp-api/vapi/CMakeLists.txt
index abf9ffb..120bfd4 100644
--- a/src/vpp-api/vapi/CMakeLists.txt
+++ b/src/vpp-api/vapi/CMakeLists.txt
@@ -33,7 +33,11 @@
     DEPENDS ${input} vapi_c_gen.py vapi_json_parser.py api_headers
     COMMENT "Generating VAPI C header ${output}"
   )
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION include/vapi)
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/${output}
+    DESTINATION include/vapi
+    COMPONENT vpp-dev
+  )
   list(APPEND VAPICLIENT_API_CPP_HEADERS ${output})
 
   # C++ VAPI Headers
@@ -46,7 +50,11 @@
     DEPENDS ${input} vapi_cpp_gen.py vapi_json_parser.py api_headers
     COMMENT "Generating VAPI C++ header ${output}"
   )
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION include/vapi)
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/${output}
+    DESTINATION include/vapi
+    COMPONENT vpp-dev
+  )
   list(APPEND VAPICLIENT_API_CPP_HEADERS ${output})
 endforeach ()
 
@@ -73,4 +81,5 @@
   vapi_internal.h
 
   DESTINATION include/vapi
+  COMPONENT vpp-dev
 )
diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt
index 78ca867..feb75cf 100644
--- a/src/vpp/CMakeLists.txt
+++ b/src/vpp/CMakeLists.txt
@@ -46,6 +46,7 @@
   install(
     FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
     DESTINATION include/vpp/${dir}
+    COMPONENT vpp-dev
   )
 endforeach()