diff options
author | Damjan Marion <damarion@cisco.com> | 2019-01-17 18:25:11 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-01-18 22:33:26 +0000 |
commit | 847d52882580378a5180e3d05a32249eef6da02e (patch) | |
tree | 45f4f68be1790b82610f9f763ac29acb352c7fa3 | |
parent | 64911369ad6605ac234a1c843359586c3adc078d (diff) |
cmake: print all flags
Change-Id: Ie80ed430d8c9e2b8fe736402d357ac8b190ca6b7
Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r-- | src/CMakeLists.txt | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 59da1fef1b8..09d132ad2ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,17 +46,28 @@ set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) ############################################################################## # build config ############################################################################## +check_c_compiler_flag("-Wno-address-of-packed-member" + compiler_flag_no_address_of_packed_member) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_C_FLAGS_COMMON "-DFORTIFY_SOURCE=2 -fstack-protector-all -Werror") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_COMMON} -DCLIB_DEBUG") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_COMMON}") -check_c_compiler_flag("-Wno-address-of-packed-member" compiler_flag_no_address_of_packed_member) +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}") +endif() + if (compiler_flag_no_address_of_packed_member) - add_definitions(-Wno-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}") +string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UC) + ############################################################################## # install config ############################################################################## @@ -132,11 +143,11 @@ message(STATUS "Configuration:") pr("VPP version" "${VPP_VERSION}") pr("VPP library version" "${VPP_LIB_VERSION}") pr("GIT toplevel dir" "${VPP_GIT_TOPLEVEL_DIR}") -pr("C flags" "${CMAKE_C_FLAGS}") -pr("Linker flags" "${CMAKE_LINKER_FLAGS}") +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("Host processor" "${CMAKE_HOST_SYSTEM_PROCESSOR}") pr("Target processor" "${CMAKE_SYSTEM_PROCESSOR}") -pr("Build type" "${CMAKE_BUILD_TYPE}") pr("Prefix path" "${CMAKE_PREFIX_PATH}") pr("Install prefix" "${CMAKE_INSTALL_PREFIX}") |