Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 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: |
| 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 | |
| 14 | cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
| 15 | |
| 16 | project(vpp C) |
| 17 | |
| 18 | include(CheckCCompilerFlag) |
| 19 | |
Damjan Marion | d16004d | 2018-08-26 10:14:52 +0200 | [diff] [blame] | 20 | include(cmake/message.cmake) |
| 21 | include(cmake/cpu.cmake) |
| 22 | include(cmake/ccache.cmake) |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 23 | |
| 24 | ############################################################################## |
| 25 | # build config |
| 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}") |
| 32 | |
Damjan Marion | 33ed3e4 | 2018-08-27 15:59:30 +0200 | [diff] [blame] | 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) |
| 36 | endif() |
| 37 | |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 38 | ############################################################################## |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 39 | # install config |
| 40 | ############################################################################## |
Neale Ranns | 917dc3b | 2018-08-27 08:35:25 -0400 | [diff] [blame] | 41 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIB_DIR_NAME}") |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 42 | set(CMAKE_INSTALL_MESSAGE NEVER) |
| 43 | |
| 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}") |
| 47 | |
| 48 | include_directories ( |
| 49 | ${CMAKE_SOURCE_DIR} |
| 50 | ${CMAKE_BINARY_DIR} |
| 51 | ${CMAKE_BINARY_DIR}/include |
| 52 | ) |
| 53 | set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp") |
| 54 | |
| 55 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 56 | find_package(Threads REQUIRED) |
| 57 | find_package(OpenSSL REQUIRED) |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 58 | |
Damjan Marion | d16004d | 2018-08-26 10:14:52 +0200 | [diff] [blame] | 59 | include(cmake/memfd.cmake) |
| 60 | include(cmake/api.cmake) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 61 | include(cmake/library.cmake) |
| 62 | include(cmake/exec.cmake) |
Damjan Marion | d16004d | 2018-08-26 10:14:52 +0200 | [diff] [blame] | 63 | include(cmake/plugin.cmake) |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 64 | |
| 65 | ############################################################################## |
Damjan Marion | 0abd4a2 | 2018-08-28 12:57:29 +0200 | [diff] [blame] | 66 | # subdirs - order matters |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 67 | ############################################################################## |
Damjan Marion | 0abd4a2 | 2018-08-28 12:57:29 +0200 | [diff] [blame] | 68 | foreach( |
| 69 | DIR |
| 70 | vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins |
Mohsin Kazmi | e04ffa4 | 2018-08-28 11:58:20 +0200 | [diff] [blame] | 71 | vpp-api tools/vppapigen tools/g2 tools/elftool tools/perftool |
Damjan Marion | 0abd4a2 | 2018-08-28 12:57:29 +0200 | [diff] [blame] | 72 | ) |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 73 | add_subdirectory(${DIR}) |
Damjan Marion | 0abd4a2 | 2018-08-28 12:57:29 +0200 | [diff] [blame] | 74 | endforeach() |
Damjan Marion | 612dd6a | 2018-07-30 12:45:07 +0200 | [diff] [blame] | 75 | |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 76 | include(cmake/pack.cmake) |