Skip to content

Commit 67cc662

Browse files
author
Aleksandar Glisic
committed
New main
1 parent e4e7624 commit 67cc662

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ set(SNITCH_SOURCES_INDIVIDUAL
116116
${PROJECT_SOURCE_DIR}/src/snitch_test_data.cpp
117117
${PROJECT_SOURCE_DIR}/src/snitch_time.cpp)
118118

119-
if (SNITCH_UNITY_BUILD)
120-
set(SNITCH_SOURCES ${PROJECT_SOURCE_DIR}/src/snitch.cpp)
119+
if (SNITCH_ENABLE)
120+
if (SNITCH_UNITY_BUILD)
121+
set(SNITCH_SOURCES ${PROJECT_SOURCE_DIR}/src/snitch.cpp)
122+
else()
123+
set(SNITCH_SOURCES ${SNITCH_SOURCES_INDIVIDUAL})
124+
endif()
121125
else()
122-
set(SNITCH_SOURCES ${SNITCH_SOURCES_INDIVIDUAL})
126+
set(SNITCH_SOURCES ${PROJECT_SOURCE_DIR}/src/snitch_main.cpp)
123127
endif()
124128

125129
function(configure_snitch_exports TARGET)
@@ -212,7 +216,7 @@ install(FILES
212216
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/snitch COMPONENT Development)
213217

214218
# Setup tests
215-
if (SNITCH_DO_TEST)
219+
if (SNITCH_DO_TEST AND SNITCH_ENABLE)
216220
enable_testing()
217221

218222
# We need to use a different snitch configuration for tests, so we can't reuse

src/snitch_main.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "snitch/snitch_cli.hpp"
22
#include "snitch/snitch_registry.hpp"
33

4-
#if SNITCH_DEFINE_MAIN
5-
SNITCH_EXPORT int main(int argc, char* argv[]) {
4+
namespace snitch {
5+
SNITCH_EXPORT int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) {
6+
#if SNITCH_ENABLE
67
std::optional<snitch::cli::input> args = snitch::cli::parse_arguments(argc, argv);
78
if (!args) {
89
return 1;
@@ -11,5 +12,14 @@ SNITCH_EXPORT int main(int argc, char* argv[]) {
1112
snitch::tests.configure(*args);
1213

1314
return snitch::tests.run_tests(*args) ? 0 : 1;
14-
}
15+
#else
16+
return 0;
1517
#endif
18+
}
19+
}
20+
21+
#if SNITCH_DEFINE_MAIN
22+
SNITCH_EXPORT int main(int argc, char* argv[]) {
23+
return snitch::main(argc, argv);
24+
}
25+
#endif

0 commit comments

Comments
 (0)