From d8474b504503143be75c7c21746c652d3a546cf2 Mon Sep 17 00:00:00 2001 From: Lucino772 Date: Fri, 9 Sep 2022 00:14:21 +0200 Subject: [PATCH] build(gpio): added CMakeLists.txt for gpio binary --- gpio/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 gpio/CMakeLists.txt diff --git a/gpio/CMakeLists.txt b/gpio/CMakeLists.txt new file mode 100644 index 0000000..0667360 --- /dev/null +++ b/gpio/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.10) + +project(gpio VERSION 0.1) +set(TARGET gpio) + +# Have CMake find pthreads library within our toolchain +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads REQUIRED) + +# Source Files +set(gpio_src + gpio.c readall.c +) + +# Add library target +add_executable (${TARGET} ${gpio_src}) + +# Add include directory for gpio +target_include_directories (${TARGET} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../wiringPiDev + ${CMAKE_CURRENT_SOURCE_DIR}/../wiringPi + ${CMAKE_INSTALL_PREFIX}/include) + + +# Add the following required libraries: wiringPi, wiringPiDev, Threads, Math, Crypt, and RealTime +target_link_directories(${TARGET} PUBLIC ${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(${TARGET} wiringPi wiringPiDev ${CMAKE_THREAD_LIBS_INIT} crypt m rt) + +# Add install +install(TARGETS ${TARGET} DESTINATION bin)