Help/litehtml: Fix litehtml build on Windows and with GCC 5.3

GCC 5.3 doesn't want to convert char* literals to QString sometimes, and
for MSVC conversions litehtml::tstring/tchar_t <->
QString::fromStdString/QString fails because the former was wstring and
wchar
Also position independent code is needed on Linux

Change-Id: Iec8dd0d9d38a07cd1c4db49c9edf10e3d1d5b156
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2019-09-20 11:14:05 +02:00
parent 1273081224
commit fe6ba084c4
3 changed files with 18 additions and 8 deletions

View File

@@ -2,26 +2,32 @@ cmake_minimum_required(VERSION 3.9)
project(QLiteHtml)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 14)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/litehtml/CMakeLists.txt)
set(ORIG_FPIC ${CMAKE_POSITION_INDEPENDENT_CODE})
set(ORIG_CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
else()
set(CMAKE_BUILD_TYPE "Release")
endif()
if (WIN32)
set(LITEHTML_UTF8 ON)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(litehtml)
set(CMAKE_BUILD_TYPE ${ORIG_CMAKE_BUILD_TYPE})
set(CMAKE_POSITION_INDEPENDENT_CODE "${ORIG_FPIC}")
else()
find_package(litehtml REQUIRED)
endif()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 14)
add_library(qlitehtml STATIC
container_qpainter.cpp container_qpainter.h
qlitehtmlwidget.cpp qlitehtmlwidget.h
@@ -29,3 +35,4 @@ add_library(qlitehtml STATIC
target_include_directories(qlitehtml PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(qlitehtml PRIVATE Qt5::Widgets litehtml)
set_target_properties(qlitehtml PROPERTIES POSITION_INDEPENDENT_CODE ON)

View File

@@ -1232,19 +1232,19 @@ QPixmap DocumentContainer::getPixmap(const QString &imageUrl, const QString &bas
QString DocumentContainer::serifFont() const
{
// TODO make configurable
return "Times New Roman";
return {"Times New Roman"};
}
QString DocumentContainer::sansSerifFont() const
{
// TODO make configurable
return "Arial";
return {"Arial"};
}
QString DocumentContainer::monospaceFont() const
{
// TODO make configurable
return "Courier";
return {"Courier"};
}
QUrl DocumentContainer::resolveUrl(const QString &url, const QString &baseUrl) const

View File

@@ -11,10 +11,13 @@ exists($$PWD/litehtml/CMakeLists.txt) {
system("$$sprintf($$QMAKE_MKDIR_CMD, $$shell_path($${LITEHTML_BUILD_PATH}))")
macos: CMAKE_DEPLOYMENT_TARGET = -DCMAKE_OSX_DEPLOYMENT_TARGET=$${QMAKE_MACOSX_DEPLOYMENT_TARGET}
win32: LITEHTML_UTF8 = -DLITEHTML_UTF8=ON
LITEHTML_CMAKE_CMD = \
"$$QMAKE_CD $$system_quote($$shell_path($${LITEHTML_BUILD_PATH})) && \
cmake -DCMAKE_BUILD_TYPE=$$BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX=$$system_quote($$shell_path($${LITEHTML_INSTALL_PATH})) \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
$$LITEHTML_UTF8 \
$$CMAKE_DEPLOYMENT_TARGET \
$$system_quote($$shell_path($${LITEHTML_SOURCE_PATH}))"
message("$${LITEHTML_CMAKE_CMD}")