Skip to content

Commit 1e1d214

Browse files
authored
Prepare release (#18)
- rename folder - adjust external usable CMake variables - use consistent nameing (sl3 instead of libsl3) - update docs - test that repo can be consumed via fetch content
1 parent eeb1bcc commit 1e1d214

31 files changed

+130
-85
lines changed

.github/workflows/build-internal-sqlite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
if: startsWith(matrix.build.os, 'windows')
3838
uses: ilammy/msvc-dev-cmd@v1
3939
- name: Configure project
40-
run: cmake --preset ${{ matrix.build.preset }} -DPROJECT_ADDONS='add-on/fetch-dependencies' -DUSE_INTERNAL_SQLITE3=ON
40+
run: cmake --preset ${{ matrix.build.preset }} -DPROJECT_ADDONS='add-on/fetch-dependencies' -Dsl3_USE_INTERNAL_SQLITE3=ON
4141
- name: Build project
4242
run: cmake --build --preset ${{ matrix.build.preset }}-release --parallel --verbose
4343
- name: Run unit test

CMake/lib/libsl3Config.cmake.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,24 @@ project(libsl3
2222

2323

2424

25-
find_package(commonCompilerWarnings CONFIG REQUIRED)
26-
#find_package(sqlite CONFIG REQUIRED)
27-
28-
29-
# is in toolchain file now
30-
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
31-
3225
# done differently now
33-
LIST(PREPEND CMAKE_MODULE_PATH "${libsl3_SOURCE_DIR}/cmake/lib")
26+
LIST(PREPEND CMAKE_MODULE_PATH "${libsl3_SOURCE_DIR}/cmake")
3427

3528
#optional enable personal test/trial dir
3629
include(CMakeLocalOpts.cmake OPTIONAL)
3730

3831

39-
SET (USE_INTERNAL_SQLITE3 FALSE CACHE BOOL
40-
"use build-in sqlite3 ON, use system sqlite3 header/lib, OFF" )
32+
option(sl3_USE_INTERNAL_SQLITE3 "use build-in sqlite3 ON, use system sqlite3 header/lib, OFF" OFF)
33+
option(sl3_USE_COMMON_COMPILER_WARNINGS "Build using shared libraries" ON)
4134

42-
# TODO, reactivate that
43-
#include( setup_doc )
35+
if (sl3_USE_COMMON_COMPILER_WARNINGS)
36+
find_package(commonCompilerWarnings CONFIG REQUIRED)
37+
set(LIBWARNINGS a4z::commonCompilerWarnings)
38+
else(sl3_USE_COMMON_COMPILER_WARNINGS)
39+
add_library(all_warnings_off INTERFACE)
40+
set(LIBWARNINGS all_warnings_off)
41+
message(STATUS "sl3_USE_COMMON_COMPILER_WARNINGS is OFF")
42+
endif(sl3_USE_COMMON_COMPILER_WARNINGS)
4443

4544

4645
set(sl3_CONFIG_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/sl3/config.hpp")
@@ -90,18 +89,7 @@ target_include_directories(sl3 PUBLIC
9089
$<INSTALL_INTERFACE:include> # <prefix>/include/mylib
9190
)
9291

93-
# TODO, make this only when a top level project
94-
target_link_libraries(sl3 PRIVATE $<BUILD_INTERFACE:a4z::commonCompilerWarnings>)
95-
96-
# if (USE_INTERNAL_SQLITE3)
97-
# include( sqlite/setup_sqlite3.cmake )
98-
# else(USE_INTERNAL_SQLITE3)
99-
# find_package(SQLite3 REQUIRED)
100-
# # target_link_libraries(sl3 PUBLIC ${SQLite3_LIBRARIES})
101-
# # target_include_directories(sl3 SYSTEM BEFORE PRIVATE ${SQLite3_INCLUDE_DIRS})
102-
# # target_link_libraries(sl3 PUBLIC SQLite::SQLite3)
103-
# endif(USE_INTERNAL_SQLITE3)
104-
92+
target_link_libraries(sl3 PRIVATE $<BUILD_INTERFACE:${LIBWARNINGS}>)
10593

10694
include( lib/find_sqlite )
10795
target_link_libraries(sl3 PUBLIC ${SQLITE_LINK_NAME})
@@ -118,16 +106,14 @@ if(BUILD_SHARED_LIBS)
118106
)
119107
endif(BUILD_SHARED_LIBS)
120108

121-
if(BUILD_TESTING)
109+
if(sl3_BUILD_TESTING)
122110
add_subdirectory(tests)
123-
endif(BUILD_TESTING)
111+
endif(sl3_BUILD_TESTING)
124112

125113
include(lib/install)
126-
127114
include(lib/doxydoc)
128115

129-
include(CMakePrintSystemInformation)
130-
131-
include(CMakePrintHelpers)
132-
cmake_print_variables(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
116+
# include(CMakePrintSystemInformation)
117+
# include(CMakePrintHelpers)
118+
# cmake_print_variables(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
133119

CMakePresets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"version": 8,
33
"include": [
4-
"CMake/preset/ninja.json",
5-
"CMake/preset/xcode.json",
6-
"CMake/preset/msvc22.json"
4+
"cmake/preset/ninja.json",
5+
"cmake/preset/xcode.json",
6+
"cmake/preset/msvc22.json"
77
]
88
}
99

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ For people seeking the old version, release v1.1.31001 preserves the original C+
1313
**The full documentation for libsl3 can be found here:** <br>
1414
https://a4z.github.io/libsl3/
1515

16+
## Build
17+
18+
Quickly summarized, there are dependencies, but they are all either development dependencies or optional
19+
20+
- sqlite3
21+
- doctest
22+
- commonCompilerWarnings
23+
24+
### Consume via CMake
25+
26+
To build libsl3 without any dependencies, run
27+
28+
cmake -S . -B build -DBUILD_TESTING=OFF -Dsl3_USE_INTERNAL_SQLITE3=ON -Dsl3_USE_COMMON_COMPILER_WARNINGS=OFF
29+
30+
This will build libsl3 with the internal sqlite distribution.
31+
32+
For using sqlite from the system, run
33+
34+
cmake -S . -B build -DBUILD_TESTING=OFF -Dsl3_USE_COMMON_COMPILER_WARNINGS=OFF
35+
36+
For more information, visit the documentation. (TODO, link)
37+
1638
## A short usage example
1739

1840
```cpp
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

CMake/lib/find_sqlite.cmake renamed to cmake/lib/find_sqlite.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ Or someone whats to rely whats on the system (root fs on x compile for yocto)
4545
include(lib/debug)
4646
#print_all_variables()
4747

48-
if (USE_INTERNAL_SQLITE3)
48+
if (sl3_USE_INTERNAL_SQLITE3)
4949
include( sqlite/setup_sqlite3.cmake )
50-
else(USE_INTERNAL_SQLITE3)
50+
else(sl3_USE_INTERNAL_SQLITE3)
5151
if (_VCPKG_INSTALLED_DIR)
5252
find_package(unofficial-sqlite3 REQUIRED)
5353
set(SQLITE_LINK_NAME unofficial::sqlite3::sqlite3)
5454
else()
5555
find_package(SQLite3 REQUIRED)
5656
set(SQLITE_LINK_NAME SQLite::SQLite3)
5757
endif()
58-
endif(USE_INTERNAL_SQLITE3)
58+
endif(sl3_USE_INTERNAL_SQLITE3)
5959

6060
# print_variable(SQLite3_INCLUDE_DIR)
6161
# print_variable(SQLite3_LIBRARY)

CMake/lib/install.cmake renamed to cmake/lib/install.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@ include_guard(GLOBAL)
22

33
include(GNUInstallDirs)
44

5-
install(TARGETS sl3 EXPORT libsl3Targets)
5+
install(TARGETS sl3 EXPORT sl3Targets)
66
INSTALL(FILES ${sl3_HDR} DESTINATION include/sl3)
77
INSTALL(FILES include/sl3.hpp DESTINATION include/sl3)
88

9-
install(EXPORT libsl3Targets
10-
FILE libsl3Targets.cmake
9+
install(EXPORT sl3Targets
10+
FILE sl3Targets.cmake
1111
NAMESPACE a4z::
1212
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
1313
)
1414

1515
include(CMakePackageConfigHelpers)
1616
write_basic_package_version_file(
17-
${CMAKE_CURRENT_BINARY_DIR}/libsl3ConfigVersion.cmake
17+
${CMAKE_CURRENT_BINARY_DIR}/sl3ConfigVersion.cmake
1818
COMPATIBILITY AnyNewerVersion
1919
)
2020
configure_package_config_file(
21-
${CMAKE_CURRENT_LIST_DIR}/libsl3Config.cmake.in
22-
${CMAKE_CURRENT_BINARY_DIR}/libsl3Config.cmake
21+
${CMAKE_CURRENT_LIST_DIR}/sl3Config.cmake.in
22+
${CMAKE_CURRENT_BINARY_DIR}/sl3Config.cmake
2323
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
2424
)
2525

2626
install(
2727
FILES
28-
${CMAKE_CURRENT_BINARY_DIR}/libsl3Config.cmake
29-
${CMAKE_CURRENT_BINARY_DIR}/libsl3ConfigVersion.cmake
28+
${CMAKE_CURRENT_BINARY_DIR}/sl3Config.cmake
29+
${CMAKE_CURRENT_BINARY_DIR}/sl3ConfigVersion.cmake
3030
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
3131

3232
)

cmake/lib/setup-warnings.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include_guard(GLOBAL)
2+

cmake/lib/sl3Config.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/sl3Targets.cmake")
4+
5+
check_required_components("sl3")

CMake/lib/testing.cmake renamed to cmake/lib/testing.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ function (add_doctest NAME)
2222

2323
add_executable(sl3test-${NAME} ${D_TEST_SOURCES} $<TARGET_OBJECTS:doctest_main>)
2424
# use naming what we had for now
25-
target_link_libraries(sl3test-${NAME} PRIVATE sl3 ${CON_DOCTEST}
26-
# a4z::commonCompilerWarnings
27-
# "$<BUILD_INTERFACE:a4z:commonCompilerWarnings>"
25+
target_link_libraries(sl3test-${NAME}
26+
PRIVATE
27+
sl3
28+
${CON_DOCTEST}
29+
$<BUILD_INTERFACE:${LIBWARNINGS}>
2830
)
29-
target_link_libraries(sl3test-${NAME} PRIVATE $<BUILD_INTERFACE:a4z::commonCompilerWarnings>)
31+
#target_link_libraries(sl3test-${NAME} PRIVATE $<BUILD_INTERFACE:a4z::commonCompilerWarnings>)
3032

3133
if(NOT D_TEST_TIMEOUT)
3234
set(D_TEST_TIMEOUT 3)

CMake/preset/base.json renamed to cmake/preset/base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"cacheVariables": {
1111
"CMAKE_COMPILE_WARNING_AS_ERROR": "ON",
1212
"ACTIVE_PRESET_NAME": "${presetName}",
13-
"CMAKE_MODULE_PATH": "${sourceDir}/CMake",
13+
"CMAKE_MODULE_PATH": "${sourceDir}/cmake",
1414
"CMAKE_PROJECT_INCLUDE": "project-setup"
1515
},
1616
"environment": {
File renamed without changes.
File renamed without changes.
File renamed without changes.

CMake/project-setup.cmake renamed to cmake/project-setup.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1313
if(PROJECT_IS_TOP_LEVEL)
1414
# make git ignore the build directory
1515
file(WRITE ${CMAKE_BINARY_DIR}/.gitignore "*")
16-
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
17-
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
18-
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
1916
include(CTest)
17+
option(sl3_BUILD_TESTING "Build the tests" ${BUILD_TESTING})
2018
endif()
2119

2220

File renamed without changes.
File renamed without changes.
File renamed without changes.

conanfile.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/doc.dox

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,46 @@ The library fully supports the SQLite duck typing concept, but it also offers a
1414
libsl3 stared as a C++98 project long time ago.
1515
Later, when C++11 was new, it became <i>a modern C++11 interface to sqlite</i>.
1616
Today, libsl3 it's still around. A C++ interface for SQLite.
17-
18-
Today, active development is on pause, but the library is still maintained and updated of required.
17+
Active development happens rarely but the library is still maintained and updated if required.
1918

2019
\section Installation
2120

21+
libsl3 can be build and consumed without any external dependencies. But you might want to use sqlite3 installations from your system.
22+
23+
\subsection consume Consuming sl3 in a CMake project
24+
25+
An easy way is consuming sl3 via CMake's 'FetchContent'
26+
27+
\code
28+
cmake_minimum_required(VERSION 3.29)
29+
30+
project(consume_sl3)
31+
32+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33+
set(CMAKE_CXX_STANDARD 20)
34+
35+
include(FetchContent)
36+
FetchContent_Declare(
37+
sl3
38+
GIT_REPOSITORY https://github.com/a4z/libsl3.git
39+
GIT_TAG main
40+
OVERRIDE_FIND_PACKAGE
41+
)
42+
SET(BUILD_TESTING OFF)
43+
SET(sl3_USE_INTERNAL_SQLITE3 ON)
44+
SET(sl3_USE_COMMON_COMPILER_WARNINGS OFF)
45+
46+
find_package(sl3 CONFIG REQUIRED)
47+
48+
add_executable(consume_sl3 main.cpp)
49+
target_link_libraries(consume_sl3 PRIVATE sl3)
50+
\endcode
51+
52+
If you want to use the system sqlite3 installation, you can omit the line
53+
`SET(sl3_USE_INTERNAL_SQLITE3 ON)`
54+
55+
\section build_from_source Building sl3 from source
56+
2257
Get you copy of the source code from the <a href="https://github.com/a4z/libsl3">libsl3 GitHub repository</a>.
2358

2459
The project has the following dependencies:
@@ -28,11 +63,19 @@ The project has the following dependencies:
2863
\li Optional: <a href="https://www.doxygen.nl">doxygen</a> for buliding the documentation
2964
\li Optional: <a href="https://github.com/doctest/doctest">doctest</a> for unit testing
3065

66+
\subsection deal_dependencies Dependency management
67+
68+
There are 3 options to deal with dependencies.
69+
70+
\li Ignore them, and turn them off. (No testing and internal sqlite3)
71+
\li Use vcpkg, a package manager for C++ libraries
72+
\li Use CMake's FetchContent to fetch the dependencies
73+
3174
If doxygen is not found it will not be possible to build the documentation.
3275

33-
doctest is fetched on demand, except if \c BUILD_TESTING is set to OFF.
76+
See below for how to use either vcpkg or FetchContent.
3477

35-
\subsection build Building the library
78+
\subsection build Building the library (developer mode)
3679

3780
The library can be build with CMake. No surprises here.
3881

@@ -63,20 +106,20 @@ ctest --preset msvc22
63106
In case you do not have vcpkg installed, the most simple way to get started is
64107

65108
\code
66-
cmake --preset ninja -DPROJECT_ADDONS=add-on/fetch-dependencies -DUSE_INTERNAL_SQLITE3=ON
109+
cmake --preset ninja -DPROJECT_ADDONS=add-on/fetch-dependencies -Dsl3_USE_INTERNAL_SQLITE3=ON
67110
\endcode
68111

69-
If you have sqlite3 installed on your system, you can use it by omitting -DUSE_INTERNAL_SQLITE3=ON
112+
If you have sqlite3 installed on your system, you can use it by omitting -Dsl3_USE_INTERNAL_SQLITE3=ON
70113

71114

72115
<b>CMake options to control the build process:</b>
73116

74-
\li \c USE_INTERNAL_SQLITE3:<BR>
117+
\li \c sl3_USE_INTERNAL_SQLITE3:<BR>
75118
If set to ON, the internal sqlite3 source code will be used.<BR>
76119
If set to OFF, the system sqlite3 will be used.<BR>
77120
Default is ON.
78121

79-
\li \c BUILD_TESTING:<BR>
122+
\li \c sl3_BUILD_TESTING:<BR>
80123
If set to ON, test targets will be added .<BR>
81124
Default is ON.
82125

@@ -98,13 +141,13 @@ Programs consuming libsl3 do not need to link against sqlite3.
98141
\li Slightly longer build time for building libsl3
99142
(not for programs consuming libsl3)
100143

101-
\section Testing
144+
\subsection Testing
102145

103146
All the tests can be found in the tests subdirectory. <BR>
104147
Existing tests try to cover as much as possible, see the <a href=coverage/index.html>coverage report</a> for details.
105148

106149

107-
\section overview Overview
150+
\section overview Usage Overview
108151

109152
A database is represented via sl3::Database. <BR>
110153
A database can execute SQL strings to read or write data. <BR>

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

sqlite/setup_sqlite3.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ target_link_libraries( sl3 PUBLIC ${CMAKE_THREAD_LIBS_INIT} )
129129
#message(STATUS "**DEFINES ARE: "${mysqlt3_DEFINES} )
130130
#message(STATUS "**LIBRARIES ARE: "${sl3_sqlite3LIBS} )
131131

132-
# else (USE_INTERNAL_SQLITE3)
132+
# else (sl3_USE_INTERNAL_SQLITE3)
133133
# INCLUDE(FindPkgConfig)
134134

135135
# # TODO define a minimum version 3.3.8

0 commit comments

Comments
 (0)