Adding support for packages 61/5961/4
authorMauro Sardara <[email protected]>
Thu, 30 Mar 2017 18:52:20 +0000 (20:52 +0200)
committerMauro Sardara <[email protected]>
Thu, 30 Mar 2017 19:01:25 +0000 (21:01 +0200)
Change-Id: Ib6b84855e4f5ec74beda02528f1186faf7387f35
Signed-off-by: Mauro Sardara <[email protected]>
cicn-plugin/CMakeLists.txt
cicn-plugin/cmake/Modules/FindVpp.cmake [new file with mode: 0644]
cicn-plugin/cmake/Modules/FindVppDpdk.cmake [new file with mode: 0644]

index c68a802..6b1f383 100755 (executable)
 
 cmake_minimum_required(VERSION 3.2)
 project(cicn_plugin)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
+
+set(${CMAKE_PROJECT_NAME}_VERSION_MAJOR 1)
+set(${CMAKE_PROJECT_NAME}_VERSION_MINOR 0)
+
+# Dependencies
+
+find_package(Vpp REQUIRED)
+find_package(VppDpdk REQUIRED)
 
 set(CICN_PLUGIN_SOURCE_FILES
-        cicn/cicn.c
-        cicn/cicn_face.c
-        cicn/cicn_fib.c
-        cicn/cicn_hashtb.c
-        cicn/cicn_hello.c
-        cicn/cicn_mgmt.c
-        cicn/cicn_parser.c
-        cicn/cicn_pcs.c
-        cicn/cicn_pg.c
-        cicn/node.c)
+    cicn/cicn.c
+    cicn/cicn_face.c
+    cicn/cicn_fib.c
+    cicn/cicn_hashtb.c
+    cicn/cicn_hello.c
+    cicn/cicn_mgmt.c
+    cicn/cicn_parser.c
+    cicn/cicn_pcs.c
+    cicn/cicn_pg.c
+    cicn/node.c)
 
 set(CICN_PLUGIN_HEADER_FILES
-        cicn/cicn_all_api_h.h
-        cicn/cicn_api_handler.h
-        cicn/cicn_fib.h
-        cicn/cicn_hashtb.h
-        cicn/cicn_hello_inlines.h
-        cicn/cicn_mgmt.h
-        cicn/cicn_params.h
-        cicn/cicn_pcs.h
-        cicn/cicn_rte_mbuf_inlines.h
-        cicn/cicn_std.h
-        cicn/cicn_api.h
-        cicn/cicn_face.h
-        cicn/cicn.h
-        cicn/cicn_hello.h
-        cicn/cicn_infra.h
-        cicn/cicn_msg_enum.h
-        cicn/cicn_parser.h
-        cicn/cicn_rte_mbuf.h
-        cicn/cicn_siphash.h
-        cicn/cicn_types.h)
+    cicn/cicn_all_api_h.h
+    cicn/cicn_api_handler.h
+    cicn/cicn_fib.h
+    cicn/cicn_hashtb.h
+    cicn/cicn_hello_inlines.h
+    cicn/cicn_mgmt.h
+    cicn/cicn_params.h
+    cicn/cicn_pcs.h
+    cicn/cicn_rte_mbuf_inlines.h
+    cicn/cicn_std.h
+    cicn/cicn_api.h
+    cicn/cicn_face.h
+    cicn/cicn.h
+    cicn/cicn_hello.h
+    cicn/cicn_infra.h
+    cicn/cicn_msg_enum.h
+    cicn/cicn_parser.h
+    cicn/cicn_rte_mbuf.h
+    cicn/cicn_siphash.h
+    cicn/cicn_types.h)
 
 if(NOT NO_UNIT_TEST)
     list(APPEND CICN_PLUGIN_SOURCE_FILES
@@ -72,10 +81,11 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cicn/cicn.api.h
         --show-name ${CMAKE_CURRENT_BINARY_DIR}/cicn/cicn.api.h
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cicn/cicn.api)
 
+include_directories(SYSTEM)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(./)
 include_directories(cicn/test)
-include_directories(/usr/include/vpp-dpdk)
+include_directories(${VPP_DPDK_INCLUDE_DIRS})
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=native -O3")
 add_library(cicn_api_test_plugin SHARED
@@ -99,8 +109,8 @@ set_target_properties(cicn_api_test_plugin
 target_link_libraries(cicn_plugin)
 target_link_libraries(cicn_api_test_plugin)
 
-set(VPP_INSTALL_PLUGIN /usr/lib/vpp_plugins)
-set(VPP_INSTALL_API_TEST_PLUGIN /usr/lib/vpp_api_test_plugins)
+set(VPP_INSTALL_PLUGIN ${CMAKE_INSTALL_PREFIX}/lib/vpp_plugins)
+set(VPP_INSTALL_API_TEST_PLUGIN ${CMAKE_INSTALL_PREFIX}/lib/vpp_api_test_plugins)
 
 install(DIRECTORY DESTINATION ${VPP_INSTALL_PLUGIN})
 install(TARGETS cicn_plugin
@@ -111,3 +121,49 @@ install(DIRECTORY DESTINATION ${VPP_INSTALL_API_TEST_PLUGIN})
 install(TARGETS cicn_api_test_plugin
         DESTINATION
         ${VPP_INSTALL_API_TEST_PLUGIN})
+
+# Generate DEB / RPM packages
+
+option(DEB_PACKAGE "Create deb package" OFF)
+option(RPM_PACKAGE "Create deb package" OFF)
+
+SET(VENDOR "Cisco Systems" CACHE STRING "Vendor")
+SET(CONTACT "[email protected]" CACHE STRING "Contact")
+SET(DISTRIBUTION "xenial" CACHE STRING "Distribution")
+SET(ARCHITECTURE "amd64" CACHE STRING "Architecture")
+SET(PACKAGE_MAINTAINER "Mauro Sardara" CACHE STRING "Maintainer")
+SET(PACKAGE_VERSION "1.0" CACHE STRING "Version")
+SET(BUILD_NUMBER "1" CACHE STRING "Build Number")
+STRING(TOLOWER ${CMAKE_PROJECT_NAME} PACKAGE_NAME)
+
+SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
+SET(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
+SET(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
+SET(CPACK_PACKAGE_VENDOR ${VENDOR})
+SET(CPACK_PACKAGE_CONTACT ${CONTACT})
+
+if (DEB_PACKAGE)
+    SET(TYPE "DEBIAN")
+    SET(GENERATOR "DEB")
+    SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}~${DISTRIBUTION}_${ARCHITECTURE}")
+    SET(CPACK_${TYPE}_PACKAGE_REQUIRES "vpp-dev >= 17.01, vpp-dpdk-dev >= 17.01")
+elseif (RPM_PACKAGE)
+    SET(TYPE "RPM")
+    SET(GENERATOR "RPM")
+    SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BUILD_NUMBER}.${DISTRIBUTION}.${ARCHITECTURE}")
+    SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/etc" "/usr/lib/python2.7" "/usr/lib/python2.7/site-packages")
+    SET(CPACK_${TYPE}_PACKAGE_REQUIRES "vpp-devel >= 17.01, vpp-dpdk-devel >= 17.01")
+else ()
+    RETURN()
+endif ()
+
+SET(CPACK_GENERATOR ${GENERATOR})
+SET(CPACK_${TYPE}_PACKAGE_MAINTAINER ${PACKAGE_MAINTAINER})
+SET(CPACK_${TYPE}_PACKAGE_NAME ${PACKAGE_NAME})
+SET(CPACK_${TYPE}_PACKAGE_VERSION ${PACKAGE_VERSION})
+SET(CPACK_${TYPE}_PACKAGE_ARCHITECTURE ${ARCHITECTURE})
+SET(CPACK_${TYPE}_PACKAGE_RELEASE 1)
+SET(CPACK_${TYPE}_PACKAGE_VENDOR ${VENDOR})
+SET(CPACK_${TYPE}_PACKAGE_DESCRIPTION "High-performance CCNx ICN forwarder as a plugin to VPP.")
+
+INCLUDE(CPack)
diff --git a/cicn-plugin/cmake/Modules/FindVpp.cmake b/cicn-plugin/cmake/Modules/FindVpp.cmake
new file mode 100644 (file)
index 0000000..a930a94
--- /dev/null
@@ -0,0 +1,48 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+########################################
+#
+# Find the VPP libraries and includes
+# This module sets:
+#  VPP_FOUND: True if VPP was found
+#  VPP_INCLUDE_DIR:  The VPP include dir
+#
+
+set(VPP_SEARCH_PATH_LIST
+    ${VPP_HOME}
+    $ENV{VPP_HOME}
+    /usr/local
+    /opt
+    /usr)
+
+find_path(VPP_INCLUDE_DIR vpp-api/vpe.api.h
+        HINTS ${VPP_SEARCH_PATH_LIST}
+        PATH_SUFFIXES include
+        DOC "Find the VPP includes")
+
+set(VPP_INCLUDE_DIRS
+   ${VPP_INCLUDE_DIR}
+   ${VPP_INCLUDE_DIR}/vpp-api
+   ${VPP_INCLUDE_DIR}/pneum
+   ${VPP_INCLUDE_DIR}/vlibmemory
+   ${VPP_INCLUDE_DIR}/vat
+   ${VPP_INCLUDE_DIR}/vlibapi
+   ${VPP_INCLUDE_DIR}/jvpp-common
+   ${VPP_INCLUDE_DIR}/vppinfra
+   ${VPP_INCLUDE_DIR}/vnet
+   ${VPP_INCLUDE_DIR}/vlibsocket
+   ${VPP_INCLUDE_DIR}/vlib)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Vpp DEFAULT_MSG VPP_INCLUDE_DIR)
diff --git a/cicn-plugin/cmake/Modules/FindVppDpdk.cmake b/cicn-plugin/cmake/Modules/FindVppDpdk.cmake
new file mode 100644 (file)
index 0000000..5c6bd62
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+########################################
+#
+# Find the VPP libraries and includes
+# This module sets:
+#  VPP_DPDK_FOUND: True if VPP was found
+#  VPP_DPDK_INCLUDE_DIR:  The VPP include dir
+#
+
+set(VPP_DPDK_SEARCH_PATH_LIST
+    ${VPP_DPDK_ROOT}
+    $ENV{VPP_DODK_ROOT}
+    /usr/local
+    /opt
+    /usr)
+
+find_path(VPP_DPDK_INCLUDE_DIR vpp-dpdk/rte_version.h
+        HINTS ${VPP_DPDK_SEARCH_PATH_LIST}
+        PATH_SUFFIXES include
+        DOC "Find the VPP-DPDK includes")
+
+set(VPP_DPDK_INCLUDE_DIRS ${VPP_DPDK_INCLUDE_DIR} ${VPP_DPDK_INCLUDE_DIR}/vpp-dpdk)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(VppDpdk DEFAULT_MSG VPP_DPDK_INCLUDE_DIR)