smanders / externpro

build external projects with cmake
MIT License
13 stars 12 forks source link

add SQLite #305

Closed smanders closed 3 years ago

smanders commented 3 years ago

https://www.sqlite.org/index.html https://github.com/sqlite/sqlite

smanders commented 3 years ago

I found that the sqlite repo on github doesn't have the amalgamation https://www.sqlite.org/amalgamation.html so I searched github to see if I could find a moderately maintained version of the amalgamation, if only to maintain a "patch" that introduced cmake...

I discovered a couple of options:

smanders commented 3 years ago

verified by building DDE, swapping out sqlite source code for sqlite library from externpro

diff --git a/Shared/SddbLIB/Sddb/CMakeLists.txt b/Shared/SddbLIB/Sddb/CMakeLists.txt
index 7d8ddf0..a285960 100644
--- a/Shared/SddbLIB/Sddb/CMakeLists.txt
+++ b/Shared/SddbLIB/Sddb/CMakeLists.txt
@@ -38,17 +38,10 @@ set(SenderReportDatabase_srcs
 source_group(SenderReportDatabase FILES ${SenderReportDatabase_srcs})
 list(APPEND ${lib_name}_libsrcs ${SenderReportDatabase_srcs})
 #######################################
-set(sqlite_srcs
-  sqlite/sqlite3.c
-  sqlite/sqlite3.h
-  sqlite/sqlite3ext.h
-  )
-source_group(sqlite FILES ${sqlite_srcs})
-list(APPEND ${lib_name}_libsrcs ${sqlite_srcs})
-#######################################
 add_library(${lib_name} STATIC ${${lib_name}_libsrcs})
 target_include_directories(${lib_name} PUBLIC ${Shared_SOURCE_DIR}/${lib_name}LIB)
-target_link_libraries(${lib_name} PUBLIC Sdmsg palam::async palam::utils)
+xpFindPkg(PKGS sqlite)
+target_link_libraries(${lib_name} PUBLIC Sdmsg palam::async palam::utils xpro::SQLite3)
 set_property(TARGET ${lib_name} PROPERTY FOLDER ${folder})
 xpLibdepTest(${lib_name})
 add_subdirectory(Test ${UNITTEST})
diff --git a/Shared/SddbLIB/Sddb/Common/Database.hpp b/Shared/SddbLIB/Sddb/Common/Database.hpp
index 055c3d2..df30fee 100644
--- a/Shared/SddbLIB/Sddb/Common/Database.hpp
+++ b/Shared/SddbLIB/Sddb/Common/Database.hpp
@@ -8,10 +8,9 @@
 #ifndef SDDB_DATABASE_HPP
 #define SDDB_DATABASE_HPP

-#include "Sddb/sqlite/sqlite3.h"
-
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
+#include <sqlite3.h>

 #include <map>
 #include <string>
diff --git a/Shared/SddbLIB/Sddb/Test/CMakeLists.txt b/Shared/SddbLIB/Sddb/Test/CMakeLists.txt
index 4ffbc91..9be441e 100644
--- a/Shared/SddbLIB/Sddb/Test/CMakeLists.txt
+++ b/Shared/SddbLIB/Sddb/Test/CMakeLists.txt
@@ -10,8 +10,7 @@ source_group("" FILES ${root_srcs})
 list(APPEND ${test_name}_srcs ${root_srcs})
 #######################################
 add_executable(${test_name} ${${test_name}_srcs})
-#TODO/NOTE: CMAKE_DL_LIBS is needed for sqlite. Hopefully it will go away once sqlite is part of externpro
-target_link_libraries(${test_name} PRIVATE ${lib_name} palam::filesys Boost::unit_test_framework ${CMAKE_DL_LIBS}) 
+target_link_libraries(${test_name} PRIVATE ${lib_name} palam::filesys Boost::unit_test_framework)
 set_property(TARGET ${test_name} PROPERTY FOLDER ${folder_unittest})
 add_test(NAME ${test_name} COMMAND ${test_name})
 xpSourceListAppend("${${test_name}_srcs}")
smanders commented 3 years ago

completed with commit to dev branch referenced above