Skip to content

Commit 33b1013

Browse files
authored
Feat/build tests option (#68)
* Added build_tests CMake option * Added build_examples CMake option * Using std::string for path output * Removed not needed #include
1 parent b0fa8a8 commit 33b1013

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.12)
33

44
project("libdbcppp" VERSION 0.1.0)
55

6+
option(build_tests "Build tests" ON)
7+
option(build_examples "Build examples" ON)
8+
69
set(CMAKE_CXX_STANDARD 17)
710
set(CMAKE_STATIC_LIBRARY_PREFIX "")
811
set(CMAKE_SHARED_LIBRARY_PREFIX "")
@@ -50,8 +53,12 @@ install(
5053
FILES_MATCHING PATTERN "*.h")
5154

5255
add_subdirectory(src)
53-
add_subdirectory(tests)
54-
add_subdirectory(examples)
56+
if (build_tests)
57+
add_subdirectory(tests)
58+
endif()
59+
if (build_examples)
60+
add_subdirectory(examples)
61+
endif()
5562

5663
set(CMAKE_STATIC_LIBRARY_PREFIX "")
5764
set(CMAKE_SHARED_LIBRARY_PREFIX "")

examples/BasicUsage/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "../../include/dbcppp/CApi.h"
66
#include "../../include/dbcppp/Network.h"
7-
#include "../../tests/Config.h"
87

98
// from uapi/linux/can.h
109
using canid_t = uint32_t;
@@ -53,7 +52,7 @@ int main()
5352
{
5453
std::unique_ptr<dbcppp::INetwork> net;
5554
{
56-
std::ifstream idbc(TEST_DBC);
55+
std::ifstream idbc("your.dbc");
5756
net = dbcppp::INetwork::LoadDBCFromIs(idbc);
5857
}
5958
std::unordered_map<uint64_t, const dbcppp::IMessage*> messages;

tests/DBCParserTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TEST_CASE("DBCParserTest", "[]")
2020
{
2121
continue;
2222
}
23-
std::cout << "Testing DBC grammar with file: " << dbc_file << std::endl;
23+
std::cout << "Testing DBC grammar with file: " << dbc_file.path() << std::endl;
2424
auto dbc_file_tmp = dbc_file.path().string() + ".tmp";
2525
std::unique_ptr<dbcppp::INetwork> spec;
2626
std::unique_ptr<dbcppp::INetwork> test;

0 commit comments

Comments
 (0)