Skip to content
Snippets Groups Projects
Commit c5b98248 authored by Armin Co's avatar Armin Co
Browse files

CMake improvements.

parents de3c9eda 9b79ff10
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,9 @@ endif()
## library for the app should be GTK independent
##
add_library( qpong_core
add_library(
qpong_core
Particle.cpp
ImageBuffer.cpp
Player.cpp
# Profiler.cpp
)
///
/// @file Profiler.cpp
/// @author Armin Co
///
/// @brief
#include "Profiler.hpp"
Profiler::Profiler(const char* name)
: m_name {name}
, m_stopped {false}
, m_verbose {Verbose::False}
{
m_startTimepoint = std::chrono::high_resolution_clock::now();
}
Profiler::~Profiler()
{
if (!m_stopped)
{
stop();
}
}
long Profiler::stop()
{
auto endTimepoint = std::chrono::high_resolution_clock::now();
m_stopped = true;
long mus = std::chrono::duration_cast<std::chrono::nanoseconds>(endTimepoint - m_startTimepoint).count();
if (m_verbose == Verbose::True)
{
std::cout << m_name << ": " << mus / 1000.0 / 1000.0<< "ms" << std::endl;
}
return mus;
}
\ No newline at end of file
///
/// @file Profiler.hpp
/// @author Armin Co
///
/// @brief Class to do some basic timing and profiling.
///
#ifndef QPONG_PROFILER_HPP
#define QPONG_PROFILER_HPP
#include <chrono>
#include <iostream>
enum class Verbose
{
True,
False
};
/// @brief Profiler class to do some basic timings.
///
class Profiler
{
public:
Profiler(const char* name);
~Profiler();
/// @brief Stops the timing and returns the time measured in nanoseconds.
///
long stop();
private:
const char* m_name;
Verbose m_verbose;
std::chrono::time_point<std::chrono::system_clock> m_startTimepoint;
bool m_stopped;
};
#endif
\ No newline at end of file
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(runUnitTests test_qpong.cpp)
include_directories(
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR}
)
target_link_libraries(runUnitTests gtest gtest_main)
target_link_libraries(runUnitTests qpong_core)
add_test(NAME a-test COMMAND ./tests/runUnitTests)
add_executable(
runUnitTests
test_qpong.cpp
)
target_link_libraries(
runUnitTests
gtest
gtest_main
)
target_link_libraries(
runUnitTests
qpong_core
)
......@@ -60,3 +60,6 @@ TEST(addInts, negativeValues)
{
ASSERT_EQ(-3 + -5, -8);
}
/// @todo Example for mocks and an explanation what they are.
///
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment