1 # Copyright (c) 2018 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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
18 include(CheckCCompilerFlag)
20 include(cmake/message.cmake)
21 include(cmake/cpu.cmake)
22 include(cmake/ccache.cmake)
24 ##############################################################################
26 ##############################################################################
27 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
28 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
29 set(CMAKE_C_FLAGS_COMMON "-DFORTIFY_SOURCE=2 -fstack-protector-all -Werror")
30 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_COMMON} -DCLIB_DEBUG")
31 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_COMMON}")
33 check_c_compiler_flag("-Wno-address-of-packed-member" compiler_flag_no_address_of_packed_member)
34 if (compiler_flag_no_address_of_packed_member)
35 add_definitions(-Wno-address-of-packed-member)
38 ##############################################################################
40 ##############################################################################
41 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIB_DIR_NAME}")
42 set(CMAKE_INSTALL_MESSAGE NEVER)
44 message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
45 message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")
46 message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
51 ${CMAKE_BINARY_DIR}/include
53 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")
55 set(THREADS_PREFER_PTHREAD_FLAG ON)
56 find_package(Threads REQUIRED)
57 find_package(OpenSSL REQUIRED)
59 include(cmake/memfd.cmake)
60 include(cmake/api.cmake)
61 include(cmake/library.cmake)
62 include(cmake/exec.cmake)
63 include(cmake/plugin.cmake)
64 include(cmake/deb.cmake)
66 ##############################################################################
67 # subdirs - order matters
68 ##############################################################################
71 vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins
72 vpp-api tools/vppapigen tools/g2 tools/elftool
74 add_subdirectory(${DIR})