Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux-cxx20-vcpkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
sudo ln -s $(which ccache) /usr/local/bin/$CC
sudo ln -s $(which ccache) /usr/local/bin/$CXX
$CXX --version
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_CHECK_HEADERS=ON
cmake --build build
- name: Compile
if: matrix.db == 'mysql'
Expand All @@ -127,7 +127,7 @@ jobs:
sudo ln -s $(which ccache) /usr/local/bin/$CC
sudo ln -s $(which ccache) /usr/local/bin/$CXX
$CXX --version
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_MYSQL=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_SQLITE3=OFF -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_MYSQL=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_SQLITE3=OFF -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic
cmake --build build
- name: Set up postgres
if: matrix.db == 'postgres'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-cxx20-vcpkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
export CMAKE_GENERATOR=Ninja
fi
$CXX --version
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF
cmake --build build -j 4
- name: Compile
if: matrix.db == 'mysql'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-cxx20-vcpkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Compile
if: matrix.db == 'sqlite'
run: |
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_CHECK_HEADERS=ON
cmake --build build --config Release -j4
- name: Compile
if: matrix.db == 'mysql'
Expand Down
46 changes: 39 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ option(SQLGEN_BUILD_TESTS "Build tests" OFF)

option(SQLGEN_BUILD_DRY_TESTS_ONLY "Build 'dry' tests only (those that do not require a database connection)" OFF)

option(SQLGEN_CHECK_HEADERS "Make sure that all headers are self-contained" OFF)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()


set(SQLGEN_USE_VCPKG_DEFAULT ON)

option(SQLGEN_USE_VCPKG "Use VCPKG to download and build dependencies" ${SQLGEN_USE_VCPKG_DEFAULT})
Expand All @@ -27,15 +28,15 @@ if (SQLGEN_USE_VCPKG)
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
endif()

if (SQLGEN_MYSQL)
if (SQLGEN_MYSQL OR SQLGEN_CHECK_HEADERS)
list(APPEND VCPKG_MANIFEST_FEATURES "mysql")
endif()

if (SQLGEN_POSTGRES)
if (SQLGEN_POSTGRES OR SQLGEN_CHECK_HEADERS)
list(APPEND VCPKG_MANIFEST_FEATURES "postgres")
endif()

if (SQLGEN_SQLITE3)
if (SQLGEN_SQLITE3 OR SQLGEN_CHECK_HEADERS)
list(APPEND VCPKG_MANIFEST_FEATURES "sqlite3")
endif()

Expand Down Expand Up @@ -66,7 +67,7 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

if(SQLGEN_MYSQL)
if(SQLGEN_MYSQL OR SQLGEN_CHECK_HEADERS)
list(APPEND SQLGEN_SOURCES src/sqlgen_mysql.cpp)
if (SQLGEN_USE_VCPKG)
if (NOT TARGET unofficial-libmariadb)
Expand All @@ -81,15 +82,15 @@ if(SQLGEN_MYSQL)
endif()
endif()

if (SQLGEN_POSTGRES)
if (SQLGEN_POSTGRES OR SQLGEN_CHECK_HEADERS)
list(APPEND SQLGEN_SOURCES src/sqlgen_postgres.cpp)
if (NOT TARGET PostgreSQL)
find_package(PostgreSQL REQUIRED)
endif()
target_link_libraries(sqlgen PUBLIC PostgreSQL::PostgreSQL)
endif()

if (SQLGEN_SQLITE3)
if (SQLGEN_SQLITE3 OR SQLGEN_CHECK_HEADERS)
list(APPEND SQLGEN_SOURCES src/sqlgen_sqlite.cpp)

if (SQLGEN_USE_VCPKG)
Expand Down Expand Up @@ -119,6 +120,37 @@ if (SQLGEN_BUILD_TESTS)
add_subdirectory(tests)
endif ()

if(SQLGEN_CHECK_HEADERS)
file(GLOB_RECURSE PROJECT_HEADERS "include/*.hpp")
find_package(reflectcpp CONFIG REQUIRED)

set(TEST_DIR "${CMAKE_CURRENT_BINARY_DIR}/self_contained_tests")
file(MAKE_DIRECTORY "${TEST_DIR}")

foreach(HEADER_FILE ${PROJECT_HEADERS})
string(MAKE_C_IDENTIFIER ${HEADER_FILE} HEADER_NAME)
set(TEST_SOURCE_FILE "${TEST_DIR}/test_${HEADER_NAME}.cpp")

file(GENERATE
OUTPUT ${TEST_SOURCE_FILE}
CONTENT "#include \"${HEADER_FILE}\"\n"
)

add_library(check_header_${HEADER_NAME} "${TEST_SOURCE_FILE}")

target_include_directories(check_header_${HEADER_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${ADDITIONAL_INCLUDE_DIRS}
)
target_link_libraries(check_header_${HEADER_NAME} PUBLIC reflectcpp::reflectcpp)
target_link_libraries(check_header_${HEADER_NAME} PUBLIC unofficial::libmariadb)
target_link_libraries(check_header_${HEADER_NAME} PUBLIC PostgreSQL::PostgreSQL)
target_link_libraries(check_header_${HEADER_NAME} PUBLIC unofficial::sqlite3::sqlite3)

add_custom_target(check_${HEADER_NAME} ALL DEPENDS check_header_${HEADER_NAME})
endforeach()
endif()

if (PROJECT_IS_TOP_LEVEL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
36 changes: 0 additions & 36 deletions include/sqlgen/dynamic/select.hpp

This file was deleted.

1 change: 1 addition & 0 deletions include/sqlgen/internal/collect/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SQLGEN_INTERNAL_COLLECT_VECTOR_HPP_

#include <ranges>
#include <vector>

namespace sqlgen::internal::collect {

Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/parsing/Parser_timestamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../dynamic/Type.hpp"
#include "../dynamic/types.hpp"
#include "Parser_base.hpp"
#include "Parser_default.hpp"

namespace sqlgen::parsing {

Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/parsing/Parser_varchar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../dynamic/Type.hpp"
#include "../dynamic/types.hpp"
#include "Parser_base.hpp"
#include "Parser_default.hpp"

namespace sqlgen::parsing {

Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/rollback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Ref.hpp"
#include "Result.hpp"
#include "Transaction.hpp"
#include "is_connection.hpp"

namespace sqlgen {
Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/transpilation/get_table_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "../Literal.hpp"
#include "../Result.hpp"
#include "../dynamic/JoinType.hpp"
#include "TableWrapper.hpp"

Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/transpilation/remove_reflection_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <memory>
#include <optional>
#include <rfl.hpp>

#include "has_reflection_method.hpp"

Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/transpilation/to_insert_or_write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utility>
#include <vector>

#include "../dynamic/Insert.hpp"
#include "../dynamic/Table.hpp"
#include "../internal/collect/vector.hpp"
#include "../internal/remove_auto_incr_primary_t.hpp"
Expand Down
1 change: 1 addition & 0 deletions include/sqlgen/update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Result.hpp"
#include "is_connection.hpp"
#include "transpilation/to_update.hpp"
#include "where.hpp"

namespace sqlgen {

Expand Down
Loading