Type: improvement
Change-Id: I0e24f1d2ad5c7a11a8bd40125428f86aca867bec
Signed-off-by: Damjan Marion <damarion@cisco.com>
# See the License for the specific language governing permissions and
# limitations under the License.
# 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)
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)
include(cmake/misc.cmake)
include(cmake/cpu.cmake)
include(cmake/ccache.cmake)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
HELPSTRING "Build type - valid options are: ${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
##############################################################################
##############################################################################
# sanitizers
##############################################################################
macro(add_vpp_library lib)
cmake_parse_arguments(ARG
macro(add_vpp_library lib)
cmake_parse_arguments(ARG
"COMPONENT"
"SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS"
${ARGN}
"COMPONENT"
"SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS"
${ARGN}
COMPONENT ${ARG_COMPONENT}
)
COMPONENT ${ARG_COMPONENT}
)
+ if (ARG_LTO AND VPP_USE_LTO)
+ set_property(TARGET ${lib} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ target_compile_options (${lib} PRIVATE "-ffunction-sections")
+ target_compile_options (${lib} PRIVATE "-fdata-sections")
+ target_link_libraries (${lib} "-Wl,--gc-sections")
+ endif()
+
if(ARG_MULTIARCH_SOURCES)
vpp_library_set_multiarch_sources(${lib} "${ARG_DEPENDS}" ${ARG_MULTIARCH_SOURCES})
endif()
if(ARG_MULTIARCH_SOURCES)
vpp_library_set_multiarch_sources(${lib} "${ARG_DEPENDS}" ${ARG_MULTIARCH_SOURCES})
endif()
LINK_LIBRARIES m
INSTALL_HEADERS ${VPPINFRA_HEADERS}
COMPONENT libvppinfra
LINK_LIBRARIES m
INSTALL_HEADERS ${VPPINFRA_HEADERS}
COMPONENT libvppinfra
)
##############################################################################
)
##############################################################################