forked from PocketNC/bb_gpio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAINTENANCE: Update to use Machinekit-HAL's new packaging scheme
Add a new simple CMake based build-system taking advantage of the new targets and scripts exported by Machinekit-HAL. For user's convenience also adds a Debian packaging.
- Loading branch information
Showing
6 changed files
with
202 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# ############################################################################## | ||
# Description: CMakeLists.txt | ||
# | ||
# This file, 'CMakeLists.txt', implements build system rules for BB-GPIO project | ||
# | ||
# Copyright (C) 2021 Jakub Fišer <jakub DOT fiser AT eryaf DOT com> | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by the Free | ||
# Software Foundation; either version 2.1 of the License, or (at your option) | ||
# any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License along | ||
# with this library; if not, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# ############################################################################## | ||
# ~~~ | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) | ||
set(CMAKE_EXPORT_LINK_COMMANDS TRUE) | ||
set(CMAKE_DISABLE_SOURCE_CHANGES TRUE) | ||
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE) | ||
|
||
project( | ||
BB-GPIO | ||
VERSION 1.0.0 | ||
DESCRIPTION "GPIO driver for Beaglebone Black SBC" | ||
HOMEPAGE_URL "https://github.com/PocketNC/bb_gpio" | ||
LANGUAGES C) | ||
|
||
if(CMAKE_TOOLCHAIN_FILE) | ||
cmake_path(IS_RELATIVE CMAKE_TOOLCHAIN_FILE _toolchain_file_is_relative) | ||
if(_toolchain_file_is_relative) | ||
file(REAL_PATH "${CMAKE_TOOLCHAIN_FILE}" _toolchain_path BASE_DIRECTORY | ||
"${CMAKE_BINARY_DIR}" EXPAND_TILDE) | ||
if(NOT EXISTS "${_toolchain_path}") | ||
message( | ||
FATAL_ERROR "Specified Toolchain file ${_toolchain_path} doesn't exist!" | ||
) | ||
endif() | ||
set(CMAKE_TOOLCHAIN_FILE "${_toolchain_path}") | ||
message( | ||
WARNING | ||
"CMAKE_TOOLCHAIN_FILE set to ${CMAKE_TOOLCHAIN_FILE} to resolve the relative path issue. Please, avoid using relative paths!" | ||
) | ||
unset(_toolchain_path) | ||
endif() | ||
unset(_toolchain_file_is_relative) | ||
endif() | ||
|
||
find_package( | ||
Machinekit-HAL | ||
COMPONENTS Managed-Runtime Managed-HAL | ||
REQUIRED) | ||
|
||
include(GNUInstallDirs) | ||
include(CPackComponent) | ||
include(CPack) | ||
include(FindPkgConfig) | ||
|
||
set(MACHINEKIT_HAL_PACKAGE_PREFIX_PATH "machinekit/hal") | ||
set(MACHINEKIT_HAL_MANAGED_MODULE_DIRECTORY | ||
"${CMAKE_INSTALL_LIBDIR}/${MACHINEKIT_HAL_PACKAGE_PREFIX_PATH}/module/managed" | ||
) | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
|
||
set(CMAKE_C_FLAGS_DEBUG "-g -O0") | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") | ||
set(CMAKE_C_FLAGS_RELEASE "-O0") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O0") | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O0") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O0") | ||
|
||
message(STATUS "Value of CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") | ||
message(STATUS "Value of CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") | ||
message(STATUS "Value of CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") | ||
|
||
pkg_check_modules(LIBGPIOD "libgpiod" REQUIRED IMPORTED_TARGET) | ||
|
||
add_library(bb_gpio MODULE) | ||
target_sources(bb_gpio PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/bb_gpio.c" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/bb_gpio.h") | ||
|
||
target_link_libraries( | ||
bb_gpio PRIVATE Machinekit::HAL::managed_hal Machinekit::HAL::managed_runtime | ||
PkgConfig::LIBGPIOD) | ||
|
||
export_rtapi_symbols(TARGET bb_gpio) | ||
|
||
set_target_properties( | ||
bb_gpio | ||
PROPERTIES OUTPUT_NAME "bb_gpio" | ||
PREFIX "mod" | ||
LIBRARY_OUTPUT_DIRECTORY | ||
"${MACHINEKIT_HAL_MANAGED_MODULE_DIRECTORY}") | ||
|
||
install(TARGETS bb_gpio | ||
LIBRARY DESTINATION "${MACHINEKIT_HAL_MANAGED_MODULE_DIRECTORY}" | ||
COMPONENT BB_GPIO_Managed_Module_Drivers) | ||
|
||
cpack_add_component(BB_GPIO_Managed_Module_Drivers GROUP BB_GPIO_Managed_Module) | ||
|
||
cpack_add_component_group(BB_GPIO_Managed_Module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bb-gpio (1.0.0) bullseye; urgency=low | ||
|
||
* Update to use the new Machinekit-HAL packaging scheme | ||
* Add simple Debian packaging | ||
* Add a CMake based buildsystem | ||
|
||
-- Jakub Fišer <jakub.fiser@eryaf.com> Sat, 22 Jan 2020 10:00:00 +0200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Source: bb-gpio | ||
Section: misc | ||
Priority: optional | ||
Maintainer: MachinekitBot <machinekit@eryaf.com> | ||
Build-Depends: | ||
dh-cmake, | ||
dh-cmake-compat (= 1), | ||
dh-sequence-cpack, | ||
debhelper-compat (= 12), | ||
debhelper (>= 10), | ||
libmachinekit-hal-dev, | ||
libgpiod-dev | ||
Standards-Version: 4.5.1 | ||
Homepage: https://github.com/PocketNC/bb_gpio | ||
|
||
|
||
Package: modbb-gpio | ||
Architecture: any | ||
Multi-Arch: same | ||
Depends: | ||
${shlibs:Depends}, | ||
${misc:Depends}, | ||
machinekit-hal | ||
Description: BeagleBone Black GPIO Driver for Machinekit-HAL | ||
Managed HAL driver module for BeagleBone Black GPIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BB_GPIO_Managed_Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/make -f | ||
|
||
# #################################################################### | ||
# Description: rules | ||
# | ||
# This file, 'rules', implements build targets for Debian | ||
# style packaging | ||
# | ||
# Copyright (C) 2021 Jakub Fišer <jakub DOT fiser AT eryaf DOT com> | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# ##################################################################### | ||
|
||
# Turn OFF the Link-Time Optimization (LTO) during compilation as it clashes with the | ||
# current version of linker script turning symbols of HAL modules local (defined | ||
# in 'MachinekitHALSymbolVisibilityFunction.cmake' CMake file) | ||
DEB_CFLAGS_MAINT_STRIP :=-flto=auto -ffat-lto-objects | ||
DEB_CXXFLAGS_MAINT_STRIP :=-flto=auto -ffat-lto-objects | ||
DEB_LDFLAGS_MAINT_STRIP :=-flto=auto | ||
|
||
# Set the main optimization value for all parts to O0 | ||
DEB_CFLAGS_MAINT_STRIP +=-O2 | ||
DEB_CXXFLAGS_MAINT_STRIP +=-O2 | ||
DEB_CFLAGS_MAINT_APPEND :=-O0 | ||
DEB_CXXFLAGS_MAINT_APPEND :=-O0 | ||
|
||
# Do not warn on potential reproducible build datetime mismatch | ||
DEB_CPPFLAGS_MAINT_STRIP :=-Wdate-time | ||
|
||
export DEB_CFLAGS_MAINT_STRIP | ||
export DEB_CXXFLAGS_MAINT_STRIP | ||
export DEB_LDFLAGS_MAINT_STRIP | ||
export DEB_CFLAGS_MAINT_APPEND | ||
export DEB_CXXFLAGS_MAINT_APPEND | ||
export DEB_CPPFLAGS_MAINT_STRIP | ||
|
||
%: | ||
dh $@ --buildsystem=cmake |