X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2FCMakeLists.txt;h=4d66671edc550e590480c3b77761d95fea1db87d;hb=30ad571cc35e4dc6d4d7e50b81b97f83f8770eea;hp=0d971fd8ebc261e2ea1ed459568e6b7b6d20db29;hpb=8c6988797e2a5d6da87fa73fee833ff3776b156b;p=vpp.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d971fd8ebc..4d66671edc5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,13 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) +cmake_minimum_required(VERSION 3.10) set(CMAKE_C_COMPILER_NAMES clang-11 clang-10 clang-9 gcc-10 gcc-9 cc) project(vpp C) include(CheckCCompilerFlag) +include(CheckIPOSupported) include(cmake/misc.cmake) include(cmake/cpu.cmake) include(cmake/ccache.cmake) @@ -69,7 +70,7 @@ list(APPEND BUILD_TYPES "release") string(CONCAT CMAKE_C_FLAGS_RELEASE "-O2 " "-fstack-protector " - "-DFORTIFY_SOURCE=2 " + "-D_FORTIFY_SOURCE=2 " "-fno-common " ) @@ -81,7 +82,6 @@ string(CONCAT CMAKE_C_FLAGS_DEBUG "-O0 " "-DCLIB_DEBUG " "-fstack-protector " - "-DFORTIFY_SOURCE=2 " "-fno-common " ) @@ -105,6 +105,16 @@ string(REPLACE ";" " " BUILD_TYPES "${BUILD_TYPES}") set_property(CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING "Build type - valid options are: ${BUILD_TYPES}") +############################################################################## +# link time optimizations +############################################################################## +if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE") + check_ipo_supported(RESULT _result) + if (_result) + option(VPP_USE_LTO "Link time optimization of release binaries" ON) + endif() +endif() + ############################################################################## # sanitizers ############################################################################## @@ -125,7 +135,10 @@ endif (VPP_ENABLE_SANITIZE_ADDR) ############################################################################## # install config ############################################################################## -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +option(VPP_SET_RPATH "Set rpath for resulting binaries and libraries." ON) +if(VPP_SET_RPATH) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif() set(CMAKE_INSTALL_MESSAGE NEVER) include_directories ( @@ -153,7 +166,7 @@ if(VPP_HOST_TOOLS_ONLY) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") find_package(OpenSSL REQUIRED) set(SUBDIRS - vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vcl plugins + vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vat2 vcl plugins vpp-api tools/vppapigen tools/g2 tools/perftool cmake pkg tools/appimage )