build: Start migration to cmake

This preps us for proper system installs to distributions, finding depending
libraries, and allowing us to build the foundation for the GUI and support
tooling next.

The plan is to run g13d as a system daemon managed by systemd. We'll use the
system-wide input group to control access to the daemon.

  - Add a CMakeLists for etc so we can install the udev rules.
  - Move the src dir to g13d to disambiguate a bit.
  - Update the toplevel Makefile so we can still build the old way (for now).
This commit is contained in:
June Tate-Gans 2021-04-25 01:19:06 -05:00
parent a8eda7a3c5
commit 04cb5d9c12
16 changed files with 44 additions and 9 deletions

5
CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16.3)
project(g13)
add_subdirectory(g13d)
add_subdirectory(etc)

View File

@ -3,16 +3,16 @@ LIBS := -lusb-1.0 -lboost_program_options -lboost_log -lboost_system -lpthr
PREFIX ?= /usr/local
G13D_SRCS := \
src/g13.cc \
src/g13_fonts.cc \
src/g13_keys.cc \
src/g13_lcd.cc \
src/g13_log.cc \
src/g13_main.cc \
src/g13_stick.cc \
src/helper.cc
g13d/g13.cc \
g13d/g13_fonts.cc \
g13d/g13_keys.cc \
g13d/g13_lcd.cc \
g13d/g13_log.cc \
g13d/g13_main.cc \
g13d/g13_stick.cc \
g13d/helper.cc
G13D_OBJS := $(patsubst src/%.cc,build/%.o,$(G13D_SRCS))
G13D_OBJS := $(patsubst g13d/%.cc,build/%.o,$(G13D_SRCS))
all: build build/g13d build/pbm2lpbm

5
etc/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16.3)
project(g13)
install(FILES 91-g13.rules
DESTINATION /etc/udev.d/rules.d/91-g13.rules)

25
g13d/CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.16.3)
project(g13d CXX)
add_executable(pbm2lpbm pbm2lpbm.cc)
add_executable(g13d
g13.cc
g13_fonts.cc
g13_keys.cc
g13_lcd.cc
g13_log.cc
g13_main.cc
g13_stick.cc
helper.cc
)
target_compile_definitions(g13d PUBLIC BOOST_LOG_DYN_LINK=1)
find_package(PkgConfig)
pkg_check_modules(libusb-1.0 REQUIRED libusb-1.0)
find_package(Boost REQUIRED COMPONENTS system log program_options)
target_link_libraries(g13d
${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
${libusb-1.0_LIBRARIES})
install(TARGETS g13d pbm2lpbm RUNTIME)