Browse Source

Merge pull request #276 from joggee-fr/jg/deb-cmake

Alternative way to build Debian package using CMake / CPack
cmake
Manfred Wallner 1 month ago
committed by GitHub
parent
commit
edbcfca9e7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
6 changed files with 57 additions and 20 deletions
  1. +49
    -2
      CMakeLists.txt
  2. +3
    -5
      devLib/CMakeLists.txt
  3. +2
    -4
      gpio/CMakeLists.txt
  4. +0
    -2
      pins/CMakeLists.txt
  5. +3
    -5
      wiringPi/CMakeLists.txt
  6. +0
    -2
      wiringPiD/CMakeLists.txt

+ 49
- 2
CMakeLists.txt View File

@@ -1,10 +1,16 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.12)
project(WiringPiLib) project(WiringPiLib)


# Read version from version.h # Read version from version.h
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.h" WIRINGPI_VERSION) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.h" WIRINGPI_VERSION)
string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" WIRINGPI_VERSION "${WIRINGPI_VERSION}") string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" WIRINGPI_VERSION "${WIRINGPI_VERSION}")
string(REGEX REPLACE "([0-9]+)\..*" "\\1" WIRINGPI_SOVERSION "${WIRINGPI_VERSION}")

if(NOT WIRINGPI_VERSION MATCHES "([0-9]+)\.([0-9]+)")
message(FATAL_ERROR "Could not retrieve WiringPi versions")
endif()

set(WIRINGPI_VERSION_MAJOR ${CMAKE_MATCH_1})
set(WIRINGPI_VERSION_MINOR ${CMAKE_MATCH_2})


# Include subdirectories # Include subdirectories
add_subdirectory(devLib) add_subdirectory(devLib)
@@ -12,3 +18,44 @@ add_subdirectory(gpio)
#add_subdirectory(pins) #add_subdirectory(pins)
add_subdirectory(wiringPi) add_subdirectory(wiringPi)
#add_subdirectory(wiringPiD) #add_subdirectory(wiringPiD)

# CPack
set(CPACK_PACKAGE_NAME "wiringpi")
set(CPACK_PACKAGE_DESCRIPTION
"The wiringPi libraries, headers and gpio command
Libraries to allow GPIO access on a Raspberry Pi from C and C++
programs as well as from the command-line")

set(CPACK_DEBIAN_PACKAGE_SECTION "libraries")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/WiringPi/WiringPi")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LESSER")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VERSION_MAJOR ${WIRINGPI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${WIRINGPI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH "")

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Grazer Computer Club - GC2 <wiringpi@gc2.at>")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_DEPENDS "libc6, libcrypt1")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/debian-template/wiringPi/DEBIAN/postinst"
"${CMAKE_CURRENT_SOURCE_DIR}/debian-template/wiringPi/DEBIAN/postrm")

set(CPACK_DEB_COMPONENT_INSTALL TRUE)
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev")
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${CPACK_DEBIAN_RUNTIME_PACKAGE_NAME}")

# Check for arm or arm64 architecture
# Let CMake determine a value otherwise
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
endif()

set(CPACK_SOURCE_GENERATOR "TGZ")

include(CPack)

+ 3
- 5
devLib/CMakeLists.txt View File

@@ -1,6 +1,4 @@
# CMakeLists.txt for devLib # CMakeLists.txt for devLib

cmake_minimum_required(VERSION 3.10)
project(devLib) project(devLib)


# Source files # Source files
@@ -31,9 +29,9 @@ target_include_directories(wiringPiDev PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(wiringPiDev PRIVATE wiringPi) target_link_libraries(wiringPiDev PRIVATE wiringPi)


# Set the library version # Set the library version
set_target_properties(wiringPiDev PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_SOVERSION})
set_target_properties(wiringPiDev PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_VERSION_MAJOR})


# Install headers # Install headers
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include COMPONENT Development)
# Install the library # Install the library
install(TARGETS wiringPiDev LIBRARY DESTINATION lib)
install(TARGETS wiringPiDev LIBRARY DESTINATION lib COMPONENT Runtime NAMELINK_COMPONENT Development)

+ 2
- 4
gpio/CMakeLists.txt View File

@@ -1,6 +1,4 @@
# CMakeLists.txt for gpio # CMakeLists.txt for gpio

cmake_minimum_required(VERSION 3.10)
project(gpio) project(gpio)


find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
@@ -24,7 +22,7 @@ add_executable(gpio ${SRC})
target_link_libraries(gpio wiringPi wiringPiDev Threads::Threads m PkgConfig::libcrypt) target_link_libraries(gpio wiringPi wiringPiDev Threads::Threads m PkgConfig::libcrypt)


# Install the executable # Install the executable
install(TARGETS gpio DESTINATION bin)
install(TARGETS gpio DESTINATION bin COMPONENT Runtime)


# Install man page # Install man page
install(FILES gpio.1 DESTINATION share/man/man1)
install(FILES gpio.1 DESTINATION share/man/man1 COMPONENT Runtime)

+ 0
- 2
pins/CMakeLists.txt View File

@@ -1,6 +1,4 @@
# CMakeLists.txt for pins # CMakeLists.txt for pins

cmake_minimum_required(VERSION 3.10)
project(pins LANGUAGES NONE) project(pins LANGUAGES NONE)


# Source file # Source file


+ 3
- 5
wiringPi/CMakeLists.txt View File

@@ -1,6 +1,4 @@
# CMakeLists.txt for wiringPi # CMakeLists.txt for wiringPi

cmake_minimum_required(VERSION 3.10)
project(WiringPi) project(WiringPi)


# Source files # Source files
@@ -49,12 +47,12 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -Wfo
add_library(wiringPi SHARED ${SRC}) add_library(wiringPi SHARED ${SRC})


# Set the library version # Set the library version
set_target_properties(wiringPi PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_SOVERSION})
set_target_properties(wiringPi PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_VERSION_MAJOR})
target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})


# Add -lm to link with the math library # Add -lm to link with the math library
target_link_libraries(wiringPi PUBLIC m crypt) target_link_libraries(wiringPi PUBLIC m crypt)
# Install headers # Install headers
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include COMPONENT Development)
# Install the library # Install the library
install(TARGETS wiringPi LIBRARY DESTINATION lib)
install(TARGETS wiringPi LIBRARY DESTINATION lib COMPONENT Runtime NAMELINK_COMPONENT Development)

+ 0
- 2
wiringPiD/CMakeLists.txt View File

@@ -1,6 +1,4 @@
# CMakeLists.txt for wiringPiD # CMakeLists.txt for wiringPiD

cmake_minimum_required(VERSION 3.10)
project(wiringPiD) project(wiringPiD)


# Source files # Source files


Loading…
Cancel
Save