Commit 1bae1081 authored by Jaime Arias's avatar Jaime Arias
Browse files

Fix CMakeLists files. Add examples folder for test

parent da3fab70
...@@ -4,7 +4,12 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) ...@@ -4,7 +4,12 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language # project name and language
project(pn-parser LANGUAGES CXX) project(pn-parser LANGUAGES CXX)
# variables
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(EXAMPLES_DIR "${PROJECT_SOURCE_DIR}/examples")
# add source folder # add source folder
include_directories (${SRC_DIR})
add_subdirectory(src) add_subdirectory(src)
# add tests # add tests
......
# set minimum cmake version # set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language # compilator flags
project(pn-parser-src LANGUAGES CXX) project(pn-parser-src LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
# dependencies # dependencies
find_package(BISON REQUIRED) find_package(BISON REQUIRED)
find_package(FLEX REQUIRED) find_package(FLEX REQUIRED)
# execute bison and flex # execute bison
bison_target(rdp_parser RdPMonteur.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c) BISON_TARGET(
flex_target(rdp_scanner RdPMonteur.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c) RdPMonteurParser
add_flex_bison_dependency(rdp_scanner rdp_parser) RdPMonteur.y ${CMAKE_CURRENT_BINARY_DIR}/RdPMonteur.tab.cpp
)
# execute flex
FLEX_TARGET(
RdPMonteurLexer
RdPMonteur.l ${CMAKE_CURRENT_BINARY_DIR}/RdPMonteur.lex.cpp
)
ADD_FLEX_BISON_DEPENDENCY(RdPMonteurLexer RdPMonteurParser)
# generate a the library from sources # generate a the library from sources
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(RdP STATIC
add_library(RdP ${BISON_RdPMonteurParser_OUTPUTS}
STATIC ${FLEX_RdPMonteurLexer_OUTPUTS}
Net.h Net.hpp
Net.cpp Net.cpp
RdPMonteur.h RdPMonteur.hpp
${BISON_rdp_parser_OUTPUTS}
${FLEX_rdp_scanner_OUTPUTS}
) )
#include "Net.h" #include "Net.hpp"
#include <algorithm> #include <algorithm>
#include <ext/hash_map> #include <ext/hash_map>
#include <iomanip> #include <iomanip>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include <vector> #include <vector>
#include "RdPMonteur.h" #include "RdPMonteur.hpp"
typedef set<int> Set; typedef set<int> Set;
class Node { class Node {
public: public:
......
%{ %{
/************* INCLUDES AND EXTERNALS *************************************/ /************* INCLUDES AND EXTERNALS *************************************/
extern "C" int yylex();
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "RdPMonteur.tab.h" #include "RdPMonteur.tab.hpp"
%} %}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <string> #include <string>
#include <stdio.h> #include <stdio.h>
#include "RdPMonteur.h" #include "RdPMonteur.hpp"
static RdPMonteur *R; static RdPMonteur *R;
static string t; static string t;
......
...@@ -11,5 +11,6 @@ target_link_libraries(RdPtest RdP) ...@@ -11,5 +11,6 @@ target_link_libraries(RdPtest RdP)
# Add test # Add test
add_test( add_test(
NAME tests NAME tests
WORKING_DIRECTORY ${EXAMPLES_DIR}
COMMAND RdPtest COMMAND RdPtest
) )
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "Net.h" #include "Net.hpp"
#include "catch.hpp" #include "catch.hpp"
TEST_CASE("Parsing simple file", "[Simple]") { TEST_CASE("Parsing simple file", "[Simple]") {
net R("../examples/ring2.net", "../examples/Obs2_ring", ""); net model("ring2.net", "Obs2_ring");
REQUIRE(model.nbPlace() == 16);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment