aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rw-r--r--extras/libmemif/CMakeLists.txt90
-rw-r--r--extras/libmemif/examples/CMakeLists.txt2
-rw-r--r--extras/libmemif/src/CMakeLists.txt21
-rw-r--r--extras/libmemif/test/CMakeLists.txt4
4 files changed, 91 insertions, 26 deletions
diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt
index 263bd18d1df..7f4915b5d70 100644
--- a/extras/libmemif/CMakeLists.txt
+++ b/extras/libmemif/CMakeLists.txt
@@ -19,15 +19,6 @@ set(CMAKE_C_STANDARD 11)
include(CheckCCompilerFlag)
include(CheckFunctionExists)
-set(VPP_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
-execute_process(
- COMMAND find ${VPP_SRC} -type d -name "cmake"
- OUTPUT_VARIABLE CMAKE_DEPS_FOLDER
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-include(${CMAKE_DEPS_FOLDER}/library.cmake)
-include(${CMAKE_DEPS_FOLDER}/pack.cmake)
-
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
@@ -47,7 +38,6 @@ if(${HAVE_MEMFD_CREATE})
endif()
include_directories(src)
-set(LIBMEMIF memif)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Check 0.10.0)
@@ -61,8 +51,80 @@ endif ()
add_subdirectory(src)
add_subdirectory(examples)
-add_vpp_packaging(
- NAME "memif"
- VENDOR "fd.io"
- DESCRIPTION "Shared Memory Interface"
+##############################################################################
+# Packaging
+##############################################################################
+
+# 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 --match v*
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE VER
+ OUTPUT_STRIP_TRAILING_WHITESPACE
)
+string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER})
+list(GET VER 0 tag)
+list(GET VER 1 commit_num)
+list(GET VER 2 commit_name)
+
+#define DEB and RPM version numbers
+if(${commit_num} EQUAL 0)
+ set(deb_ver "${tag}")
+ set(rpm_ver "${tag}")
+else()
+ if (DEFINED ENV{BUILD_NUMBER})
+ set(deb_ver "${tag}~${commit_num}-${commit_name}~b$ENV{BUILD_NUMBER}")
+ set(rpm_ver "${tag}~${commit_num}_${commit_name}~b$ENV{BUILD_NUMBER}")
+ else()
+ set(deb_ver "${tag}~${commit_num}-${commit_name}")
+ set(rpm_ver "${tag}~${commit_num}_${commit_name}")
+ endif()
+endif()
+
+set(CPACK_PACKAGE_NAME "memif")
+set(CPACK_STRIP_FILES OFF)
+set(CPACK_PACKAGE_VENDOR "fd.io")
+set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
+set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON)
+set(CPACK_${type}_PACKAGE_DESCRIPTION "memif Shared Memory Interface")
+set(CPACK_${type}_PACKAGE_RELEASE 1)
+
+if(OS_ID_LIKE MATCHES "debian")
+ set(CPACK_GENERATOR "DEB")
+ set(type "DEBIAN")
+ set(CPACK_PACKAGE_VERSION "${deb_ver}")
+ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPP Team")
+ execute_process(
+ COMMAND dpkg --print-architecture
+ OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
+elseif(OS_ID_LIKE MATCHES "rhel")
+ set(CPACK_GENERATOR "RPM")
+ set(type "RPM")
+ set(CPACK_PACKAGE_VERSION "${rpm_ver}")
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE})
+endif()
+
+if(CPACK_GENERATOR)
+ include(CPack)
+else()
+ message(ERROR "CPACK_GENERATOR must be set")
+endif()
+
diff --git a/extras/libmemif/examples/CMakeLists.txt b/extras/libmemif/examples/CMakeLists.txt
index 1cf50002b8a..4f120e59f75 100644
--- a/extras/libmemif/examples/CMakeLists.txt
+++ b/extras/libmemif/examples/CMakeLists.txt
@@ -32,5 +32,5 @@ foreach (EXAMPLE_SRC ${EXAMPLES_LIST})
string(SUBSTRING ${EXAMPLE_SRC} 0 ${INDEX} EXECUTABLE)
add_executable(${EXECUTABLE} ${COMMON_SOURCE_FILES} ${EXAMPLE_SRC})
target_include_directories(${EXECUTABLE} PRIVATE $<BUILD_INTERFACE:${HEADERS_DIR}>)
- target_link_libraries(${EXECUTABLE} ${LIBMEMIF} ${CMAKE_THREAD_LIBS_INIT})
+ target_link_libraries(${EXECUTABLE} memif ${CMAKE_THREAD_LIBS_INIT})
endforeach()
diff --git a/extras/libmemif/src/CMakeLists.txt b/extras/libmemif/src/CMakeLists.txt
index 09a2e4e6005..aced550ff5d 100644
--- a/extras/libmemif/src/CMakeLists.txt
+++ b/extras/libmemif/src/CMakeLists.txt
@@ -32,12 +32,15 @@ list(APPEND MEMIF_SOURCES
include_directories(${HEADERS_DIR})
-add_vpp_library(${LIBMEMIF}
- SOURCES ${MEMIF_SOURCES}
-
- INSTALL_HEADERS ${MEMIF_HEADERS}
-
- LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
-
- COMPONENT libmemif
-)
+add_library(memif SHARED ${MEMIF_SOURCES})
+target_link_libraries(memif ${CMAKE_THREAD_LIBS_INIT})
+foreach(file ${MEMIF_HEADERS})
+ get_filename_component(dir ${file} DIRECTORY)
+ install(
+ FILES ${file}
+ DESTINATION include/${lib}/${dir}
+ COMPONENT libmemif-dev
+ )
+endforeach()
+
+install(TARGETS memif DESTINATION lib COMPONENT libmemif)
diff --git a/extras/libmemif/test/CMakeLists.txt b/extras/libmemif/test/CMakeLists.txt
index 3681fd3e64b..79754a2f8b7 100644
--- a/extras/libmemif/test/CMakeLists.txt
+++ b/extras/libmemif/test/CMakeLists.txt
@@ -30,6 +30,6 @@ set(SOURCE_FILES
add_executable(${TEST_NAME} ${SOURCE_FILES})
target_include_directories(${TEST_NAME} PRIVATE $<BUILD_INTERFACE:${HEADERS_DIR}>)
-target_link_libraries(${TEST_NAME} ${LIBMEMIF} ${CHECK_LIBRARY} ${SUBUNIT_LIBRARY} ${TEST_LIBS} ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${TEST_NAME} memif ${CHECK_LIBRARY} ${SUBUNIT_LIBRARY} ${TEST_LIBS} ${CMAKE_THREAD_LIBS_INIT})
-add_test(unit_test unit-test) \ No newline at end of file
+add_test(unit_test unit-test)