Skip to content

Commit

Permalink
devops commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zahar-kohut-ucu committed May 12, 2024
1 parent 8306a1f commit fa9cbee
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 105 deletions.
36 changes: 24 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.15)

#! CHANGE YOUR PROJECT NAME
# It is used as your project's main executable name.
set(PROJECT_NAME template)
project(${PROJECT_NAME} C CXX) # project(${PROJECT_NAME} C CXX ASM)
set(PROJECT_NAME exam_acs_2024)
project(${PROJECT_NAME} C CXX)

set(CMAKE_CXX_STANDARD 20)

Expand Down Expand Up @@ -53,30 +53,42 @@ include(cmake/CompilerWarnings.cmake)
##########################################################
# Project files, packages, libraries and so on
##########################################################

set(EXE_NAME run_exam)
#! Project main executable source compilation
add_executable(${PROJECT_NAME} main.cpp
options_parser/options_parser.cpp options_parser/options_parser.h)
add_executable(${EXE_NAME} src/main.cpp
)

target_include_directories(${EXE_NAME} PRIVATE include)

#! Put path to your project headers
target_include_directories(${PROJECT_NAME} PRIVATE options_parser)
# TBB
find_package(TBB REQUIRED)
target_link_libraries(${EXE_NAME} TBB::tbb)

#! Add external packages
# options_parser requires boost::program_options library
find_package(Boost 1.71.0 COMPONENTS program_options system REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::system)
find_package(Boost 1.71.0 COMPONENTS locale program_options system REQUIRED)
target_include_directories(${EXE_NAME} PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(${EXE_NAME} Boost::program_options Boost::system Boost::locale)

# Add Libarchive
#set(LibArchive_INCLUDE_DIR "/opt/homebrew/opt/libarchive/include")
find_package(LibArchive REQUIRED)
target_link_libraries(${EXE_NAME} LibArchive::LibArchive)

# Add Threads
find_package(Threads REQUIRED)
target_link_libraries(${EXE_NAME} Threads::Threads)

##########################################################
# Fixed CMakeLists.txt part
##########################################################

INSTALL(PROGRAMS
$<TARGET_FILE:${PROJECT_NAME}> # ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
$<TARGET_FILE:${EXE_NAME}> # ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
DESTINATION bin)

# Define ALL_TARGETS variable to use in PVS and Sanitizers
set(ALL_TARGETS ${PROJECT_NAME})
set(ALL_TARGETS ${EXE_NAME})

# Include CMake setup
include(cmake/main-config.cmake)
4 changes: 2 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set -o errexit
set -o nounset
set -o pipefail

debug_build=true
optimize_build=false
debug_build=false
optimize_build=true
remove_dirs=false
install_prefix=".."

Expand Down
23 changes: 23 additions & 0 deletions include/errcode_exception.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Created by mykola on 22.04.24.
//

#ifndef COUNTWORDS_PAR_PROFTOOLS_ERRCODE_EXCEPTION_H
#define COUNTWORDS_PAR_PROFTOOLS_ERRCODE_EXCEPTION_H

#include <exception>
#include <string>

class errcode_exception: public std::exception {
private:
int m_err_code;
std::string m_message;

public:
errcode_exception(int err_code, std::string_view msg): m_message(msg), m_err_code(err_code) {}

[[nodiscard]] const char* what() const noexcept override;
[[nodiscard]] int err_code() const noexcept;
};

#endif //COUNTWORDS_PAR_PROFTOOLS_ERRCODE_EXCEPTION_H
26 changes: 26 additions & 0 deletions include/time_measure.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Created by mykola on 22.04.24.
//

#ifndef COUNTWORDS_PAR_PROFTOOLS_TIME_MEASURE_H
#define COUNTWORDS_PAR_PROFTOOLS_TIME_MEASURE_H

#include <chrono>
#include <atomic>

inline std::chrono::high_resolution_clock::time_point
get_current_time_fenced()
{
std::atomic_thread_fence(std::memory_order_seq_cst);
auto res_time = std::chrono::high_resolution_clock::now();
std::atomic_thread_fence(std::memory_order_seq_cst);
return res_time;
}

template<class D>
inline long long to_ms(const D& d)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(d).count();
}

#endif //COUNTWORDS_PAR_PROFTOOLS_TIME_MEASURE_H
46 changes: 0 additions & 46 deletions options_parser/options_parser.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions options_parser/options_parser.h

This file was deleted.

13 changes: 13 additions & 0 deletions src/errcode_exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Created by mykola on 22.04.24.
//

#include "errcode_exception.h"

const char* errcode_exception::what() const noexcept {
return m_message.c_str();
}

int errcode_exception::err_code() const noexcept {
return m_err_code;
}
7 changes: 4 additions & 3 deletions main.cpp → src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include <iostream>
#include "options_parser.h"
#include "time_measure.h"
#include "errcode_exception.h"
#include "oneapi/tbb.h"


int main(int argc, char* argv[]) {
command_line_options_t command_line_options{argc, argv};
std::cout << "A flag value: " << command_line_options.get_A_flag() << std::endl;
return 0;
}

0 comments on commit fa9cbee

Please sign in to comment.