aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJunfeng Wang <drenfong.wang@intel.com>2019-09-06 07:10:24 -0400
committerJunfeng Wang <drenfong.wang@intel.com>2019-09-06 07:10:24 -0400
commit4b0f20eed87e8b1542f991e06f4868b05f36dd64 (patch)
treeda80c4496bb79ac62ec0a7e7d7e1ab4ebfdaa0ab /cmake
parentc7a8d969d2830a6fa69d6e3c5d49ab8f33ae9a87 (diff)
add source code
Change-Id: I70aa9a0e05bbb5f38b2d6fb74c9d21db356dc889 Signed-off-by: Junfeng Wang <drenfong.wang@intel.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindVPP.cmake209
-rw-r--r--cmake/Packager.cmake151
2 files changed, 360 insertions, 0 deletions
diff --git a/cmake/FindVPP.cmake b/cmake/FindVPP.cmake
new file mode 100644
index 0000000..56ab482
--- /dev/null
+++ b/cmake/FindVPP.cmake
@@ -0,0 +1,209 @@
+#
+# Copyright (c) 2018 PANTHEON.tech.
+#
+# 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.
+
+
+# - Try to find LibVPP
+# Once done this will define
+#
+# VPP_FOUND - system has VPP
+# VPP_INCLUDE_DIRS - the VPP include directory
+# VPP_LIBRARIES - Link these to use LibSSH
+
+
+if (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
+ # in cache already
+ set(VPP_FOUND TRUE)
+else (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
+
+ set(VPP_INCLUDE_PATH
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+ set(VPP_LIBRARY_PATH
+ /usr/lib
+ /usr/lib64
+ /usr/local/lib
+ /usr/local/lib64
+ /opt/local/lib
+ /sw/lib
+ )
+
+ find_path(VNET_INCLUDE_DIR
+ NAMES
+ vnet/vnet.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+
+ )
+
+ find_path(VLIB_API_INCLUDE_DIR
+ NAMES
+ vlibapi/api.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VLIBMEMORY_INCLUDE_DIR
+ NAMES
+ vlibmemory/api.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VPP_MSG_INCLUDE_DIR
+ NAMES
+ vpp/api/vpe_msg_enum.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VPP_ALL_INCLUDE_DIR
+ NAMES
+ vpp/api/vpe_all_api_h.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VAPI_INCLUDE_DIR
+ NAMES
+ vapi/interface.api.vapi.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VOM_INCLUDE_DIR
+ NAMES
+ vom/om.hpp
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_library(VLIBMEMORYCLIENT_LIBRARY
+ NAMES
+ vlibmemoryclient
+ libvlibmemoryclient
+ PATHS
+ ${VPP_LIBARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(SVM_LIBRARY
+ NAMES
+ svm
+ libsvm
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VPPINFRA_LIBRARY
+ NAMES
+ vppinfra
+ libvppinfra
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VLIB_LIBRARY
+ NAMES
+ vlib
+ libvlib
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VATPLUGIN_LIBRARY
+ NAMES
+ vatplugin
+ libvatplugin
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VAPI_LIBRARY
+ NAMES
+ vapiclient
+ libvapiclient
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VOM_LIBRARY
+ NAMES
+ vom
+ libvom
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ if (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+ set(VPP_FOUND TRUE)
+ else (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+ set(VPP_FOUND FALSE)
+ endif (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+
+ set(VPP_INCLUDE_DIRS
+ ${VNET_INCLUDE_DIR}
+ ${VLIB_API_INCLUDE_DIR}
+ ${VLIB_MEMORY_INCLUDE_DIR}
+ ${VPP_MSG_INCLUDE_DIR}
+ ${VPP_ALL_INCLUDE_DIR}
+ ${VAPI_INCLUDE_DIR}
+ ${VOM_INCLUDE_DIR}
+ )
+
+ set(VPP_LIBRARIES
+ ${VLIBMEMORYCLIENT_LIBRARY}
+ ${SVM_LIBRARY}
+ ${VPPINFRA_LIBRARY}
+ ${VLIB_LIBRARY}
+ ${VATPLUGIN_LIBRARY}
+ ${VAPI_LIBRARY}
+ ${VOM_LIBRARY}
+ )
+
+ # show the VPP_INCLUDE_DIRS and VPP_LIBRARIES variables only in the advanced view
+ mark_as_advanced(VPP_INCLUDE_DIRS VPP_LIBRARIES)
+
+endif (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
diff --git a/cmake/Packager.cmake b/cmake/Packager.cmake
new file mode 100644
index 0000000..b049819
--- /dev/null
+++ b/cmake/Packager.cmake
@@ -0,0 +1,151 @@
+# Copyright (c) 2017-2019 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.
+
+#############
+# RPM/DEB/TGZ Packaging utils
+#
+
+set(CONTACT "udpi-dev@lists.fd.io" CACHE STRING "Contact")
+set(PACKAGE_MAINTAINER "Udpi Team" CACHE STRING "Maintainer")
+set(PACKAGE_VENDOR "fd.io" CACHE STRING "Vendor")
+
+# macro(set)
+
+macro(make_packages)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ # parse /etc/os-release
+ file(READ "/etc/os-release" os_version)
+ string(REPLACE "\n" ";" os_version ${os_version})
+ foreach(_ver ${os_version})
+ string(REPLACE "=" ";" _ver ${_ver})
+ list(GET _ver 0 _name)
+ list(GET _ver 1 _value)
+ set(OS_${_name} ${_value})
+ endforeach()
+
+ #extract version from git
+ execute_process(
+ COMMAND git describe --long --tags
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE VER
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ if (NOT VER)
+ set(VER "v1.0")
+ endif()
+
+ string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER})
+ list(GET VER 0 tag)
+ string(REPLACE "-" "~" tag ${tag})
+ list(GET VER 1 commit_num)
+ list(GET VER 2 commit_name)
+
+ message("${tag}")
+
+ if (NOT DEFINED ENV{BUILD_NUMBER})
+ set(bld "b1")
+ else()
+ set(bld "b$ENV{BUILD_NUMBER}")
+ endif()
+
+ message("Build number is: ${bld}")
+
+ #define DEB and RPM version numbers
+ if(${commit_num} EQUAL 0)
+ set(deb_ver "${tag}")
+ set(rpm_ver "${tag}")
+ else()
+ set(deb_ver "${tag}-${commit_num}-${commit_name}")
+ set(rpm_ver "${tag}-${commit_num}-${commit_name}")
+ endif()
+
+ get_cmake_property(components COMPONENTS)
+
+ if(OS_ID_LIKE MATCHES "debian")
+ set(CPACK_GENERATOR "DEB")
+ set(type "DEBIAN")
+
+ execute_process(
+ COMMAND dpkg --print-architecture
+ OUTPUT_VARIABLE arch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ set(CPACK_PACKAGE_VERSION "${deb_ver}")
+ foreach(lc ${components})
+ if (${lc} MATCHES ".*Unspecified.*")
+ continue()
+ endif()
+
+ string(TOUPPER ${lc} uc)
+ set(CPACK_${type}_${uc}_FILE_NAME "${lc}_${deb_ver}_${arch}.deb")
+
+ set(DEB_DEPS)
+ if (NOT ${${lc}_DEB_DEPENDENCIES} STREQUAL "")
+ string(REPLACE "stable_version" ${tag} DEB_DEPS ${${lc}_DEB_DEPENDENCIES})
+ endif()
+
+ set(CPACK_${type}_${uc}_PACKAGE_DEPENDS "${DEB_DEPS}")
+ set(CPACK_${type}_${uc}_PACKAGE_NAME "${lc}")
+ set(CPACK_COMPONENT_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}")
+ endforeach()
+ elseif(OS_ID_LIKE MATCHES "rhel")
+ set(CPACK_GENERATOR "RPM")
+ set(type "RPM")
+
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE arch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ set(CPACK_PACKAGE_VERSION "${rpm_ver}")
+ foreach(lc ${components})
+ if (${lc} MATCHES ".*Unspecified.*")
+ continue()
+ endif()
+
+ string(TOUPPER ${lc} uc)
+ set(CPACK_${type}_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}")
+
+ set(RPM_DEPS)
+ if (NOT ${${lc}_DEB_DEPENDENCIES} STREQUAL "")
+ string(REPLACE "stable_version" ${tag} RPM_DEPS ${${lc}_RPM_DEPENDENCIES})
+ endif()
+
+ set(CPACK_${type}_${uc}_PACKAGE_REQUIRES "${RPM_DEPS}")
+
+ if(${lc} MATCHES ".*-dev")
+ set(package_name ${lc}el)
+ else()
+ set(package_name ${lc})
+ endif()
+
+ set(CPACK_RPM_${uc}_PACKAGE_NAME "${package_name}")
+ set(CPACK_${type}_${uc}_FILE_NAME "${package_name}-${rpm_ver}.${arch}.rpm")
+ endforeach()
+ endif()
+
+ if(CPACK_GENERATOR)
+ set(CPACK_PACKAGE_NAME ${ARG_NAME})
+ set(CPACK_STRIP_FILES OFF)
+ set(CPACK_PACKAGE_VENDOR "${PACKAGE_VENDOR}")
+ set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
+ set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON)
+ set(CPACK_${type}_PACKAGE_MAINTAINER "Udpi Team")
+ set(CPACK_${type}_PACKAGE_RELEASE 1)
+ include(CPack)
+ endif()
+ endif()
+endmacro()