Skip to content

Commit 33e4c13

Browse files
committed
Set up testing using CMake and CTest
1 parent a4a49d0 commit 33e4c13

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ install(FILES "${PKG_CONFIG_FILE_NAME}"
9797
COMPONENT "sdk"
9898
)
9999

100+
option(WITH_TESTS ON "Build tests")
101+
102+
if(WITH_TESTS)
103+
find_package(Catch2)
104+
include(Catch)
105+
106+
add_executable(tests "${CMAKE_CURRENT_SOURCE_DIR}/test.cpp")
107+
target_link_libraries(tests PRIVATE ${PROJECT_NAME} Catch2::Catch2)
108+
109+
catch_discover_tests(tests)
110+
enable_testing()
111+
endif()
112+
100113

101114
include(CPack)
102115

test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*/
99
#include "anyoption.h"
10-
#include "catch.hpp"
10+
#include <catch2/catch.hpp>
1111

1212
#include <fstream>
1313
#include <stdarg.h>

0 commit comments

Comments
 (0)