build: use cmake build types
Type: make Change-Id: If822c85d6ff26982516ea1d597ca81aa84773b2b Signed-off-by: Damjan Marion <damarion@cisco.com> (cherry picked from commit 2baa115da3b752cd7e44cc477f2c45bda22d444b)
This commit is contained in:
Damjan Marion
committed by
Dave Wallace
parent
5381da1dc6
commit
74331c935f
@ -25,10 +25,7 @@ vpp_cmake_prefix_path := $(subst $() $(),;,$(vpp_cmake_prefix_path))
|
||||
|
||||
vpp_cmake_args ?=
|
||||
vpp_cmake_args += -DCMAKE_INSTALL_PREFIX:PATH=$(PACKAGE_INSTALL_DIR)
|
||||
vpp_cmake_args += -DCMAKE_C_FLAGS="$($(TAG)_TAG_CFLAGS)"
|
||||
vpp_cmake_args += -DCMAKE_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
|
||||
vpp_cmake_args += -DCMAKE_EXE_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
|
||||
vpp_cmake_args += -DCMAKE_SHARED_LINKER_FLAGS="$($(TAG)_TAG_LDFLAGS)"
|
||||
vpp_cmake_args += -DCMAKE_BUILD_TYPE="$($(TAG)_TAG_BUILD_TYPE)"
|
||||
vpp_cmake_args += -DCMAKE_PREFIX_PATH:PATH="$(vpp_cmake_prefix_path)"
|
||||
ifeq ("$(V)","1")
|
||||
vpp_cmake_args += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
|
||||
|
@ -22,29 +22,8 @@ endif
|
||||
|
||||
vpp_root_packages = vpp vom
|
||||
|
||||
vpp_common_cflags = \
|
||||
-g \
|
||||
-DFORTIFY_SOURCE=2 \
|
||||
-fstack-protector \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-fno-common
|
||||
|
||||
vpp_debug_TAG_CFLAGS = -O0 -DCLIB_DEBUG $(vpp_common_cflags)
|
||||
vpp_debug_TAG_CXXFLAGS = -O0 -DCLIB_DEBUG $(vpp_common_cflags)
|
||||
vpp_debug_TAG_LDFLAGS = -O0 -DCLIB_DEBUG $(vpp_common_cflags)
|
||||
|
||||
vpp_TAG_CFLAGS = -O2 $(vpp_common_cflags)
|
||||
vpp_TAG_CXXFLAGS = -O2 $(vpp_common_cflags)
|
||||
vpp_TAG_LDFLAGS = -O2 $(vpp_common_cflags) -pie
|
||||
|
||||
vpp_clang_TAG_CFLAGS = -O2 $(vpp_common_cflags)
|
||||
vpp_clang_TAG_CXXFLAGS = -O2 $(vpp_common_cflags)
|
||||
vpp_clang_TAG_LDFLAGS = -O2 $(vpp_common_cflags)
|
||||
|
||||
vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DCLIB_GCOV -fPIC -Werror -fprofile-arcs -ftest-coverage
|
||||
vpp_gcov_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DCLIB_GCOV -fPIC -Werror -coverage
|
||||
|
||||
vpp_coverity_TAG_CFLAGS = -g -O2 -fPIC -Werror -D__COVERITY__
|
||||
vpp_coverity_TAG_LDFLAGS = -g -O2 -fPIC -Werror -D__COVERITY__
|
||||
vpp_debug_TAG_BUILD_TYPE = debug
|
||||
vpp_TAG_BUILD_TYPE = release
|
||||
vpp_clang_TAG_BUILD_TYPE = release
|
||||
vpp_gcov_TAG_BUILD_TYPE = gcov
|
||||
vpp_coverity_TAG_BUILD_TYPE = coverity
|
||||
|
@ -53,19 +53,43 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
if (CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_C_FLAGS "-g -fPIC ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "-fstack-protector-all ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "-Werror ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "-DFORTIFY_SOURCE=2 ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "-g -fPIC -Werror -Wall ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
|
||||
if (compiler_flag_no_address_of_packed_member)
|
||||
set(CMAKE_C_FLAGS "-Wno-address-of-packed-member ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O2 ${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -DCLIB_DEBUG ${CMAKE_C_FLAGS_DEBUG}")
|
||||
set(CMAKE_LINKER_FLAGS_RELEASE "-pie -Wl,-z,now ${CMAKE_LINKER_FLAGS_RELEASE}")
|
||||
# release
|
||||
string(CONCAT CMAKE_C_FLAGS_RELEASE
|
||||
"-O2 "
|
||||
"-fstack-protector "
|
||||
"-DFORTIFY_SOURCE=2 "
|
||||
"-fno-common "
|
||||
)
|
||||
|
||||
string(CONCAT CMAKE_EXE_LINKER_FLAGS_RELEASE "-pie")
|
||||
|
||||
# debug
|
||||
string(CONCAT CMAKE_C_FLAGS_DEBUG
|
||||
"-O0 "
|
||||
"-DCLIB_DEBUG "
|
||||
"-fstack-protector "
|
||||
"-DFORTIFY_SOURCE=2 "
|
||||
"-fno-common "
|
||||
)
|
||||
|
||||
# coverity
|
||||
string(CONCAT CMAKE_C_FLAGS_COVERITY "-O2 -D__COVERITY__")
|
||||
|
||||
# gcov
|
||||
string(CONCAT CMAKE_C_FLAGS_GCOV
|
||||
"-O0 "
|
||||
"-DCLIB_DEBUG "
|
||||
"-DCLIB_GCOV "
|
||||
"-fprofile-arcs "
|
||||
"-ftest-coverage ")
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UC)
|
||||
|
||||
##############################################################################
|
||||
@ -137,7 +161,8 @@ pr("VPP library version" "${VPP_LIB_VERSION}")
|
||||
pr("GIT toplevel dir" "${VPP_GIT_TOPLEVEL_DIR}")
|
||||
pr("Build type" "${CMAKE_BUILD_TYPE}")
|
||||
pr("C flags" "${CMAKE_C_FLAGS}${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
||||
pr("Linker flags" "${CMAKE_LINKER_FLAGS}${CMAKE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
||||
pr("Linker flags (apps)" "${CMAKE_EXE_LINKER_FLAGS}${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
||||
pr("Linker flags (libs)" "${CMAKE_SHARED_LINKER_FLAGS}${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
||||
pr("Host processor" "${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
pr("Target processor" "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
pr("Prefix path" "${CMAKE_PREFIX_PATH}")
|
||||
|
Reference in New Issue
Block a user