Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Set up project CMake structure (#16)
Browse files Browse the repository at this point in the history
* set up module library structure

* set up module library structure

* removed test function and finalized CMake project structure

* fix error with no class memeber
  • Loading branch information
samdai01 authored Jan 8, 2024
1 parent d0e7f88 commit 3c084b4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 6 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ryml REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(diagnostics src/main/diagnostics.cpp)

add_subdirectory(src)
target_include_directories(diagnostics PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(main)
add_subdirectory(ui)
9 changes: 9 additions & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_executable(diagnostics diagnostics.cpp)

target_link_libraries(diagnostics PRIVATE
UI
)

target_include_directories(diagnostics PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
9 changes: 7 additions & 2 deletions src/main/diagnostics.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include <cstdio>
#include <iostream>

#include "commonUI.h"

int main(int argc, char ** argv)
{
(void)argc;
(void)argv;

printf("Welcome to UBC Sailbot diagnostics!\n");
std::cout << "Welcome to UBC Sailbot Diagnostics! The C++ version" << std::endl;

CommonUI myObj;

return 0;
}
1 change: 1 addition & 0 deletions src/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(common)
2 changes: 2 additions & 0 deletions src/ui/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_library(UI STATIC commonUI.cpp commonUI.h)
target_include_directories(UI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
13 changes: 13 additions & 0 deletions src/ui/common/commonUI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "commonUI.h"

#include <sys/ioctl.h>
#include <unistd.h>

CommonUI::CommonUI() { terminal_width = getTerminalWidth(); }

int CommonUI::getTerminalWidth()
{
struct winsize size;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
return size.ws_col;
}
16 changes: 16 additions & 0 deletions src/ui/common/commonUI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef COMMON_UI_H_
#define COMMON_UI_H_

/* Objects */

class CommonUI
{
private:
int terminal_width;
static int getTerminalWidth();

public:
CommonUI();
};

#endif

0 comments on commit 3c084b4

Please sign in to comment.