mirror of
https://github.com/3cky/mbusd.git
synced 2024-12-24 16:37:37 +01:00
cmake/gitlabci added DEB/RPM capabilities
This commit is contained in:
parent
fc3a976274
commit
425bd14167
@ -14,8 +14,10 @@ stages:
|
|||||||
- output.dir/mbusd.8
|
- output.dir/mbusd.8
|
||||||
- conf/mbusd.conf.example
|
- conf/mbusd.conf.example
|
||||||
- output.dir/mbusd@.service
|
- output.dir/mbusd@.service
|
||||||
|
- output.dir/mbusd*.deb
|
||||||
|
- output.dir/mbusd*.rpm
|
||||||
|
|
||||||
build:linux_armhf:
|
build:deb_armhf:
|
||||||
<<: *mbusd_job_template
|
<<: *mbusd_job_template
|
||||||
stage: build
|
stage: build
|
||||||
before_script:
|
before_script:
|
||||||
@ -25,9 +27,9 @@ build:linux_armhf:
|
|||||||
- mkdir output.dir/
|
- mkdir output.dir/
|
||||||
- cd output.dir
|
- cd output.dir
|
||||||
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../arm_linux_gnueabihf.cmake ../
|
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../arm_linux_gnueabihf.cmake ../
|
||||||
- make
|
- make package
|
||||||
|
|
||||||
build:linux_x86:
|
build:deb_x86:
|
||||||
<<: *mbusd_job_template
|
<<: *mbusd_job_template
|
||||||
stage: build
|
stage: build
|
||||||
before_script:
|
before_script:
|
||||||
@ -37,7 +39,8 @@ build:linux_x86:
|
|||||||
- mkdir output.dir/
|
- mkdir output.dir/
|
||||||
- cd output.dir
|
- cd output.dir
|
||||||
- cmake -D CMAKE_BUILD_TYPE=Debug ../
|
- cmake -D CMAKE_BUILD_TYPE=Debug ../
|
||||||
- make
|
- make package
|
||||||
|
|
||||||
|
|
||||||
test_x86:
|
test_x86:
|
||||||
stage: test
|
stage: test
|
||||||
@ -50,7 +53,7 @@ test_x86:
|
|||||||
- python -m pip install pymodbus service_identity
|
- python -m pip install pymodbus service_identity
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- build:linux_x86
|
- build:deb_x86
|
||||||
script:
|
script:
|
||||||
- mkdir -p output.dir/
|
- mkdir -p output.dir/
|
||||||
- cd output.dir
|
- cd output.dir
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.2)
|
cmake_minimum_required(VERSION 3.2)
|
||||||
include(CPack)
|
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
@ -68,11 +67,11 @@ set(mbusd_SOURCES
|
|||||||
src/sock.c
|
src/sock.c
|
||||||
)
|
)
|
||||||
add_executable(mbusd ${mbusd_SOURCES})
|
add_executable(mbusd ${mbusd_SOURCES})
|
||||||
install(TARGETS mbusd DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS mbusd DESTINATION bin)
|
||||||
|
|
||||||
# aggregate the man page template
|
# aggregate the man page template
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/mbusd.8.in mbusd.8)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/mbusd.8.in mbusd.8)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd.8 DESTINATION share/man/man8)
|
||||||
|
|
||||||
# install example configuration file
|
# install example configuration file
|
||||||
install(
|
install(
|
||||||
@ -80,11 +79,13 @@ install(
|
|||||||
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(SystemD "systemd")
|
||||||
|
if(SystemD_FOUND)
|
||||||
# aggregate mbusd@.service from its template
|
# aggregate mbusd@.service from its template
|
||||||
if(IS_DIRECTORY /usr/lib/systemd/system)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/systemd-units/mbusd@.service.in mbusd@.service)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/systemd-units/mbusd@.service.in mbusd@.service)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd@.service DESTINATION /usr/lib/systemd/system)
|
|
||||||
endif()
|
endif()
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd@.service DESTINATION /etc/systemd/system/ OPTIONAL)
|
||||||
|
|
||||||
# uninstall target
|
# uninstall target
|
||||||
configure_file(
|
configure_file(
|
||||||
@ -94,9 +95,46 @@ configure_file(
|
|||||||
add_custom_target(uninstall
|
add_custom_target(uninstall
|
||||||
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
# unittest target
|
# unittest target
|
||||||
option(TESTS "Enable unittests" OFF)
|
option(TESTS "Enable unittests" OFF)
|
||||||
if(TESTS)
|
if(TESTS)
|
||||||
add_executable(test_basic tests/test_basics.c)
|
add_executable(test_basic tests/test_basics.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
## Please find Packaging stuff following
|
||||||
|
#@source http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/
|
||||||
|
# Get the current working branch
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
# Get the latest abbreviated commit hash of the working branch
|
||||||
|
execute_process(
|
||||||
|
COMMAND git log -1 --format=%h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# which infrastructure do we want
|
||||||
|
set(CPACK_GENERATOR "DEB")
|
||||||
|
pkg_check_modules(rpmBuilder "librpmbuild3")
|
||||||
|
if(rpmBuilder_FOUND)
|
||||||
|
set(CPACK_GENERATOR "RPM")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_NAME "modbusd")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Victor Antonovich") #required
|
||||||
|
set(CPACK_PACKAGE_CONTACT "Victor Antonovich <v.antonovich@gmail.com>")
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}-${GIT_BRANCH}-g${GIT_COMMIT_HASH})
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}-v${PROJECT_VERSION})
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Modbus serial to TCP/UDP transceiver")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
|
|
||||||
|
set(CPACK_SOURCE_STRIP_FILES TRUE)
|
||||||
|
set(CPACK_STRIP_FILES TRUE)
|
||||||
|
#the include must be after all the cpack concerning set's
|
||||||
|
include(CPack)
|
Loading…
Reference in New Issue
Block a user