blob: 42e3a1cbf7492f05d6404299a91396aec4c5221a [file] [log] [blame]
Damjan Marion612dd6a2018-07-30 12:45:07 +02001# 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:
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(vpp C)
17
18include(CheckCCompilerFlag)
19
Damjan Mariond16004d2018-08-26 10:14:52 +020020include(cmake/message.cmake)
21include(cmake/cpu.cmake)
22include(cmake/ccache.cmake)
Damjan Marion612dd6a2018-07-30 12:45:07 +020023
24##############################################################################
25# build config
26##############################################################################
27set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
28set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
29set(CMAKE_C_FLAGS_COMMON "-DFORTIFY_SOURCE=2 -fstack-protector-all -Werror")
30set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_COMMON} -DCLIB_DEBUG")
31set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_COMMON}")
32
Damjan Marion33ed3e42018-08-27 15:59:30 +020033check_c_compiler_flag("-Wno-address-of-packed-member" compiler_flag_no_address_of_packed_member)
34if (compiler_flag_no_address_of_packed_member)
35 add_definitions(-Wno-address-of-packed-member)
36endif()
37
Damjan Marion612dd6a2018-07-30 12:45:07 +020038##############################################################################
Damjan Marion612dd6a2018-07-30 12:45:07 +020039# install config
40##############################################################################
Neale Ranns917dc3b2018-08-27 08:35:25 -040041set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIB_DIR_NAME}")
Damjan Marion612dd6a2018-07-30 12:45:07 +020042set(CMAKE_INSTALL_MESSAGE NEVER)
43
44message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
45message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")
46message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
47
48include_directories (
49 ${CMAKE_SOURCE_DIR}
50 ${CMAKE_BINARY_DIR}
51 ${CMAKE_BINARY_DIR}/include
52)
53set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")
54
55set(THREADS_PREFER_PTHREAD_FLAG ON)
56find_package(Threads REQUIRED)
57find_package(OpenSSL REQUIRED)
Damjan Marion612dd6a2018-07-30 12:45:07 +020058
Damjan Mariond16004d2018-08-26 10:14:52 +020059include(cmake/memfd.cmake)
60include(cmake/api.cmake)
Damjan Marion4553c952018-08-26 11:04:40 +020061include(cmake/library.cmake)
62include(cmake/exec.cmake)
Damjan Mariond16004d2018-08-26 10:14:52 +020063include(cmake/plugin.cmake)
64include(cmake/deb.cmake)
Damjan Marion612dd6a2018-07-30 12:45:07 +020065
66##############################################################################
Damjan Marion0abd4a22018-08-28 12:57:29 +020067# subdirs - order matters
Damjan Marion612dd6a2018-07-30 12:45:07 +020068##############################################################################
Damjan Marion0abd4a22018-08-28 12:57:29 +020069foreach(
70 DIR
71 vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins
72 vpp-api tools/vppapigen
73)
Damjan Marion612dd6a2018-07-30 12:45:07 +020074 add_subdirectory(${DIR})
Damjan Marion0abd4a22018-08-28 12:57:29 +020075endforeach()
Damjan Marion612dd6a2018-07-30 12:45:07 +020076