Skip to content

Commit

Permalink
Add configuration header
Browse files Browse the repository at this point in the history
  • Loading branch information
andreylitvintsev committed Feb 27, 2024
1 parent 6dea771 commit 786817f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cmake_minimum_required(VERSION 3.22.1)

project(MagicPodsCore LANGUAGES C CXX)
project(MagicPodsCore VERSION 1.0.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")

configure_file(config/Config.h.in src/Config.h)

add_executable(MagicPodsCore
src/main.cpp
src/DevicesInfoFetcher.cpp
Expand All @@ -15,5 +17,5 @@ add_executable(MagicPodsCore
src/aap/AapClient.cpp
)
add_subdirectory(dependencies)
target_include_directories(MagicPodsCore PRIVATE src dependencies/json)
target_include_directories(MagicPodsCore PRIVATE src dependencies/json ${PROJECT_BINARY_DIR}/src)
target_link_libraries(MagicPodsCore PRIVATE sdbus-c++ uWebSockets bluetooth)
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ FROM system_stage AS build_stage

ADD ./src /app/src
ADD ./dependencies /app/dependencies
ADD ./config /app/config
ADD ./CMakeLists.txt /app/CMakeLists.txt

WORKDIR /app/build

RUN cmake -DCMAKE_BUILD_TYPE=Release ..
RUN cmake --build .
RUN cmake -DCMAKE_BUILD_TYPE=Release ../
RUN cmake --build ./

FROM scratch as copy_results_stage

Expand Down
2 changes: 2 additions & 0 deletions config/Config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#cmakedefine CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#cmakedefine MagicPodsCore_VERSION "@MagicPodsCore_VERSION@"
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "DeviceBattery.h"
#include "DeviceAnc.h"
#include "Logger.h"
#include "Config.h"

using namespace MagicPodsCore;

Expand Down Expand Up @@ -310,7 +311,7 @@ bool TryToParseArguments(int argc, char** argv) {
for (int i = 0; i < argc; ++i) {
std::string argument{argv[i]};
if (argument == "--version" || argument == "-version" || argument == "-v") {
LOG_RELEASE("MagicPodsCore 1.0.0");
LOG_RELEASE(CMAKE_PROJECT_NAME " " MagicPodsCore_VERSION);
return true;
}
else if (argument == "--help" || argument == "-help" || argument == "-h" || argc > 2) {
Expand All @@ -330,6 +331,8 @@ int main(int argc, char** argv) {
if (TryToParseArguments(argc, argv))
return 0;

LOG_RELEASE(CMAKE_PROJECT_NAME " " MagicPodsCore_VERSION);

DevicesInfoFetcher devicesInfoFetcher{};

/* ws->getUserData returns one of these */
Expand Down

0 comments on commit 786817f

Please sign in to comment.