diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 089084b..5b8f5c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,8 @@ jobs: CXXFLAGS=-std=c++17 ./configure make sudo make install - - run: g++ -std=c++17 -Wall -Wextra -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq - - run: test/pqxx + - run: cmake -S test -B test/build + - run: cmake --build test/build # test install - run: cmake -S . -B build diff --git a/.gitignore b/.gitignore index b9d3146..378eac2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ build -/test/pqxx diff --git a/README.md b/README.md index 4dc3569..63b4edd 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ To get started with development: git clone https://github.com/pgvector/pgvector-cpp.git cd pgvector-cpp createdb pgvector_cpp_test -g++ -std=c++17 -Wall -Wextra -Wno-unknown-attributes -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq -test/pqxx +cmake -S test -B test/build +cmake --build test/build ``` To run an example: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..68a0b53 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.18) + +project(test) + +set(CMAKE_CXX_STANDARD 17) + +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unknown-attributes -Werror") +set(SKIP_BUILD_TEST ON) + +include(FetchContent) + +FetchContent_Declare(libpqxx GIT_REPOSITORY https://github.com/jtv/libpqxx.git GIT_TAG 7.10.0) +FetchContent_MakeAvailable(libpqxx) + +add_subdirectory("${PROJECT_SOURCE_DIR}/.." pgvector) + +add_executable(pqxx_test pqxx_test.cpp) +target_link_libraries(pqxx_test PRIVATE libpqxx::pqxx pgvector::pgvector) +add_custom_command(TARGET pqxx_test POST_BUILD COMMAND "${CMAKE_CURRENT_BINARY_DIR}/pqxx_test") diff --git a/test/pqxx_test.cpp b/test/pqxx_test.cpp index d5004d1..f57b202 100644 --- a/test/pqxx_test.cpp +++ b/test/pqxx_test.cpp @@ -1,6 +1,6 @@ -#include "../include/pgvector/pqxx.hpp" #include #include +#include #include void setup(pqxx::connection &conn) {