diff --git a/Makefile b/Makefile index e3d1904029..94d50c6ec7 100644 --- a/Makefile +++ b/Makefile @@ -147,11 +147,26 @@ endif $(OUTPUT_DIR)/libs/libkoreader-cre.so: cre.cpp \ $(if $(USE_LUAJIT_LIB),$(LUAJIT_LIB),) \ - $(CRENGINE_LIB) - $(CXX) -I$(CRENGINE_SRC_DIR)/crengine/include/ $(DYNLIB_CXXFLAGS) \ - -DLDOM_USE_OWN_MEM_MAN=$(if $(WIN32),0,1) -DUSE_SRELL_REGEX=1 \ - $(if $(WIN32),-DQT_GL=1) $(SYMVIS_FLAGS) $(LDFLAGS) -o $@ cre.cpp $(LUAJIT_LIB_LINK_FLAG) \ - -lcrengine + $(CRENGINE_LIB) $(CRENGINE_THIRDPARTY_LIBS) \ + $(FREETYPE_LIB) $(FRIBIDI_LIB) $(HARFBUZZ_LIB) \ + $(JPEG_LIB) $(LIBWEBP_LIB) $(LIBWEBPDEMUX_LIB) \ + $(LIBUNIBREAK_LIB) $(LUNASVG_LIB) $(PNG_LIB) \ + $(UTF8PROC_LIB) $(ZLIB) $(ZSTD_LIB) + $(CXX) \ + -I$(CRENGINE_SRC_DIR)/crengine/include/ \ + -I$(FREETYPE_DIR)/include/freetype2 \ + -I$(HARFBUZZ_DIR)/include/harfbuzz \ + -I$(LIBUNIBREAK_DIR)/include \ + $(CRENGINE_FLAGS) \ + $(DYNLIB_CXXFLAGS) \ + $(SYMVIS_FLAGS) \ + $(LDFLAGS) -o $@ cre.cpp \ + $(CRENGINE_LIB) $(CRENGINE_THIRDPARTY_LIBS) $(FREETYPE_LIB_LINK_FLAG) \ + $(FRIBIDI_LIB) $(HARFBUZZ_LIB_LINK_FLAG) $(JPEG_LIB_LINK_FLAG) \ + $(LIBWEBP_LIB) $(LIBWEBPDEMUX_LIB) $(LIBUNIBREAK_LIB_LINK_FLAG) \ + $(LUNASVG_LIB) $(PNG_LIB) $(UTF8PROC_LIB) $(ZLIB) $(ZSTD_LIB) \ + $(LUAJIT_LIB_LINK_FLAG) \ + $(if $(ANDROID),$(SHARED_STL_LINK_FLAG),) ifdef DARWIN install_name_tool -change \ `otool -L "$@" | grep "libluajit" | awk '{print $$1}'` \ @@ -170,7 +185,9 @@ $(OUTPUT_DIR)/libs/libkoreader-xtext.so: xtext.cpp \ -I$(HARFBUZZ_DIR)/include/harfbuzz \ -I$(FRIBIDI_DIR)/include/fribidi \ -I$(LIBUNIBREAK_DIR)/include \ - $(DYNLIB_CXXFLAGS) $(SYMVIS_FLAGS) $(LDFLAGS) \ + $(DYNLIB_CXXFLAGS) \ + $(SYMVIS_FLAGS) \ + $(LDFLAGS) \ -Wall -o $@ xtext.cpp \ $(FREETYPE_LIB_LINK_FLAG) \ $(FRIBIDI_LIB_LINK_FLAG) \ diff --git a/Makefile.defs b/Makefile.defs index dbb95daafd..7abd724de6 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -756,7 +756,23 @@ CRENGINE_SRC_FILES=$(wildcard $(CRENGINE_SRC_DIR)/crengine/src/*.cpp) CRENGINE_SRC_FILES+=$(wildcard $(CRENGINE_SRC_DIR)/crengine/include/*.h) CRENGINE_SRC_FILES+=$(wildcard $(CRENGINE_SRC_DIR)/crengine/src/*.h) CRENGINE_SRC_FILES+=$(wildcard $(CRENGINE_SRC_DIR)/crengine/src/*_h.*) -CRENGINE_LIB=$(OUTPUT_DIR)/libs/libcrengine$(LIB_EXT) +CRENGINE_LIB = $(CRENGINE_BUILD_DIR)/libcrengine.a +CRENGINE_THIRDPARTY_LIBS = $(addprefix $(CRENGINE_BUILD_DIR)/crengine/thirdparty/, antiword/libantiword.a chmlib/libchmlib.a) +CRENGINE_FLAGS =\ + -DUSE_FONTCONFIG=0 \ + -DUSE_FREETYPE=1 \ + -DUSE_HARFBUZZ=1 \ + -DUSE_FRIBIDI=1 \ + -DUSE_LIBUNIBREAK=1 \ + -DUSE_UTF8PROC=1 \ + -DUSE_NANOSVG=0 \ + -DUSE_LUNASVG=1 \ + -DUSE_LIBWEBP=1 \ + -DUSE_ZSTD=1 \ + -DUSE_SRELL_REGEX=1 \ + -DALLOW_KERNING=1 \ + -DCR3_PATCH=1 \ + -DMATHML_SUPPORT=1 \ LUAJIT_BUILD_DIR=$(THIRDPARTY_DIR)/luajit/build/$(MACHINE) LUAJIT_DIR=$(CURDIR)/$(LUAJIT_BUILD_DIR)/luajit-prefix/src/luajit diff --git a/Makefile.third b/Makefile.third index f6a8052315..e6506f78a5 100644 --- a/Makefile.third +++ b/Makefile.third @@ -251,24 +251,23 @@ ifdef DARWIN endif # crengine, fetched via GIT as a submodule -$(CRENGINE_LIB): $(ZLIB) $(ZSTD_LIB) $(PNG_LIB) $(FREETYPE_LIB) $(HARFBUZZ_LIB) $(FRIBIDI_LIB) \ - $(LIBUNIBREAK_LIB) $(UTF8PROC_LIB) $(JPEG_LIB) $(LIBWEBP_LIB) $(LUNASVG_LIB) \ - $(CRENGINE_SRC_FILES) $(THIRDPARTY_DIR)/kpvcrlib/*.* +$(CRENGINE_LIB): $(CRENGINE_SRC_FILES) \ + $(FREETYPE_DIR)/include \ + $(FRIBIDI_DIR)/include \ + $(HARFBUZZ_DIR)/include \ + $(JPEG_DIR)/include \ + $(LIBUNIBREAK_DIR)/include \ + $(LIBWEBP_DIR)/include \ + $(LUNASVG_DIR)/include \ + $(MUPDF_DIR)/scripts \ + $(PNG_DIR)/include \ + $(SRELL_INCLUDE_DIR) \ + $(UTF8PROC_DIR) \ + $(ZLIB_DIR)/include \ + $(ZSTD_DESTDIR)/include \ + $(THIRDPARTY_DIR)/kpvcrlib/*.* install -d $(CRENGINE_BUILD_DIR) cd $(CRENGINE_BUILD_DIR) && \ - JPEG_LIB='$(CURDIR)/$(JPEG_LIB)' \ - PNG_LIB='$(CURDIR)/$(PNG_LIB)' \ - FREETYPE_LIB='$(CURDIR)/$(FREETYPE_LIB)' \ - HARFBUZZ_LIB='$(CURDIR)/$(HARFBUZZ_LIB)' \ - FRIBIDI_LIB='$(CURDIR)/$(FRIBIDI_LIB)' \ - LIBWEBP_LIB='$(CURDIR)/$(LIBWEBP_LIB)' \ - LIBWEBPDEMUX_LIB='$(CURDIR)/$(LIBWEBPDEMUX_LIB)' \ - LUNASVG_LIB='$(CURDIR)/$(LUNASVG_LIB)' \ - LIBUNIBREAK_LIB='$(CURDIR)/$(LIBUNIBREAK_LIB)' \ - UTF8PROC_LIB='$(CURDIR)/$(UTF8PROC_LIB)' \ - ZLIB='$(CURDIR)/$(ZLIB)' \ - ZSTD_LIB='$(CURDIR)/$(ZSTD_LIB)' \ - LIBS_DIR='$(CURDIR)/$(OUTPUT_DIR)/libs' \ $(CMAKE) $(CMAKE_FLAGS) \ -DJPEGLIB_INCLUDE_DIR='$(JPEG_DIR)/include' \ -DJCONFIG_INCLUDE_DIR='$(MUPDF_DIR)/scripts' \ @@ -284,29 +283,12 @@ $(CRENGINE_LIB): $(ZLIB) $(ZSTD_LIB) $(PNG_LIB) $(FREETYPE_LIB) $(HARFBUZZ_LIB) -DZSTD_INCLUDE_DIR='$(ZSTD_DESTDIR)/include' \ -DSRELL_INCLUDE_DIR='${SRELL_INCLUDE_DIR}' \ -DCMAKE_BUILD_TYPE='$(CMAKE_BUILD_TYPE)' \ + -DCRENGINE_FLAGS='$(CRENGINE_FLAGS)' \ $(if $(WIN32),-DCMAKE_SYSTEM_NAME=Windows,) \ $(if $(ANDROID),-DCMAKE_SYSTEM_NAME=Android,) \ $(if $(ANDROID),-DCMAKE_SYSTEM_VERSION=1,) \ $(CURDIR)/$(THIRDPARTY_DIR)/kpvcrlib && \ $(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS) - cp -fL $(CRENGINE_DIR)/$(notdir $(CRENGINE_LIB)) $(CRENGINE_LIB) -ifdef DARWIN - install_name_tool -id \ - libs/$(notdir $(CRENGINE_LIB)) \ - $@ - install_name_tool -change \ - `otool -L '$@' | grep '$(notdir $(UTF8PROC_LIB)) ' | awk '{print $$1}'` \ - libs/$(notdir $(UTF8PROC_LIB)) \ - $@ - install_name_tool -change \ - `otool -L '$@' | grep '$(notdir $(JPEG_LIB)) ' | awk '{print $$1}'` \ - libs/$(notdir $(JPEG_LIB)) \ - $@ - install_name_tool -change \ - `otool -L '$@' | grep '$(notdir $(ZSTD_LIB)) ' | awk '{print $$1}'` \ - libs/$(notdir $(ZSTD_LIB)) \ - $@ -endif $(LUAJIT) $(LUAJIT_LIB) $(LUAJIT_JIT): $(THIRDPARTY_DIR)/luajit/*.* install -d $(LUAJIT_BUILD_DIR) diff --git a/thirdparty/kpvcrlib/CMakeLists.txt b/thirdparty/kpvcrlib/CMakeLists.txt index 1756dd8e57..cf3c58cc51 100644 --- a/thirdparty/kpvcrlib/CMakeLists.txt +++ b/thirdparty/kpvcrlib/CMakeLists.txt @@ -31,6 +31,7 @@ assert_var_defined(JPEGLIB_INCLUDE_DIR) assert_var_defined(LIBWEBP_INCLUDE_DIR) assert_var_defined(LUNASVG_INCLUDE_DIR) assert_var_defined(ZSTD_INCLUDE_DIR) +assert_var_defined(CRENGINE_FLAGS) include_directories( ${JCONFIG_INCLUDE_DIR} @@ -72,22 +73,8 @@ else() set(CMAKE_REQUIRED_DEFINITIONS) endif() -add_definitions( - -DUSE_FONTCONFIG=0 - -DUSE_FREETYPE=1 - -DUSE_HARFBUZZ=1 - -DUSE_FRIBIDI=1 - -DUSE_LIBUNIBREAK=1 - -DUSE_UTF8PROC=1 - -DUSE_NANOSVG=0 # better SVG support via LunaSVG - -DUSE_LUNASVG=1 - -DUSE_LIBWEBP=1 - -DUSE_ZSTD=1 - -DUSE_SRELL_REGEX=1 - -DALLOW_KERNING=1 - -DCR3_PATCH=1 - -DMATHML_SUPPORT=1 -) +separate_arguments(CRENGINE_FLAGS UNIX_COMMAND ${CRENGINE_FLAGS}) +add_compile_definitions(${CRENGINE_FLAGS}) if(${CMAKE_BUILD_TYPE} STREQUAL Debug) add_definitions( @@ -100,48 +87,6 @@ else() ) endif() -if(DEFINED ENV{WIN32}) - find_library(ZLIB NAMES "zlib1" PATHS $ENV{LIBS_DIR}) - find_library(ZSTD NAMES "zstd" PATHS $ENV{LIBS_DIR}) - find_library(PNG_LIB NAMES "png16-16" PATHS $ENV{LIBS_DIR}) - find_library(FREETYPE_LIB NAMES "freetype-6" PATHS $ENV{LIBS_DIR}) - find_library(HARFBUZZ_LIB NAMES "harfbuzz-0" PATHS $ENV{LIBS_DIR}) - find_library(FRIBIDI_LIB NAMES "fribidi-0" PATHS $ENV{LIBS_DIR}) - find_library(LIBUNIBREAK_LIB NAMES "libunibreak-5" PATHS $ENV{LIBS_DIR}) - find_library(UTF8PROC_LIB NAMES "utf8proc-2" PATHS $ENV{LIBS_DIR}) - find_library(JPEG_LIB NAMES "jpeg-8" PATHS $ENV{LIBS_DIR}) - find_library(LUNASVG_LIB NAMES "lunasvg" PATHS $ENV{LIBS_DIR}) - find_library(LIBWEBP_LIB NAMES "webp-7" PATHS $ENV{LIBS_DIR}) - find_library(LIBWEBPDEMUX_LIB NAMES "webpdemux-2" PATHS $ENV{LIBS_DIR}) - set(THIRDPARTY_LIBS ${ZLIB} ${ZSTD} ${FREETYPE_LIB} ${HARFBUZZ_LIB} ${FRIBIDI_LIB} ${LIBUNIBREAK_LIB} ${UTF8PROC_LIB} ${JPEG_LIB} ${PNG_LIB} ${LIBWEBP_LIB} ${LIBWEBPDEMUX_LIB} ${LUNASVG_LIB}) -else() - add_library(PNG_LIB SHARED IMPORTED) - set_target_properties(PNG_LIB PROPERTIES IMPORTED_LOCATION $ENV{PNG_LIB}) - add_library(FREETYPE_LIB SHARED IMPORTED) - set_target_properties(FREETYPE_LIB PROPERTIES IMPORTED_LOCATION $ENV{FREETYPE_LIB}) - add_library(HARFBUZZ_LIB SHARED IMPORTED) - set_target_properties(HARFBUZZ_LIB PROPERTIES IMPORTED_LOCATION $ENV{HARFBUZZ_LIB}) - add_library(FRIBIDI_LIB SHARED IMPORTED) - set_target_properties(FRIBIDI_LIB PROPERTIES IMPORTED_LOCATION $ENV{FRIBIDI_LIB}) - add_library(LIBUNIBREAK_LIB SHARED IMPORTED) - set_target_properties(LIBUNIBREAK_LIB PROPERTIES IMPORTED_LOCATION $ENV{LIBUNIBREAK_LIB}) - add_library(UTF8PROC_LIB SHARED IMPORTED) - set_target_properties(UTF8PROC_LIB PROPERTIES IMPORTED_LOCATION $ENV{UTF8PROC_LIB}) - add_library(JPEG_LIB SHARED IMPORTED) - set_target_properties(JPEG_LIB PROPERTIES IMPORTED_LOCATION $ENV{JPEG_LIB}) - add_library(LIBWEBP_LIB SHARED IMPORTED) - set_target_properties(LIBWEBP_LIB PROPERTIES IMPORTED_LOCATION $ENV{LIBWEBP_LIB}) - add_library(LIBWEBPDEMUX_LIB SHARED IMPORTED) - set_target_properties(LIBWEBPDEMUX_LIB PROPERTIES IMPORTED_LOCATION $ENV{LIBWEBPDEMUX_LIB}) - add_library(LUNASVG_LIB SHARED IMPORTED) - set_target_properties(LUNASVG_LIB PROPERTIES IMPORTED_LOCATION $ENV{LUNASVG_LIB}) - add_library(ZLIB SHARED IMPORTED) - set_target_properties(ZLIB PROPERTIES IMPORTED_LOCATION $ENV{ZLIB}) - add_library(ZSTD SHARED IMPORTED) - set_target_properties(ZSTD PROPERTIES IMPORTED_LOCATION $ENV{ZSTD_LIB}) - set(THIRDPARTY_LIBS ZLIB ZSTD FREETYPE_LIB HARFBUZZ_LIB FRIBIDI_LIB LIBUNIBREAK_LIB UTF8PROC_LIB JPEG_LIB PNG_LIB LIBWEBP_LIB LIBWEBPDEMUX_LIB LUNASVG_LIB) -endif() - message("Will build LIBCHM library") add_definitions(-DCHM_SUPPORT_ENABLED=1) add_subdirectory(${CR_3RDPARTY_DIR}/chmlib) @@ -199,9 +144,6 @@ set (CRENGINE_SOURCES ${CRE_DIR}/src/cri18n.cpp ${CRE_DIR}/src/crconcurrent.cpp ) -add_library(crengine SHARED ${CRENGINE_SOURCES}) +add_library(crengine STATIC ${CRENGINE_SOURCES}) # Make sure we get full `constexpr` support. target_compile_features(crengine PRIVATE cxx_std_17) - -target_link_libraries(crengine PRIVATE chmlib antiword) -target_link_libraries(crengine PRIVATE ${THIRDPARTY_LIBS})