CMake: Use own SQLite3 on macOS and Windows

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
Felix Weilbach 2021-04-14 13:34:12 +02:00
parent 89677fe22f
commit da1e5c448a
3 changed files with 17 additions and 26 deletions

View file

@ -52,18 +52,8 @@ if (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
set(SQLite3_VERSION _SQLITE3_VERSION)
endif (SQLite3_FIND_VERSION AND _SQLITE3_VERSION)
if (APPLE OR WIN32)
set(USE_OUR_OWN_SQLITE3 TRUE)
set(SQLITE3_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite3)
set(SQLITE3_LIBRARIES "")
set(SQLITE3_SOURCE ${SQLITE3_INCLUDE_DIR}/sqlite3.c)
MESSAGE(STATUS "Using own sqlite3 from " ${SQLITE3_INCLUDE_DIR})
else()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3 DEFAULT_MSG SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
# show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view
mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)

View file

@ -19,7 +19,11 @@ include(DefineOptions.cmake)
include(DefineInstallationPaths)
find_package(SQLite3 3.8.0 REQUIRED)
if (APPLE OR WIN32)
set(USE_OUR_OWN_SQLITE3 TRUE)
else()
find_package(SQLite3 3.8.0 REQUIRED)
endif()
include(ConfigureChecks.cmake)
include(../common/common.cmake)
@ -52,10 +56,6 @@ else()
)
endif()
if (USE_OUR_OWN_SQLITE3)
list(APPEND csync_SRCS ${SQLITE3_SOURCE})
endif()
configure_file(csync_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/csync_version.h)
add_library("${csync_NAME}" SHARED ${common_SOURCES} ${csync_SRCS})
@ -65,12 +65,14 @@ target_include_directories(
PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/std
)
find_package(SQLite3 3.9.0 REQUIRED)
if (USE_OUR_OWN_SQLITE3)
# make sure that the path for the local sqlite3 is before the system one
target_include_directories("${csync_NAME}" BEFORE PUBLIC ${SQLITE3_INCLUDE_DIR})
if(USE_OUR_OWN_SQLITE3)
message(STATUS "Using own sqlite3 version")
add_library(sqlite3 STATIC "${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite3/sqlite3.c")
target_include_directories(sqlite3 PUBLIC "${CMAKE_SOURCE_DIR}/src/3rdparty/sqlite3")
target_link_libraries("${csync_NAME}" PUBLIC sqlite3)
else()
target_include_directories("${csync_NAME}" PUBLIC ${SQLITE3_INCLUDE_DIR})
target_include_directories("${csync_NAME}" PUBLIC ${SQLITE3_INCLUDE_DIR})
target_link_libraries("${csync_NAME}" PUBLIC ${SQLITE3_LIBRARIES})
endif()
@ -80,13 +82,13 @@ generate_export_header("${csync_NAME}"
)
target_link_libraries("${csync_NAME}"
PUBLIC
${CSYNC_REQUIRED_LIBRARIES}
${SQLITE3_LIBRARIES}
Qt5::Core Qt5::Concurrent
)
if(ZLIB_FOUND)
target_link_libraries("${csync_NAME}" ZLIB::ZLIB)
target_link_libraries("${csync_NAME}" PUBLIC ZLIB::ZLIB)
endif(ZLIB_FOUND)
@ -94,7 +96,7 @@ endif(ZLIB_FOUND)
if (APPLE)
find_library(FOUNDATION_LIBRARY NAMES Foundation)
find_library(CORESERVICES_LIBRARY NAMES CoreServices)
target_link_libraries("${csync_NAME}" ${FOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY})
target_link_libraries("${csync_NAME}" PUBLIC ${FOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY})
endif()
set_target_properties(

View file

@ -1,5 +1,4 @@
include(DefinePlatformDefaults)
find_package(SQLite3 3.8.0 REQUIRED)
include(nextcloud_add_test.cmake)