Sqlite: Don't link to the internal Sqlite library

If you link to the internal Sqlite library you link actually twice. That
leads to strange bugs because you have an uninitialized object file. The
static linking workaround is now moved to cmake.

Change-Id: I51d966a623a18486ce5870d898999f3ce139f092
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2023-06-28 15:22:23 +02:00
parent b65ba2f702
commit f81ef9b2d6
7 changed files with 26 additions and 18 deletions

View File

@@ -27,10 +27,6 @@
#include <string.h>
#if defined(SQLITE_STATIC_LIBRARY) || defined(SQLITEC_STATIC_LIBRARY)
#include "sqlite_static_config.h"
#endif
#if __has_include(<unistd.h>)
#include <unistd.h>
#endif

View File

@@ -1,8 +1,7 @@
add_qtc_library(SqliteC OBJECT
add_qtc_library(SqliteInternal OBJECT
PROPERTIES AUTOMOC OFF AUTOUIC OFF QT_COMPILE_OPTIONS_DISABLE_WARNINGS ON
DEFINES SQLITE_CORE SQLITE_CUSTOM_INCLUDE=config.h $<$<CONFIG:Debug>:SQLITE_DEBUG>
PROPERTIES COMPILE_OPTIONS $<IF:$<CXX_COMPILER_ID:MSVC>,/FIconfig.h,-includeconfig.h>
PUBLIC_INCLUDES
INCLUDES
../3rdparty/sqlite
SOURCES
../3rdparty/sqlite
@@ -11,12 +10,26 @@ add_qtc_library(SqliteC OBJECT
../3rdparty/sqlite/sqlite3ext.h
../3rdparty/sqlite/carray.c
../3rdparty/sqlite/config.h
../3rdparty/sqlite/sqlite_static_config.h
../3rdparty/sqlite/sqlite.h
)
extend_qtc_library(SqliteInternal
CONDITION QTC_STATIC_BUILD
PROPERTIES COMPILE_OPTIONS $<IF:$<CXX_COMPILER_ID:MSVC>,/FIsqlite_static_config.h,-includesqlite_static_config.h>
)
if (APPLE)
extend_qtc_library(SqliteInternal DEFINES _BSD_SOURCE)
elseif (UNIX)
extend_qtc_library(SqliteInternal DEFINES _POSIX_C_SOURCE=200809L _GNU_SOURCE _DEFAULT_SOURCE)
endif()
add_qtc_library(Sqlite
PROPERTIES AUTOMOC OFF AUTOUIC OFF
DEPENDS Qt::Core Threads::Threads ${CMAKE_DL_LIBS} SqliteC
DEPENDS Qt::Core Threads::Threads ${CMAKE_DL_LIBS} SqliteInternal
INCLUDES
../3rdparty/sqlite
PUBLIC_INCLUDES
"${CMAKE_CURRENT_LIST_DIR}"
DEFINES SQLITE_CUSTOM_INCLUDE=config.h $<$<CONFIG:Debug>:SQLITE_REVERSE>
@@ -53,8 +66,7 @@ add_qtc_library(Sqlite
sqliteids.h
)
if (APPLE)
extend_qtc_library(SqliteC DEFINES _BSD_SOURCE)
elseif (UNIX)
extend_qtc_library(SqliteC DEFINES _POSIX_C_SOURCE=200809L _GNU_SOURCE _DEFAULT_SOURCE)
endif()
extend_qtc_library(Sqlite
CONDITION QTC_STATIC_BUILD
PROPERTIES COMPILE_OPTIONS $<IF:$<CXX_COMPILER_ID:MSVC>,/FIsqlite_static_config.h,-includesqlite_static_config.h>
)

View File

@@ -3,7 +3,7 @@ add_qtc_library(TestPrinters OBJECT
SKIP_AUTOMOC ON
PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}
DEPENDS
Qt::Core Qt::Widgets SqliteC Sqlite Googletest TestDesignerCore
Qt::Core Qt::Widgets Sqlite Googletest TestDesignerCore
SOURCES
gtest-creator-printing.cpp gtest-creator-printing.h
gtest-qt-printing.cpp gtest-qt-printing.h

View File

@@ -9,6 +9,7 @@
#include <gtest/gtest-printers.h>
#include <gmock/gmock-matchers.h>
#include <3rdparty/sqlite/sqlite.h>
#include <imagecache/imagecachestorageinterface.h>
#include <imagecacheauxiliarydata.h>
#include <import.h>
@@ -17,7 +18,6 @@
#include <projectstorage/projectstoragepathwatchertypes.h>
#include <projectstorage/projectstoragetypes.h>
#include <projectstorage/sourcepathcachetypes.h>
#include <sqlite.h>
#include <sqlitesessionchangeset.h>
#include <sqlitevalue.h>
#include <utils/fileutils.h>

View File

@@ -5,7 +5,7 @@ add_qtc_library(TestDesignerCore OBJECT
DEPENDS
Qt::Core Qt::Network Qt::Widgets
Qt::Xml Qt::Concurrent Qt::QmlPrivate Qt::Gui
Qt::Core5Compat Utils QmlJS Sqlite SqliteC
Qt::Core5Compat Utils QmlJS Sqlite
PUBLIC_DEPENDS
QmlPuppetCommunication
SOURCES_PREFIX ${QmlDesignerDir}/designercore

View File

@@ -7,7 +7,7 @@ add_qtc_test(unittest GTEST
DEPENDS
Qt::Core Qt::Network Qt::Widgets
Qt::Xml Qt::Concurrent Qt::QmlPrivate Qt::Gui
Qt::Core5Compat Utils QmlJS Sqlite SqliteC
Qt::Core5Compat Utils QmlJS Sqlite
Googletest TestDesignerCore TestUtils TestMatchers TestPrinters TestMocks
DEFINES
GTEST_INTERNAL_HAS_STRING_VIEW

View File

@@ -9,7 +9,7 @@
#include <sqlitetransaction.h>
#include <sqlitewritestatement.h>
#include <sqlite.h>
#include <3rdparty/sqlite/sqlite.h>
#include <QDir>