diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-01-22 00:02:05 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-01-22 14:38:36 +0100 |
commit | 211b6a8bc6d959a874a43f28d4cda43eae48200d (patch) | |
tree | ba0385073c4c2f9baaf611a7f2c7a1e38d507edc /cmake | |
parent | 7d710d62fcb2a15505a7a0fc8feb91b8342fafd6 (diff) |
[HICN-3] First version of packaging system based on cmake.
Change-Id: I576f84f4c12f932e17e9169f2c6ffdaed128ca10
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'cmake')
-rwxr-xr-x | cmake/Modules/BuildMacros.cmake | 15 | ||||
-rwxr-xr-x | cmake/Modules/Packager.cmake | 32 |
2 files changed, 26 insertions, 21 deletions
diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake index 276659525..a1977f980 100755 --- a/cmake/Modules/BuildMacros.cmake +++ b/cmake/Modules/BuildMacros.cmake @@ -54,7 +54,7 @@ endmacro() macro(build_library lib) cmake_parse_arguments(ARG "SHARED;STATIC" - "COMPONENT" + "COMPONENT;" "SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS;INCLUDE_DIRS;DEFINITIONS;INSTALL_ROOT_DIR" ${ARGN} ) @@ -76,6 +76,11 @@ macro(build_library lib) add_library(${lib} STATIC ${ARG_SOURCES}) endif() + # install .so + if(NOT ARG_COMPONENT) + set(ARG_COMPONENT hicn) + endif() + foreach(library ${TARGET_LIBS}) target_compile_options(${library} PRIVATE -Wall) @@ -107,10 +112,6 @@ macro(build_library lib) ) endif() - # install .so - if(NOT ARG_COMPONENT) - set(ARG_COMPONENT hicn) - endif() install( TARGETS ${library} DESTINATION lib @@ -129,6 +130,10 @@ macro(build_library lib) set(ARG_INSTALL_ROOT_DIR "hicn") endif() + list(APPEND local_comps + ${ARG_COMPONENT}-dev + ) + foreach(file ${ARG_INSTALL_HEADERS}) get_filename_component(_dir ${file} DIRECTORY) get_filename_component(dir ${_dir} NAME) diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake index 58530fa72..f060bfa4b 100755 --- a/cmake/Modules/Packager.cmake +++ b/cmake/Modules/Packager.cmake @@ -19,15 +19,10 @@ set(CONTACT "hicn-dev@lists.fd.io" CACHE STRING "Contact") set(PACKAGE_MAINTAINER "ICN Team" CACHE STRING "Maintainer") set(PACKAGE_VENDOR "fd.io" CACHE STRING "Vendor") -macro(add_package name) - cmake_parse_arguments(ARG - "" - "NAME;DESCRIPION;DEPENDENCIES" - "" - ${ARGN} - ) +# macro(set) - if (0) +macro(make_packages) + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") # parse /etc/os-release file(READ "/etc/os-release" os_version) string(REPLACE "\n" ";" os_version ${os_version}) @@ -41,6 +36,7 @@ macro(add_package name) # extract version from git execute_process( COMMAND git describe --long --match v* + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VER OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -70,34 +66,38 @@ macro(add_package name) set(CPACK_GENERATOR "DEB") set(type "DEBIAN") set(CPACK_PACKAGE_VERSION "${deb_ver}") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPP Team") - set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + set(CPACK_${type}_FILE_NAME DEB-DEFAULT) foreach(lc ${components}) string(TOUPPER ${lc} uc) - set(CPACK_DEBIAN_${uc}_PACKAGE_NAME "${lc}") + set(CPACK_${type}_${uc}_PACKAGE_DEPENDS "${${lc}_DEB_DEPENDENCIES}") + set(CPACK_${type}_${uc}_PACKAGE_NAME "${lc}") + set(CPACK_COMPONENT_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}") endforeach() elseif(OS_ID_LIKE MATCHES "rhel") set(CPACK_GENERATOR "RPM") set(type "RPM") set(CPACK_PACKAGE_VERSION "${rpm_ver}") - set(CPACK_RPM_FILE_NAME RPM-DEFAULT) + set(CPACK_${type}_FILE_NAME RPM-DEFAULT) foreach(lc ${components}) string(TOUPPER ${lc} uc) if(${lc} MATCHES ".*-dev") - set(CPACK_RPM_${uc}_DEBUGINFO_PACKAGE ON) + set(CPACK_${type}_${uc}_DEBUGINFO_PACKAGE ON) set(lc ${lc}el) endif() - set(CPACK_RPM_${uc}_PACKAGE_NAME "${lc}") + + set(CPACK_${type}_${uc}_PACKAGE_NAME "${lc}") + set(CPACK_${type}_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}") + set(CPACK_${type}_${uc}_PACKAGE_REQUIRES "${${lc}_RPM_DEPENDENCIES}") endforeach() endif() if(CPACK_GENERATOR) set(CPACK_PACKAGE_NAME ${ARG_NAME}) set(CPACK_STRIP_FILES OFF) - set(CPACK_PACKAGE_VENDOR "${ARG_VENDOR}") + set(CPACK_PACKAGE_VENDOR "${PACKAGE_VENDOR}") set(CPACK_COMPONENTS_IGNORE_GROUPS 1) set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON) - set(CPACK_${type}_PACKAGE_DESCRIPTION "${ARG_DESCRIPTION}") + set(CPACK_${type}_PACKAGE_MAINTAINER "HICN Team") set(CPACK_${type}_PACKAGE_RELEASE 1) include(CPack) endif() |