aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-08-31 17:38:57 +0200
committerDamjan Marion <damarion@cisco.com>2018-08-31 21:14:29 +0200
commitc6c0246e2e9219baee3d67970775bed7560eac1e (patch)
treed8fb787aa3e95c30442e8fc997d05b6cdc4a008e
parent219cc90cb435cfcfb5154c6c0e49bd4d60aae769 (diff)
cmake: detect vpp version, set soversion, pretty config print
Change-Id: I5d0777421debe6c3e4b93d62ad6790912063a9e6 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/CMakeLists.txt46
-rw-r--r--src/cmake/library.cmake1
-rw-r--r--src/cmake/message.cmake15
3 files changed, 57 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3d934f26459..c5dfca20b92 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,12 +16,23 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(vpp C)
include(CheckCCompilerFlag)
-
include(cmake/message.cmake)
include(cmake/cpu.cmake)
include(cmake/ccache.cmake)
##############################################################################
+# VPP Version
+##############################################################################
+execute_process(
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND scripts/version
+ OUTPUT_VARIABLE VPP_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
+list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)
+
+##############################################################################
# build config
##############################################################################
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -41,10 +52,6 @@ endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIB_DIR_NAME}")
set(CMAKE_INSTALL_MESSAGE NEVER)
-message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
-message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")
-message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
-
include_directories (
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
@@ -74,3 +81,32 @@ foreach(
endforeach()
include(cmake/pack.cmake)
+##############################################################################
+# detect if we are inside git repo and add configure dependency
+##############################################################################
+execute_process(
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND git rev-parse --show-toplevel
+ OUTPUT_VARIABLE VPP_GIT_TOPLEVEL_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if (VPP_GIT_TOPLEVEL_DIR)
+ set_property(
+ DIRECTORY APPEND PROPERTY
+ CMAKE_CONFIGURE_DEPENDS ${VPP_GIT_TOPLEVEL_DIR}/.git/index
+ )
+endif()
+
+##############################################################################
+# print configuration
+##############################################################################
+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("Target processor" "${CMAKE_SYSTEM_PROCESSOR}")
+pr("Build type" "${CMAKE_BUILD_TYPE}")
+pr("Install prefix" "${CMAKE_INSTALL_PREFIX}")
diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake
index 0d1e97cb6a3..cff5e3e3f2f 100644
--- a/src/cmake/library.cmake
+++ b/src/cmake/library.cmake
@@ -21,6 +21,7 @@ macro(add_vpp_library lib)
add_library(${lib} SHARED ${ARG_SOURCES})
target_compile_options(${lib} PRIVATE -Wall)
+ set_target_properties(${lib} PROPERTIES SOVERSION ${VPP_LIB_VERSION})
# library deps
if(ARG_LINK_LIBRARIES)
diff --git a/src/cmake/message.cmake b/src/cmake/message.cmake
index faee00091a2..fb740fdf7d9 100644
--- a/src/cmake/message.cmake
+++ b/src/cmake/message.cmake
@@ -34,3 +34,18 @@ function(message)
endif()
endfunction()
+##############################################################################
+# aligned config output
+##############################################################################
+function(pr desc val)
+ string(ASCII 27 esc)
+ set(reset "${esc}[m")
+ set(cyan "${esc}[36m")
+
+ string(LENGTH ${desc} len)
+ while (len LESS 20)
+ set (desc "${desc} ")
+ string(LENGTH ${desc} len)
+ endwhile()
+ _message("${cyan}${desc}${reset}: ${val}")
+endfunction()