Skip to content

Commit c5b08f7

Browse files
committed
small bugfixes in project, refactored clang-format.cmake and clang-tidy.cmake
1 parent 8478e8d commit c5b08f7

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}")
8787
include(cmake/3rdParty.cmake)
8888
include(cmake/CompileOptions.cmake)
8989

90-
include(cmake/Clang-Format.cmake)
91-
include(cmake/Clang-Tidy.cmake)
9290
#
9391
# Deployment/installation setup
9492
#
@@ -174,3 +172,6 @@ install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
174172

175173
# Install runtime data
176174
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime)
175+
176+
include(cmake/Clang-Format.cmake)
177+
include(cmake/Clang-Tidy.cmake)

cmake/Clang-Format.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
file(GLOB_RECURSE ALL_SOURCE_FILES "*.cpp" "*.h")
2-
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
1+
# Adding clang-tidy target if executable is found
2+
find_program(CLANG_FORMAT "clang-format")
3+
if(CLANG_FORMAT)
4+
file(GLOB_RECURSE ALL_SOURCE_FILES "*.cpp" "*.h")
5+
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
36
string(FIND "${SOURCE_FILE}" "${CMAKE_BINARY_DIR}" PROJECT_TRDPARTY_DIR_FOUND)
47
if (NOT "${PROJECT_TRDPARTY_DIR_FOUND}" EQUAL "-1")
5-
list(REMOVE_ITEM ALL_SOURCE_FILES "${SOURCE_FILE}")
8+
list(REMOVE_ITEM ALL_SOURCE_FILES "${SOURCE_FILE}")
69
endif ()
7-
endforeach ()
10+
endforeach ()
811

9-
# Adding clang-tidy target if executable is found
10-
find_program(CLANG_FORMAT "clang-format")
11-
if(CLANG_FORMAT)
1212
add_custom_target(
1313
clang-format
1414
COMMAND clang-format

cmake/Clang-Tidy.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
file(GLOB_RECURSE ALL_SOURCE_FILES "*.cpp" "*.h")
2-
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
3-
string(FIND "${SOURCE_FILE}" "${CMAKE_BINARY_DIR}" PROJECT_TRDPARTY_DIR_FOUND)
4-
if (NOT "${PROJECT_TRDPARTY_DIR_FOUND}" EQUAL "-1")
5-
list(REMOVE_ITEM ALL_SOURCE_FILES "${SOURCE_FILE}")
6-
endif ()
7-
endforeach ()
8-
91
# Adding clang-tidy target if executable is found
102
find_program(CLANG_TIDY "clang-tidy")
113
if(CLANG_TIDY)
4+
file(GLOB_RECURSE ALL_SOURCE_FILES "*.cpp" "*.h")
5+
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
6+
string(FIND "${SOURCE_FILE}" "${CMAKE_BINARY_DIR}" PROJECT_TRDPARTY_DIR_FOUND)
7+
if (NOT "${PROJECT_TRDPARTY_DIR_FOUND}" EQUAL "-1")
8+
list(REMOVE_ITEM ALL_SOURCE_FILES "${SOURCE_FILE}")
9+
endif ()
10+
endforeach ()
11+
1212
add_custom_target(
1313
clang-tidy
1414
COMMAND clang-tidy

source/annotatorlib/source/Loader/XMLLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <AnnotatorLib/Object.h>
1111
#include <AnnotatorLib/Session.h>
1212

13+
#include <fstream>
1314
#include <memory>
1415

1516
#include <boost/algorithm/string.hpp>

source/annotatorlib/source/Project.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ void Project::create() {
9393
*
9494
*/
9595
void Project::load() {
96-
std::istringstream istr(path);
96+
std::fstream istr;
97+
istr.open(path, std::ios::in);
9798
Poco::AutoPtr<Poco::Util::XMLConfiguration> config =
9899
new Poco::Util::XMLConfiguration(istr);
99100

@@ -113,6 +114,7 @@ void Project::load() {
113114
this->imageSet = AnnotatorLib::ImageSetFactory::createImageSet(
114115
this->imageSetType, imageSetPath);
115116

117+
istr.close();
116118
loadSession();
117119
}
118120

@@ -126,7 +128,8 @@ void Project::loadSession() {
126128
}
127129

128130
void Project::saveConfig() {
129-
std::ofstream ostr(path, std::ios::out);
131+
std::fstream ostr;
132+
ostr.open(path, std::ios::out);
130133

131134
Poco::XML::DOMWriter writer;
132135
writer.setNewLine("\n");
@@ -146,6 +149,7 @@ void Project::saveConfig() {
146149
config->setBool("Settings[@active]", this->active);
147150

148151
config->save(writer, ostr);
152+
ostr.close();
149153
}
150154

151155
void Project::save(std::shared_ptr<AnnotatorLib::Project> project,

source/tests/annotatorlib-test/project_test.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ class project_test : public testing::Test {
1414

1515
TEST_F(project_test, saveProject) {
1616
try {
17-
std::string path =
18-
"/home/chriamue/builds/build-annotatorlib-Desktop-Debug/test.xml";
17+
std::string path = "test.xml";
1918
std::shared_ptr<AnnotatorLib::Project> project =
2019
Project::create("testname", "images", "", "json", "test.json");
2120
project->setPath(path);
22-
project->load();
21+
// project->load();
2322
std::shared_ptr<Session> session = project->getSession();
2423
shared_ptr<Object> object = std::make_shared<Object>();
2524
object->setName("testobject");
@@ -103,4 +102,3 @@ TEST_F(project_test, equals) {
103102

104103
ASSERT_TRUE(project->equals(project6));
105104
}
106-

0 commit comments

Comments
 (0)