Skip to content

Commit

Permalink
Feat/build tests option (#68)
Browse files Browse the repository at this point in the history
* Added build_tests CMake option
* Added build_examples CMake option
* Using std::string for path output
* Removed not needed #include
  • Loading branch information
xR3b0rn authored May 29, 2021
1 parent b0fa8a8 commit 33b1013
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.12)

project("libdbcppp" VERSION 0.1.0)

option(build_tests "Build tests" ON)
option(build_examples "Build examples" ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
Expand Down Expand Up @@ -50,8 +53,12 @@ install(
FILES_MATCHING PATTERN "*.h")

add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(examples)
if (build_tests)
add_subdirectory(tests)
endif()
if (build_examples)
add_subdirectory(examples)
endif()

set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
Expand Down
3 changes: 1 addition & 2 deletions examples/BasicUsage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "../../include/dbcppp/CApi.h"
#include "../../include/dbcppp/Network.h"
#include "../../tests/Config.h"

// from uapi/linux/can.h
using canid_t = uint32_t;
Expand Down Expand Up @@ -53,7 +52,7 @@ int main()
{
std::unique_ptr<dbcppp::INetwork> net;
{
std::ifstream idbc(TEST_DBC);
std::ifstream idbc("your.dbc");
net = dbcppp::INetwork::LoadDBCFromIs(idbc);
}
std::unordered_map<uint64_t, const dbcppp::IMessage*> messages;
Expand Down
2 changes: 1 addition & 1 deletion tests/DBCParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST_CASE("DBCParserTest", "[]")
{
continue;
}
std::cout << "Testing DBC grammar with file: " << dbc_file << std::endl;
std::cout << "Testing DBC grammar with file: " << dbc_file.path() << std::endl;
auto dbc_file_tmp = dbc_file.path().string() + ".tmp";
std::unique_ptr<dbcppp::INetwork> spec;
std::unique_ptr<dbcppp::INetwork> test;
Expand Down

0 comments on commit 33b1013

Please sign in to comment.