Skip to content

Commit 987c1dc

Browse files
committed
Use CMake for tests
1 parent ce7f299 commit 987c1dc

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ jobs:
2121
CXXFLAGS=-std=c++17 ./configure
2222
make
2323
sudo make install
24-
- run: g++ -std=c++17 -Wall -Wextra -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
25-
- run: test/pqxx
24+
- run: cmake -S test -B test/build
25+
- run: cmake --build test/build
26+
- run: test/build/pqxx_test
2627

2728
# test install
2829
- run: cmake -S . -B build

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
build
2-
/test/pqxx

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ To get started with development:
106106
git clone https://github.com/pgvector/pgvector-cpp.git
107107
cd pgvector-cpp
108108
createdb pgvector_cpp_test
109-
g++ -std=c++17 -Wall -Wextra -Wno-unknown-attributes -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
110-
test/pqxx
109+
cmake -S test -B test/build
110+
cmake --build test/build
111+
test/build/pqxx_test
111112
```
112113

113114
To run an example:

test/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
3+
project(test)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
7+
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unknown-attributes -Werror")
8+
set(SKIP_BUILD_TEST ON)
9+
10+
include(FetchContent)
11+
12+
FetchContent_Declare(libpqxx GIT_REPOSITORY https://github.com/jtv/libpqxx.git GIT_TAG 7.10.0)
13+
FetchContent_MakeAvailable(libpqxx)
14+
15+
add_subdirectory("${PROJECT_SOURCE_DIR}/.." pgvector)
16+
17+
add_executable(pqxx_test pqxx_test.cpp)
18+
target_link_libraries(pqxx_test PRIVATE libpqxx::pqxx pgvector::pgvector)

test/pqxx_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "../include/pgvector/pqxx.hpp"
21
#include <cassert>
32
#include <optional>
3+
#include <pgvector/pqxx.hpp>
44
#include <pqxx/pqxx>
55

66
void setup(pqxx::connection &conn) {

0 commit comments

Comments
 (0)