blob: 3d934f2645940e31984cafc29831bdb66f0e62f1 [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)
Damjan Marion612dd6a2018-07-30 12:45:07 +020064
65##############################################################################
Damjan Marion0abd4a22018-08-28 12:57:29 +020066# subdirs - order matters
Damjan Marion612dd6a2018-07-30 12:45:07 +020067##############################################################################
Damjan Marion0abd4a22018-08-28 12:57:29 +020068foreach(
69 DIR
70 vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins
Mohsin Kazmie04ffa42018-08-28 11:58:20 +020071 vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool
Damjan Marion0abd4a22018-08-28 12:57:29 +020072)
Damjan Marion612dd6a2018-07-30 12:45:07 +020073 add_subdirectory(${DIR})
Damjan Marion0abd4a22018-08-28 12:57:29 +020074endforeach()
Damjan Marion612dd6a2018-07-30 12:45:07 +020075
Damjan Marion43b06062018-08-29 22:20:45 +020076include(cmake/pack.cmake)