Skip to content

Commit

Permalink
Install boost, add demo for boost log
Browse files Browse the repository at this point in the history
  • Loading branch information
autosquash committed Jan 6, 2024
1 parent 00fc834 commit 45f1e07
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(pizzeria LANGUAGES CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# SFML
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
Expand All @@ -18,6 +19,13 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(googletest)

# Boost
set(BOOST_ROOT $ENV{BOOST_ROOT})
set(BOOST_LIBRARYDIR "$ENV{BOOST_ROOT}/stage/lib")
find_package(Boost 1.82 REQUIRED COMPONENTS log)
include_directories( ${Boost_INCLUDE_DIRS} )
link_directories(${BOOST_LIBRARYDIR})


add_executable(pizzeria
src/main.cpp
Expand Down Expand Up @@ -57,14 +65,15 @@ add_executable(pizzeria
src/vista/presentador.cpp
src/vista/vista.cpp
src/vista/basicos_vista.cpp
src/demos/boost_log.cpp
src/demos/demo_nivel.cpp
src/demos/map.cpp
src/demos/prueba.cpp
src/demos/unicode.cpp
src/demos/visual.cpp
src/demos/visual_textos.cpp
)
target_link_libraries(pizzeria PRIVATE sfml-graphics sfml-audio)
target_link_libraries(pizzeria PRIVATE sfml-graphics sfml-audio Boost::log)
target_compile_features(pizzeria PRIVATE cxx_std_17)

# Tratar los warnings como errores en modo Debug.
Expand Down Expand Up @@ -135,6 +144,7 @@ add_executable(
src/vista/presentador.cpp
src/vista/vista.cpp
src/vista/basicos_vista.cpp
src/demos/boost_log.cpp
src/demos/demo_nivel.cpp
src/demos/map.cpp
src/demos/prueba.cpp
Expand Down
16 changes: 16 additions & 0 deletions src/demos/boost_log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "boost_log.h"
#include <boost/log/trivial.hpp>
#include <iostream>

#define LOG BOOST_LOG_TRIVIAL

int demo_boost_log() {
std::cout << "Prueba de Boost Log" << std::endl;
LOG(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}
5 changes: 5 additions & 0 deletions src/demos/boost_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../shared.h"

int demo_boost_log();
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "demos/boost_log.h"
#include "demos/demo_nivel.h"
#include "demos/map.h"
#include "demos/min_ex.h"
Expand All @@ -13,6 +14,7 @@
#define USER_ERROR 1

enum class AppNombrada {
Boost,
Juego,
Nivel,
Visual,
Expand All @@ -26,6 +28,7 @@ enum class AppNombrada {

const std::map<std::string, AppNombrada> cadena_to_app_nombrada = {
{"", AppNombrada::Juego}, //
{"boost-log", AppNombrada::Boost}, //
{"nivel", AppNombrada::Nivel}, //
{"visual", AppNombrada::Visual}, //
{"textos", AppNombrada::Textos}, //
Expand Down Expand Up @@ -62,6 +65,9 @@ int _main(int argc, char *argv[]) {
case AppNombrada::Juego:
return juego();
break;
case AppNombrada::Boost:
return demo_boost_log();
break;
case AppNombrada::Nivel:
{
int num_nivel_introducido;
Expand Down

0 comments on commit 45f1e07

Please sign in to comment.