aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/BuildMacros.cmake18
-rwxr-xr-xcmake/Modules/FindLibhicnctrl.cmake6
-rw-r--r--cmake/Modules/Packager.cmake49
-rw-r--r--cmake/Modules/ServiceScript.cmake42
4 files changed, 90 insertions, 25 deletions
diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake
index 63d54502b..8b591d05b 100644
--- a/cmake/Modules/BuildMacros.cmake
+++ b/cmake/Modules/BuildMacros.cmake
@@ -25,12 +25,13 @@ macro(build_executable exec)
${ARGN}
)
- add_executable(${exec} ${ARG_SOURCES})
+ add_executable(${exec}-bin ${ARG_SOURCES})
set(BUILD_ROOT ${CMAKE_BINARY_DIR}/build-root)
- set_target_properties(${exec}
+ set_target_properties(${exec}-bin
PROPERTIES
+ OUTPUT_NAME ${exec}
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
INSTALL_RPATH_USE_LINK_PATH TRUE
ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib"
@@ -39,19 +40,19 @@ macro(build_executable exec)
)
if(ARG_LINK_LIBRARIES)
- target_link_libraries(${exec} ${ARG_LINK_LIBRARIES})
+ target_link_libraries(${exec}-bin ${ARG_LINK_LIBRARIES})
endif()
if(ARG_DEPENDS)
- add_dependencies(${exec} ${ARG_DEPENDS})
+ add_dependencies(${exec}-bin ${ARG_DEPENDS})
endif()
if(ARG_DEFINITIONS)
- target_compile_definitions(${exec} PRIVATE ${ARG_DEFINITIONS})
+ target_compile_definitions(${exec}-bin PRIVATE ${ARG_DEFINITIONS})
endif()
if(ARG_INCLUDE_DIRS)
- target_include_directories(${exec} BEFORE PUBLIC
+ target_include_directories(${exec}-bin BEFORE PUBLIC
${ARG_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}
)
@@ -59,7 +60,7 @@ macro(build_executable exec)
if(NOT ARG_NO_INSTALL)
install(
- TARGETS ${exec}
+ TARGETS ${exec}-bin
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ${ARG_COMPONENT}
@@ -178,6 +179,9 @@ macro(build_library lib)
if ("${dir}" STREQUAL includes)
set(dir "")
endif()
+ if ("${dir}" STREQUAL ${ARG_INSTALL_ROOT_DIR})
+ set(dir "")
+ endif()
else()
set(dir "")
endif()
diff --git a/cmake/Modules/FindLibhicnctrl.cmake b/cmake/Modules/FindLibhicnctrl.cmake
index 1399b41bf..7c20420b4 100755
--- a/cmake/Modules/FindLibhicnctrl.cmake
+++ b/cmake/Modules/FindLibhicnctrl.cmake
@@ -31,14 +31,14 @@ find_path(LIBHICNCTRL_INCLUDE_DIR hicn/ctrl.h
DOC "Find the hICN control include"
)
-find_library(LIBHICNCTRL_LIBRARY NAMES hicn-ctrl
+find_library(LIBHICNCTRL_LIBRARY NAMES hicnctrl
HINTS ${HICN_SEARCH_PATH_LIST}
PATH_SUFFIXES lib
DOC "Find the hicn control library"
)
-set(LIBHICNCTRL_LIBRARIES ${HICNCTRL_LIBRARY})
-set(LIBHICNCTRL_INCLUDE_DIRS ${HICNCTRL_INCLUDE_DIR})
+set(LIBHICNCTRL_LIBRARIES ${LIBHICNCTRL_LIBRARY})
+set(LIBHICNCTRL_INCLUDE_DIRS ${LIBHICNCTRL_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(hicnctrl DEFAULT_MSG
diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake
index 898e40bcb..6f77fd3a8 100644
--- a/cmake/Modules/Packager.cmake
+++ b/cmake/Modules/Packager.cmake
@@ -33,10 +33,35 @@ function(get_next_version VERSION NEXT_VERSION)
math(EXPR major "${major} + 1")
endif()
- set(minor "0${minor}")
+ if (minor LESS 10)
+ set(minor "0${minor}")
+ endif()
+
set(${NEXT_VERSION} "${major}.${minor}" PARENT_SCOPE)
endfunction()
+macro(extract_version)
+ # Extract version from git
+ execute_process(
+ COMMAND git describe --long --match v*
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE VER
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ if (NOT VER)
+ set(VER "v1.0-0-gcafe")
+ endif()
+
+ message(STATUS "Git describe output: ${VER}")
+
+ string(REGEX REPLACE "v([0-9]+).([0-9]+)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3;\\4" VER ${VER})
+ list(GET VER 0 VERSION_MAJOR)
+ list(GET VER 1 VERSION_MINOR)
+ list(GET VER 2 VERSION_REVISION)
+ list(GET VER 3 COMMIT_NAME)
+endmacro(extract_version)
+
macro(make_packages)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
# parse /etc/os-release
@@ -49,23 +74,17 @@ macro(make_packages)
set(OS_${_name} ${_value})
endforeach()
- # extract version from git
- execute_process(
- COMMAND git describe --long --match v*
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- OUTPUT_VARIABLE VER
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
+ extract_version()
- if (NOT VER)
- set(VER "v1.0-1-gcafe")
- endif()
+ message(STATUS "Version major: ${VERSION_MAJOR}")
+ message(STATUS "Version minor: ${VERSION_MINOR}")
+ message(STATUS "Revision: ${VERSION_REVISION}")
+ message(STATUS "Commit hash: ${COMMIT_NAME}")
- string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER})
- list(GET VER 0 tag)
+ set(tag "${VERSION_MAJOR}.${VERSION_MINOR}")
string(REPLACE "-" "~" tag ${tag})
- list(GET VER 1 commit_num)
- list(GET VER 2 commit_name)
+ set(commit_num ${VERSION_REVISION})
+ set(commit_name ${COMMIT_NAME})
if (NOT DEFINED ENV{BUILD_NUMBER})
set(bld "b1")
diff --git a/cmake/Modules/ServiceScript.cmake b/cmake/Modules/ServiceScript.cmake
new file mode 100644
index 000000000..110aa816b
--- /dev/null
+++ b/cmake/Modules/ServiceScript.cmake
@@ -0,0 +1,42 @@
+# Copyright (c) 2019 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+########################################
+#
+# Find the LongBow libraries and includes
+# This module sets:
+# SYSTEMD_FOUND: True if Systemd was found
+# SYSTEMD_SERVICES_INSTALL_DIR: The Systemd install directory
+
+set(SYSTEMD_SERVICE_FOLDER "/lib/systemd/system")
+
+macro(install_service_script script)
+cmake_parse_arguments(ARG
+ ""
+ "COMPONENT"
+ ""
+ ${ARGN}
+)
+
+ # Install service file only if
+ # 1) We are on a linux system
+ # 2) The installation prefix is /usr
+
+ if (NOT ARG_COMPONENT)
+ set(ARG_COMPONENT hicn)
+ endif()
+
+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")
+ install (FILES ${script} DESTINATION ${SYSTEMD_SERVICE_FOLDER} COMPONENT ${ARG_COMPONENT})
+ endif()
+endmacro(install_service_script) \ No newline at end of file