sqlitecpp cmake nonsense

This commit is contained in:
Thomas Winget 2021-10-06 19:04:23 -04:00
parent df07ae3e40
commit 73e787a9ec
5 changed files with 31 additions and 10 deletions

View File

@ -506,10 +506,9 @@ endif()
if(NOT BUILD_STATIC_DEPS)
add_library(sqlite3 INTERFACE)
pkg_check_modules(SQLITE3 REQUIRED sqlite3 IMPORTED_TARGET)
pkg_check_modules(SQLITE3 REQUIRED sqlite3 IMPORTED_TARGET GLOBAL)
message(STATUS "Found sqlite3 ${SQLITE3_VERSION}")
target_link_libraries(sqlite3 INTERFACE PkgConfig::SQLITE3)
add_library(SQLite::SQLite3 ALIAS PkgConfig::SQLITE3)
endif()
add_subdirectory(external)

View File

@ -54,6 +54,15 @@ set(SQLITE3_SOURCE sqlite-autoconf-${SQLITE3_VERSION}.tar.gz)
set(SQLITE3_HASH SHA512=039af796f79fc4517be0bd5ba37886264d49da309e234ae6fccdb488ef0109ed2b917fc3e6c1fc7224dff4f736824c653aaf8f0a37550c5ebc14d035cb8ac737
CACHE STRING "sqlite3 source hash")
if(SQLITE3_VERSION MATCHES "^([0-9]+)(0([0-9])|([1-9][0-9]))(0([0-9])|([1-9][0-9]))[0-9][0-9]$")
set(SQLite3_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_3}${CMAKE_MATCH_4}.${CMAKE_MATCH_6}${CMAKE_MATCH_7}" CACHE STRING "" FORCE)
mark_as_advanced(SQLite3_VERSION)
message(STATUS "Building static sqlite3 ${SQLite3_VERSION}")
else()
message(FATAL_ERROR "Couldn't figure out sqlite3 version from '${SQLITE3_VERSION}'")
endif()
set(EUDEV_VERSION 3.2.10 CACHE STRING "eudev version")
set(EUDEV_MIRROR ${LOCAL_MIRROR} https://github.com/gentoo/eudev/archive/
CACHE STRING "eudev download mirror(s)")
@ -430,7 +439,7 @@ set(Boost_VERSION ${BOOST_VERSION})
build_external(sqlite3
BUILD_COMMAND true
INSTALL_COMMAND make install-includeHEADERS install-libLTLIBRARIES)
add_static_target(sqlite3 sqlite3_external libsqlite3.a)
add_static_target( SQLite::SQLite3 sqlite3_external libsqlite3.a)

View File

@ -145,8 +145,21 @@ target_include_directories(cpr PUBLIC cpr/include)
target_compile_definitions(cpr PUBLIC CPR_CURL_NOSIGNAL)
add_library(cpr::cpr ALIAS cpr)
# disable bundled sqlite3 in sqlitecpp
if(TARGET sqlite3)
option(SQLITECPP_INTERNAL_SQLITE "" OFF)
endif()
# Hack around SQLiteCpp's attempts to locate sqlite3 because we *don't* want to link against the
# system one, but don't download and build the embedded one until build time. Thankfully it
# actually links against the SQLite::SQLite3 cmake target if it already exists, so all we have to do
# is set that up and circumvent some of the non-target bits of its FindSQLite3.cmake.
set(SQLite3_FOUND TRUE CACHE BOOL "" FORCE)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ignored")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ignored/sqlite3.h" "#define SQLITE_VERSION \"${SQLite3_VERSION}\"")
set(SQLite3_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/ignored" CACHE STRING "" FORCE)
set(SQLite3_LIBRARY "ignored" CACHE STRING "" FORCE)
set(SQLITECPP_INTERNAL_SQLITE OFF CACHE BOOL "don't build SQLiteCpp's internal sqlite3" FORCE)
set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "" FORCE)
set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "" FORCE)
set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "" FORCE)
set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "" FORCE)
set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(SQLiteCpp)

View File

@ -52,7 +52,7 @@ target_link_libraries(cryptonote_core
ringct
device
checkpoints
sqlite3
SQLite::SQLite3
PRIVATE
Boost::program_options
systemd

View File

@ -128,7 +128,7 @@ if (STATIC AND BUILD_STATIC_DEPS)
OpenSSL::SSL OpenSSL::Crypto
expat
libunbound
sqlite3
SQLite::SQLite3
${merged_protobuf}
sodium
libzmq