X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2FCMakeLists.txt;h=eb598784cb8521ba3d9ea3a0be7c8b9227032e94;hb=5c97dbfdb24a91440910891ed347f9fcd2454b34;hp=499a39fbad494efaee356b356f06a58447a060c6;hpb=cea46522e79637f6ec37c03ec3fbeb87b160a378;p=vpp.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 499a39fbad4..eb598784cb8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,13 +11,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) - -set(CMAKE_C_COMPILER_NAMES clang-10 clang-9 gcc-9 cc) +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_C_COMPILER_NAMES + clang-12 + 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 +78,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 +90,6 @@ string(CONCAT CMAKE_C_FLAGS_DEBUG "-O0 " "-DCLIB_DEBUG " "-fstack-protector " - "-DFORTIFY_SOURCE=2 " "-fno-common " ) @@ -105,6 +113,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 +143,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 +174,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 )