Search for sqlite3 before vendoring

This commit is contained in:
Mo Morsi
2019-10-30 12:17:35 -04:00
committed by Nik Bougalis
parent 530f1939d6
commit 9bd470f2c7
3 changed files with 101 additions and 59 deletions

View File

@@ -0,0 +1,22 @@
find_package (PkgConfig REQUIRED)
pkg_search_module (sqlite_PC QUIET sqlite3>=3.26.0)
if(static)
set(SQLITE_LIB libsqlite3.a)
else()
set(SQLITE_LIB sqlite3.so)
endif()
find_library (sqlite3
NAMES ${SQLITE_LIB}
HINTS
${sqlite_PC_LIBDIR}
${sqlite_PC_LIBRARY_DIRS}
NO_DEFAULT_PATH)
find_path (SQLITE_INCLUDE_DIR
NAMES sqlite3.h
HINTS
${sqlite_PC_INCLUDEDIR}
${sqlite_PC_INCLUDEDIRS}
NO_DEFAULT_PATH)

View File

@@ -86,7 +86,7 @@ ExternalProject_Add (soci
> >
TEST_COMMAND "" TEST_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
DEPENDS sqlite3 DEPENDS sqlite
BUILD_BYPRODUCTS BUILD_BYPRODUCTS
<BINARY_DIR>/lib/${soci_lib_pre}soci_core${soci_lib_post}${ep_lib_suffix} <BINARY_DIR>/lib/${soci_lib_pre}soci_core${soci_lib_post}${ep_lib_suffix}
<BINARY_DIR>/lib/${soci_lib_pre}soci_core${soci_lib_post}_d${ep_lib_suffix} <BINARY_DIR>/lib/${soci_lib_pre}soci_core${soci_lib_post}_d${ep_lib_suffix}

View File

@@ -2,6 +2,23 @@
NIH dep: sqlite NIH dep: sqlite
#]===================================================================] #]===================================================================]
add_library (sqlite STATIC IMPORTED GLOBAL)
if (NOT WIN32)
find_package(sqlite)
endif()
if(sqlite3)
set_target_properties (sqlite PROPERTIES
IMPORTED_LOCATION_DEBUG
${sqlite3}
IMPORTED_LOCATION_RELEASE
${sqlite3}
INTERFACE_INCLUDE_DIRECTORIES
${SQLITE_INCLUDE_DIR})
else()
ExternalProject_Add (sqlite3 ExternalProject_Add (sqlite3
PREFIX ${nih_cache_path} PREFIX ${nih_cache_path}
# sqlite doesn't use git, but it provides versioned tarballs # sqlite doesn't use git, but it provides versioned tarballs
@@ -51,7 +68,7 @@ ExternalProject_Get_Property (sqlite3 SOURCE_DIR)
if (CMAKE_VERBOSE_MAKEFILE) if (CMAKE_VERBOSE_MAKEFILE)
print_ep_logs (sqlite3) print_ep_logs (sqlite3)
endif () endif ()
add_library (sqlite STATIC IMPORTED GLOBAL)
set_target_properties (sqlite PROPERTIES set_target_properties (sqlite PROPERTIES
IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_DEBUG
${BINARY_DIR}/${ep_lib_prefix}sqlite3_d${ep_lib_suffix} ${BINARY_DIR}/${ep_lib_prefix}sqlite3_d${ep_lib_suffix}
@@ -59,9 +76,12 @@ set_target_properties (sqlite PROPERTIES
${BINARY_DIR}/${ep_lib_prefix}sqlite3${ep_lib_suffix} ${BINARY_DIR}/${ep_lib_prefix}sqlite3${ep_lib_suffix}
INTERFACE_INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES
${SOURCE_DIR}) ${SOURCE_DIR})
add_dependencies (sqlite sqlite3) add_dependencies (sqlite sqlite3)
exclude_if_included (sqlite3)
endif()
target_link_libraries (sqlite INTERFACE $<$<NOT:$<BOOL:${MSVC}>>:dl>) target_link_libraries (sqlite INTERFACE $<$<NOT:$<BOOL:${MSVC}>>:dl>)
target_link_libraries (ripple_libs INTERFACE sqlite) target_link_libraries (ripple_libs INTERFACE sqlite)
exclude_if_included (sqlite3)
exclude_if_included (sqlite) exclude_if_included (sqlite)
set(sqlite_BINARY_DIR ${BINARY_DIR}) set(sqlite_BINARY_DIR ${BINARY_DIR})