blob: 263bd18d1df0b7a191ec2c751aa9aa0804afca57 [file] [log] [blame]
msardara8f554b72018-12-11 18:36:55 +01001# Copyright (c) 2017 Cisco and/or its affiliates.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at:
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
15
16project(memif)
17set(CMAKE_C_STANDARD 11)
18
19include(CheckCCompilerFlag)
20include(CheckFunctionExists)
21
22set(VPP_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
23execute_process(
24 COMMAND find ${VPP_SRC} -type d -name "cmake"
25 OUTPUT_VARIABLE CMAKE_DEPS_FOLDER
26 OUTPUT_STRIP_TRAILING_WHITESPACE
27)
28include(${CMAKE_DEPS_FOLDER}/library.cmake)
29include(${CMAKE_DEPS_FOLDER}/pack.cmake)
30
31if (NOT CMAKE_BUILD_TYPE)
32 message(STATUS "No build type selected, default to Release")
33 set(CMAKE_BUILD_TYPE "Release")
34endif ()
35
36set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -DMEMIF_DBG -DICMP_DBG")
37set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
38set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
39set(CMAKE_INSTALL_MESSAGE NEVER)
40
41find_package(Threads REQUIRED)
42include_directories(${CMAKE_THREADS_INCLUDE_DIRS})
43
44check_function_exists(memfd_create HAVE_MEMFD_CREATE)
45if(${HAVE_MEMFD_CREATE})
46 add_definitions(-DHAVE_MEMFD_CREATE)
47endif()
48
49include_directories(src)
50set(LIBMEMIF memif)
51
52set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
53find_package(Check 0.10.0)
54if (CHECK_FOUND)
55 include_directories(${CHECK_INCLUDE_DIR})
56 add_definitions(-DMEMIF_UNIT_TEST)
57 add_subdirectory(test)
58 enable_testing()
59endif ()
60
61add_subdirectory(src)
62add_subdirectory(examples)
63
64add_vpp_packaging(
65 NAME "memif"
66 VENDOR "fd.io"
67 DESCRIPTION "Shared Memory Interface"
68)