Skip to content

Commit

Permalink
Compile to a library
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJappie08 committed Sep 30, 2024
1 parent a88e6e9 commit 41bd2c0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 50 deletions.
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ project(tmx_cpp)
# Find Boost libraries
find_package(Boost REQUIRED COMPONENTS system thread)

add_subdirectory(libs/async_serial)

# Add executable
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/libs/async_serial/ SUB_SOURCES)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/async_serial/
# aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/libs/async_serial/ SUB_SOURCES)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/async_serial/include/
${CMAKE_CURRENT_SOURCE_DIR}/include/)

add_executable(tmx_cpp src/main.cpp src/tmx.cpp src/sensors.cpp ${SUB_SOURCES})
add_library(tmx_cpp
STATIC
src/tmx.cpp
src/tmx_util.cpp
src/buffer_build.cpp
src/modules.cpp
src/modules/HiwonderServo.cpp
src/modules/PCA9685.cpp
src/sensors.cpp
src/sensors/INA226.cpp)

# Link Boost libraries
target_link_libraries(tmx_cpp Boost::system Boost::thread)
install(TARGETS tmx_cpp DESTINATION lib/${PROJECT_NAME})
target_link_libraries(tmx_cpp Boost::system Boost::thread async_serial)
2 changes: 1 addition & 1 deletion include/tmx.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "AsyncSerial.h"
#include "async_serial/AsyncSerial.h"
#include "modules.hpp"
#include "sensors.hpp"
#include <algorithm>
Expand Down
13 changes: 7 additions & 6 deletions libs/async_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

cmake_minimum_required(VERSION 3.1)
project(TEST)
project(async_serial)

## Target
set(CMAKE_CXX_STANDARD 11)
set(TEST_SRCS main.cpp AsyncSerial.cpp BufferedAsyncSerial.cpp)
add_executable(async ${TEST_SRCS})

include_directories(include/)

add_library(${PROJECT_NAME} STATIC src/AsyncSerial.cpp src/BufferedAsyncSerial.cpp)

## Link libraries
set(BOOST_LIBS date_time system)
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
target_link_libraries(async ${Boost_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
find_package(Threads REQUIRED)
target_link_libraries(async ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
2 changes: 2 additions & 0 deletions libs/async_serial/Makefile.windows
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PROBABLY BROKEN

#Using MinGW distro from http://nuwen.net/mingw.html that contains boost precompiled

all:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Created on January 6, 2011, 3:31 PM
*/

#include "AsyncSerial.h"
#include "async_serial/AsyncSerial.h"
#include <mutex>

#ifndef BUFFEREDASYNCSERIAL_H
Expand Down
35 changes: 0 additions & 35 deletions libs/async_serial/main.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
*/

#include "AsyncSerial.h"
#include "async_serial/AsyncSerial.h"

#include <algorithm>
#include <boost/bind/bind.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Created on January 6, 2011, 3:31 PM
*/

#include "BufferedAsyncSerial.h"
#include "async_serial/BufferedAsyncSerial.h"

#include <algorithm>
#include <string>
Expand Down

0 comments on commit 41bd2c0

Please sign in to comment.