Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sqlite3 as third party package #857

Merged
merged 5 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,8 @@ include(digestpp.cmake)
# cpp-httplib webserver and client
include(cpp-httplib.cmake)

#################
# Sqlite3 SQL Database
include(sqlite3.cmake)


1 change: 1 addition & 0 deletions external/bootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ set(EXTERNAL_INCLUDES
${cereal_INCLUDE_DIRS}
${digestpp_INCLUDE_DIRS}
${cpp-httplib_INCLUDE_DIRS}
${sqlite3_INCLUDE_DIRS}
${common_INCLUDE_DIRS}
${REPOSITORY_DIR}/external/common/include
)
Expand Down
62 changes: 62 additions & 0 deletions external/sqlite3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -----------------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2019, Numenta, Inc. Unless you have purchased from
# Numenta, Inc. a separate commercial license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero Public License for more details.
#
# You should have received a copy of the GNU Affero Public License
# along with this program. If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# -----------------------------------------------------------------------------
# This downloads and builds the sqlite3 library.
#
# SQLite is a C-language library that implements a small, fast, self-contained,
# high-reliability, full-featured, SQL database engine. SQLite is the most used
# database engine in the world.
#
# The current release is 3/32/3 (2020-06-18)
# The repository is at https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz
#
#
if(EXISTS ${REPOSITORY_DIR}/build/ThirdParty/share/sqlite3.tar.gz)
set(URL ${REPOSITORY_DIR}/build/ThirdParty/share/sqlite3.tar.gz)
else()
set(URL "https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz")
endif()

message(STATUS "Obtaining sqlite3")
include(DownloadProject/DownloadProject.cmake)
download_project(PROJ sqlite3
PREFIX ${EP_BASE}/sqlite3
URL ${URL}
GIT_SHALLOW ON
UPDATE_DISCONNECTED 1
QUIET
)

# SQLite does not provide a CMakeList.txt to buld with so we provide the following lines to perform the compile here.
# Since we are building here and not in the source folder, the library will show up directly under build/ThirdParty.
set(SRCS ${sqlite3_SOURCE_DIR}/sqlite3.c ${sqlite3_SOURCE_DIR}/sqlite3.h)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might need to explicitely tell CMake this is a C (not C++) file somewhere here

https://github.com/htm-community/htm.core/pull/857/checks?check_run_id=827912596#step:6:173

add_library(sqlite3 STATIC ${SRCS} )
target_compile_definitions(sqlite3 PRIVATE ${COMMON_COMPILER_DEFINITIONS})

set(sqlite3_INCLUDE_DIRS ${sqlite3_SOURCE_DIR}/include)
if (MSVC)
set(sqlite3_LIBRARIES "${CMAKE_BINARY_DIR}$<$<CONFIG:Release>:/Release/sqlite3.lib>$<$<CONFIG:Debug>:/Debug/sqlite3.lib>")
else()
set(sqlite3_LIBRARIES ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sqlite3${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()

FILE(APPEND "${EXPORT_FILE_NAME}" "sqlite3_INCLUDE_DIRS@@@${sqlite3_INCLUDE_DIRS}\n")
FILE(APPEND "${EXPORT_FILE_NAME}" "sqlite3_LIBRARIES@@@${sqlite3_LIBRARIES}\n")

2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ endif()
set(src_combined_htmcore_source_archives
${src_lib_static}
${yaml_LIBRARIES}
${sqlite3_LIBRARIES}
${Boost_LIBRARIES}
${common_LIBRARIES}
)
Expand All @@ -288,6 +289,7 @@ else()
set(all_object_locations)
set(src_externLibs
${yaml_LIBRARIES}
${sqlite3_LIBRARIES}
${Boost_LIBRARIES}
${common_LIBRARIES}
)
Expand Down