mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 18:26:43 +00:00
Update readme
This commit is contained in:
parent
bfc7f4ddb6
commit
0d4deb3eb3
@ -98,13 +98,13 @@ TARGET_LINK_LIBRARIES(
|
|||||||
${UUID_LIBRARIES}
|
${UUID_LIBRARIES}
|
||||||
|
|
||||||
# ffmpeg
|
# ffmpeg
|
||||||
# ${PROJECT_SOURCE_DIR}/lib/libavcodec.a
|
${PROJECT_SOURCE_DIR}/lib/libavcodec.a
|
||||||
# ${PROJECT_SOURCE_DIR}/lib/libavformat.a
|
${PROJECT_SOURCE_DIR}/lib/libavformat.a
|
||||||
# ${PROJECT_SOURCE_DIR}/lib/libavutil.a
|
${PROJECT_SOURCE_DIR}/lib/libavutil.a
|
||||||
# ${PROJECT_SOURCE_DIR}/lib/libswscale.a
|
${PROJECT_SOURCE_DIR}/lib/libswscale.a
|
||||||
# ${PROJECT_SOURCE_DIR}/lib/libswresample.a
|
${PROJECT_SOURCE_DIR}/lib/libswresample.a
|
||||||
${FFMPEG_LIBRARIES}
|
# ${FFMPEG_LIBRARIES}
|
||||||
swscale
|
# swscale
|
||||||
|
|
||||||
# mupdf
|
# mupdf
|
||||||
${PROJECT_SOURCE_DIR}/lib/libmupdf.a
|
${PROJECT_SOURCE_DIR}/lib/libmupdf.a
|
||||||
|
80
CMakeModules/FindFFmpeg.cmake
vendored
Normal file
80
CMakeModules/FindFFmpeg.cmake
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# FFMPEG_FOUND - system has ffmpeg or libav
|
||||||
|
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
|
||||||
|
# FFMPEG_LIBRARIES - Link these to use ffmpeg
|
||||||
|
# FFMPEG_LIBAVCODEC
|
||||||
|
# FFMPEG_LIBAVFORMAT
|
||||||
|
# FFMPEG_LIBAVUTIL
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
|
||||||
|
# Modified for other libraries by Lasse Kärkkäinen <tronic>
|
||||||
|
# Modified for Hedgewars by Stepik777
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
#
|
||||||
|
|
||||||
|
if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||||
|
# in cache already
|
||||||
|
set(FFMPEG_FOUND TRUE)
|
||||||
|
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||||
|
# use pkg-config to get the directories and then use these values
|
||||||
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
|
||||||
|
pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
|
||||||
|
pkg_check_modules(_FFMPEG_AVUTIL libavutil)
|
||||||
|
endif (PKG_CONFIG_FOUND)
|
||||||
|
|
||||||
|
find_path(FFMPEG_AVCODEC_INCLUDE_DIR
|
||||||
|
NAMES libavcodec/avcodec.h
|
||||||
|
PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
|
||||||
|
PATH_SUFFIXES ffmpeg libav
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(FFMPEG_LIBAVCODEC
|
||||||
|
NAMES avcodec
|
||||||
|
PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(FFMPEG_LIBAVFORMAT
|
||||||
|
NAMES avformat
|
||||||
|
PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(FFMPEG_LIBAVUTIL
|
||||||
|
NAMES avutil
|
||||||
|
PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
|
||||||
|
set(FFMPEG_FOUND TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (FFMPEG_FOUND)
|
||||||
|
set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
|
||||||
|
|
||||||
|
set(FFMPEG_LIBRARIES
|
||||||
|
${FFMPEG_LIBAVCODEC}
|
||||||
|
${FFMPEG_LIBAVFORMAT}
|
||||||
|
${FFMPEG_LIBAVUTIL}
|
||||||
|
)
|
||||||
|
|
||||||
|
endif (FFMPEG_FOUND)
|
||||||
|
|
||||||
|
if (FFMPEG_FOUND)
|
||||||
|
if (NOT FFMPEG_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
|
||||||
|
endif (NOT FFMPEG_FIND_QUIETLY)
|
||||||
|
else (FFMPEG_FOUND)
|
||||||
|
if (FFMPEG_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
|
||||||
|
endif (FFMPEG_FIND_REQUIRED)
|
||||||
|
endif (FFMPEG_FOUND)
|
||||||
|
|
||||||
|
endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||||
|
|
||||||
|
|
100
CMakeModules/FindLibMagic.cmake
vendored
Normal file
100
CMakeModules/FindLibMagic.cmake
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2013-2013, Lars Baehren <lbaehren@gmail.com>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# - Check for the presence of LIBMAGIC
|
||||||
|
#
|
||||||
|
# The following variables are set when LIBMAGIC is found:
|
||||||
|
# LIBMAGIC_FOUND = Set to true, if all components of LIBMAGIC have been
|
||||||
|
# found.
|
||||||
|
# LIBMAGIC_INCLUDES = Include path for the header files of LIBMAGIC
|
||||||
|
# LIBMAGIC_LIBRARIES = Link these to use LIBMAGIC
|
||||||
|
# LIBMAGIC_LFLAGS = Linker flags (optional)
|
||||||
|
|
||||||
|
if (NOT LIBMAGIC_FOUND)
|
||||||
|
|
||||||
|
if (NOT LIBMAGIC_ROOT_DIR)
|
||||||
|
set (LIBMAGIC_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
|
||||||
|
endif (NOT LIBMAGIC_ROOT_DIR)
|
||||||
|
|
||||||
|
##____________________________________________________________________________
|
||||||
|
## Check for the header files
|
||||||
|
|
||||||
|
find_path (LIBMAGIC_FILE_H
|
||||||
|
NAMES file/file.h
|
||||||
|
HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
)
|
||||||
|
if (LIBMAGIC_FILE_H)
|
||||||
|
list (APPEND LIBMAGIC_INCLUDES ${LIBMAGIC_FILE_H})
|
||||||
|
endif (LIBMAGIC_FILE_H)
|
||||||
|
|
||||||
|
find_path (LIBMAGIC_MAGIC_H
|
||||||
|
NAMES magic.h
|
||||||
|
HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
|
||||||
|
PATH_SUFFIXES include include/linux
|
||||||
|
)
|
||||||
|
if (LIBMAGIC_MAGIC_H)
|
||||||
|
list (APPEND LIBMAGIC_INCLUDES ${LIBMAGIC_MAGIC_H})
|
||||||
|
endif (LIBMAGIC_MAGIC_H)
|
||||||
|
|
||||||
|
list (REMOVE_DUPLICATES LIBMAGIC_INCLUDES)
|
||||||
|
|
||||||
|
##____________________________________________________________________________
|
||||||
|
## Check for the library
|
||||||
|
|
||||||
|
find_library (LIBMAGIC_LIBRARIES magic
|
||||||
|
HINTS ${LIBMAGIC_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
)
|
||||||
|
|
||||||
|
##____________________________________________________________________________
|
||||||
|
## Actions taken when all components have been found
|
||||||
|
|
||||||
|
#find_package_handle_standard_args (LIBMAGIC DEFAULT_MSG LIBMAGIC_LIBRARIES LIBMAGIC_INCLUDES)
|
||||||
|
|
||||||
|
if (LIBMAGIC_FOUND)
|
||||||
|
if (NOT LIBMAGIC_FIND_QUIETLY)
|
||||||
|
message (STATUS "Found components for LIBMAGIC")
|
||||||
|
message (STATUS "LIBMAGIC_ROOT_DIR = ${LIBMAGIC_ROOT_DIR}")
|
||||||
|
message (STATUS "LIBMAGIC_INCLUDES = ${LIBMAGIC_INCLUDES}")
|
||||||
|
message (STATUS "LIBMAGIC_LIBRARIES = ${LIBMAGIC_LIBRARIES}")
|
||||||
|
endif (NOT LIBMAGIC_FIND_QUIETLY)
|
||||||
|
else (LIBMAGIC_FOUND)
|
||||||
|
if (LIBMAGIC_FIND_REQUIRED)
|
||||||
|
message (FATAL_ERROR "Could not find LIBMAGIC!")
|
||||||
|
endif (LIBMAGIC_FIND_REQUIRED)
|
||||||
|
endif (LIBMAGIC_FOUND)
|
||||||
|
|
||||||
|
##____________________________________________________________________________
|
||||||
|
## Mark advanced variables
|
||||||
|
|
||||||
|
mark_as_advanced (
|
||||||
|
LIBMAGIC_ROOT_DIR
|
||||||
|
LIBMAGIC_INCLUDES
|
||||||
|
LIBMAGIC_LIBRARIES
|
||||||
|
)
|
||||||
|
|
||||||
|
endif (NOT LIBMAGIC_FOUND)
|
478
CMakeModules/FindOpenSSL.cmake
vendored
Normal file
478
CMakeModules/FindOpenSSL.cmake
vendored
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
|
||||||
|
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
|
||||||
|
(("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR
|
||||||
|
("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
|
||||||
|
set(_OpenSSL_has_dependencies TRUE)
|
||||||
|
find_package(Threads)
|
||||||
|
else()
|
||||||
|
set(_OpenSSL_has_dependencies FALSE)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
function(_OpenSSL_add_dependencies libraries_var library)
|
||||||
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
|
list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
endif()
|
||||||
|
list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
|
||||||
|
set(${libraries_var} ${${libraries_var}} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(_OpenSSL_target_add_dependencies target)
|
||||||
|
if(_OpenSSL_has_dependencies)
|
||||||
|
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads )
|
||||||
|
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
pkg_check_modules(_OPENSSL QUIET openssl)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
|
||||||
|
if(OPENSSL_USE_STATIC_LIBS)
|
||||||
|
set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
else()
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# http://www.slproweb.com/products/Win32OpenSSL.html
|
||||||
|
set(_OPENSSL_ROOT_HINTS
|
||||||
|
${OPENSSL_ROOT_DIR}
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
|
||||||
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
|
||||||
|
ENV OPENSSL_ROOT_DIR
|
||||||
|
)
|
||||||
|
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||||
|
set(_OPENSSL_ROOT_PATHS
|
||||||
|
"${_programfiles}/OpenSSL"
|
||||||
|
"${_programfiles}/OpenSSL-Win32"
|
||||||
|
"${_programfiles}/OpenSSL-Win64"
|
||||||
|
"C:/OpenSSL/"
|
||||||
|
"C:/OpenSSL-Win32/"
|
||||||
|
"C:/OpenSSL-Win64/"
|
||||||
|
)
|
||||||
|
unset(_programfiles)
|
||||||
|
else ()
|
||||||
|
set(_OPENSSL_ROOT_HINTS
|
||||||
|
${OPENSSL_ROOT_DIR}
|
||||||
|
ENV OPENSSL_ROOT_DIR
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(_OPENSSL_ROOT_HINTS_AND_PATHS
|
||||||
|
HINTS ${_OPENSSL_ROOT_HINTS}
|
||||||
|
PATHS ${_OPENSSL_ROOT_PATHS}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(OPENSSL_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
openssl/ssl.h
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
HINTS
|
||||||
|
${_OPENSSL_INCLUDEDIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32 AND NOT CYGWIN)
|
||||||
|
if(MSVC)
|
||||||
|
# /MD and /MDd are the standard values - if someone wants to use
|
||||||
|
# others, the libnames have to change here too
|
||||||
|
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
|
||||||
|
# enable OPENSSL_MSVC_STATIC_RT to get the libs build /MT (Multithreaded no-DLL)
|
||||||
|
# In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
|
||||||
|
# * MD for dynamic-release
|
||||||
|
# * MDd for dynamic-debug
|
||||||
|
# * MT for static-release
|
||||||
|
# * MTd for static-debug
|
||||||
|
|
||||||
|
# Implementation details:
|
||||||
|
# We are using the libraries located in the VC subdir instead of the parent directory even though :
|
||||||
|
# libeay32MD.lib is identical to ../libeay32.lib, and
|
||||||
|
# ssleay32MD.lib is identical to ../ssleay32.lib
|
||||||
|
# enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static
|
||||||
|
|
||||||
|
if (OPENSSL_MSVC_STATIC_RT)
|
||||||
|
set(_OPENSSL_MSVC_RT_MODE "MT")
|
||||||
|
else ()
|
||||||
|
set(_OPENSSL_MSVC_RT_MODE "MD")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Since OpenSSL 1.1, lib names are like libcrypto32MTd.lib and libssl32MTd.lib
|
||||||
|
if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" )
|
||||||
|
set(_OPENSSL_MSVC_ARCH_SUFFIX "64")
|
||||||
|
else()
|
||||||
|
set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPENSSL_USE_STATIC_LIBS)
|
||||||
|
set(_OPENSSL_PATH_SUFFIXES
|
||||||
|
"lib/VC/static"
|
||||||
|
"VC/static"
|
||||||
|
"lib"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(_OPENSSL_PATH_SUFFIXES
|
||||||
|
"lib/VC"
|
||||||
|
"VC"
|
||||||
|
"lib"
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_library(LIB_EAY_DEBUG
|
||||||
|
NAMES
|
||||||
|
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
libcrypto${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
libcryptod
|
||||||
|
libeay32${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
libeay32d
|
||||||
|
cryptod
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_OPENSSL_PATH_SUFFIXES}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LIB_EAY_RELEASE
|
||||||
|
NAMES
|
||||||
|
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
libcrypto${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
libcrypto
|
||||||
|
libeay32${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
libeay32
|
||||||
|
crypto
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_OPENSSL_PATH_SUFFIXES}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(SSL_EAY_DEBUG
|
||||||
|
NAMES
|
||||||
|
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
libssl${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
libssld
|
||||||
|
ssleay32${_OPENSSL_MSVC_RT_MODE}d
|
||||||
|
ssleay32d
|
||||||
|
ssld
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_OPENSSL_PATH_SUFFIXES}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(SSL_EAY_RELEASE
|
||||||
|
NAMES
|
||||||
|
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
libssl${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
libssl
|
||||||
|
ssleay32${_OPENSSL_MSVC_RT_MODE}
|
||||||
|
ssleay32
|
||||||
|
ssl
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
${_OPENSSL_PATH_SUFFIXES}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
|
||||||
|
set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
|
||||||
|
set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
|
||||||
|
set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
|
||||||
|
select_library_configurations(LIB_EAY)
|
||||||
|
select_library_configurations(SSL_EAY)
|
||||||
|
|
||||||
|
mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
|
||||||
|
SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
|
||||||
|
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} )
|
||||||
|
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} )
|
||||||
|
elseif(MINGW)
|
||||||
|
# same player, for MinGW
|
||||||
|
set(LIB_EAY_NAMES crypto libeay32)
|
||||||
|
set(SSL_EAY_NAMES ssl ssleay32)
|
||||||
|
find_library(LIB_EAY
|
||||||
|
NAMES
|
||||||
|
${LIB_EAY_NAMES}
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"lib/MinGW"
|
||||||
|
"lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(SSL_EAY
|
||||||
|
NAMES
|
||||||
|
${SSL_EAY_NAMES}
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
"lib/MinGW"
|
||||||
|
"lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||||
|
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||||
|
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||||
|
unset(LIB_EAY_NAMES)
|
||||||
|
unset(SSL_EAY_NAMES)
|
||||||
|
else()
|
||||||
|
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
|
||||||
|
find_library(LIB_EAY
|
||||||
|
NAMES
|
||||||
|
libcrypto
|
||||||
|
libeay32
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
HINTS
|
||||||
|
${_OPENSSL_LIBDIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(SSL_EAY
|
||||||
|
NAMES
|
||||||
|
libssl
|
||||||
|
ssleay32
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
HINTS
|
||||||
|
${_OPENSSL_LIBDIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||||
|
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||||
|
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
|
||||||
|
find_library(OPENSSL_SSL_LIBRARY
|
||||||
|
NAMES
|
||||||
|
ssl
|
||||||
|
ssleay32
|
||||||
|
ssleay32MD
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
HINTS
|
||||||
|
${_OPENSSL_LIBDIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(OPENSSL_CRYPTO_LIBRARY
|
||||||
|
NAMES
|
||||||
|
crypto
|
||||||
|
NAMES_PER_DIR
|
||||||
|
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||||
|
HINTS
|
||||||
|
${_OPENSSL_LIBDIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# compat defines
|
||||||
|
set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
|
||||||
|
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
||||||
|
_OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
|
||||||
|
if(_OpenSSL_has_dependencies)
|
||||||
|
_OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES "${OPENSSL_SSL_LIBRARY}" )
|
||||||
|
_OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES "${OPENSSL_CRYPTO_LIBRARY}" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(from_hex HEX DEC)
|
||||||
|
string(TOUPPER "${HEX}" HEX)
|
||||||
|
set(_res 0)
|
||||||
|
string(LENGTH "${HEX}" _strlen)
|
||||||
|
|
||||||
|
while (_strlen GREATER 0)
|
||||||
|
math(EXPR _res "${_res} * 16")
|
||||||
|
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
|
||||||
|
string(SUBSTRING "${HEX}" 1 -1 HEX)
|
||||||
|
if (NIBBLE STREQUAL "A")
|
||||||
|
math(EXPR _res "${_res} + 10")
|
||||||
|
elseif (NIBBLE STREQUAL "B")
|
||||||
|
math(EXPR _res "${_res} + 11")
|
||||||
|
elseif (NIBBLE STREQUAL "C")
|
||||||
|
math(EXPR _res "${_res} + 12")
|
||||||
|
elseif (NIBBLE STREQUAL "D")
|
||||||
|
math(EXPR _res "${_res} + 13")
|
||||||
|
elseif (NIBBLE STREQUAL "E")
|
||||||
|
math(EXPR _res "${_res} + 14")
|
||||||
|
elseif (NIBBLE STREQUAL "F")
|
||||||
|
math(EXPR _res "${_res} + 15")
|
||||||
|
else()
|
||||||
|
math(EXPR _res "${_res} + ${NIBBLE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(LENGTH "${HEX}" _strlen)
|
||||||
|
endwhile()
|
||||||
|
|
||||||
|
set(${DEC} ${_res} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||||
|
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||||
|
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||||
|
|
||||||
|
if(openssl_version_str)
|
||||||
|
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
|
||||||
|
# The status gives if this is a developer or prerelease and is ignored here.
|
||||||
|
# Major, minor, and fix directly translate into the version numbers shown in
|
||||||
|
# the string. The patch field translates to the single character suffix that
|
||||||
|
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
|
||||||
|
# on.
|
||||||
|
|
||||||
|
string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
|
||||||
|
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
|
||||||
|
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
||||||
|
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
||||||
|
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
|
||||||
|
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
|
||||||
|
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
|
||||||
|
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
|
||||||
|
|
||||||
|
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||||
|
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
|
||||||
|
# 96 is the ASCII code of 'a' minus 1
|
||||||
|
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
|
||||||
|
unset(_tmp)
|
||||||
|
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
|
||||||
|
# this should be updated to handle that, too. This has not happened yet
|
||||||
|
# so it is simply ignored here for now.
|
||||||
|
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} )
|
||||||
|
list(REMOVE_DUPLICATES OPENSSL_LIBRARIES)
|
||||||
|
|
||||||
|
foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
|
||||||
|
if(_comp STREQUAL "Crypto")
|
||||||
|
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||||
|
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||||
|
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||||
|
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||||
|
)
|
||||||
|
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
elseif(_comp STREQUAL "SSL")
|
||||||
|
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||||
|
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||||
|
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||||
|
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||||
|
)
|
||||||
|
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "${_comp} is not a valid OpenSSL component")
|
||||||
|
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(_comp)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
find_package_handle_standard_args(OpenSSL
|
||||||
|
REQUIRED_VARS
|
||||||
|
OPENSSL_CRYPTO_LIBRARY
|
||||||
|
OPENSSL_INCLUDE_DIR
|
||||||
|
VERSION_VAR
|
||||||
|
OPENSSL_VERSION
|
||||||
|
HANDLE_COMPONENTS
|
||||||
|
FAIL_MESSAGE
|
||||||
|
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
|
||||||
|
|
||||||
|
if(OPENSSL_FOUND)
|
||||||
|
if(NOT TARGET OpenSSL::Crypto AND
|
||||||
|
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||||
|
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||||
|
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||||
|
)
|
||||||
|
add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||||
|
if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
|
||||||
|
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||||
|
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||||
|
IMPORTED_CONFIGURATIONS RELEASE)
|
||||||
|
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
|
||||||
|
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||||
|
IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
|
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
|
||||||
|
endif()
|
||||||
|
_OpenSSL_target_add_dependencies(OpenSSL::Crypto)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET OpenSSL::SSL AND
|
||||||
|
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||||
|
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||||
|
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||||
|
)
|
||||||
|
add_library(OpenSSL::SSL UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||||
|
if(EXISTS "${OPENSSL_SSL_LIBRARY}")
|
||||||
|
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||||
|
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||||
|
IMPORTED_CONFIGURATIONS RELEASE)
|
||||||
|
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||||
|
IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
|
||||||
|
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||||
|
IMPORTED_CONFIGURATIONS DEBUG)
|
||||||
|
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||||
|
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
|
||||||
|
endif()
|
||||||
|
if(TARGET OpenSSL::Crypto)
|
||||||
|
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
|
||||||
|
endif()
|
||||||
|
_OpenSSL_target_add_dependencies(OpenSSL::SSL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Restore the original find library ordering
|
||||||
|
if(OPENSSL_USE_STATIC_LIBS)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
endif()
|
268
CMakeModules/FindPackageHandleStandardArgs.cmake
vendored
Normal file
268
CMakeModules/FindPackageHandleStandardArgs.cmake
vendored
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
|
||||||
|
|
||||||
|
# internal helper macro
|
||||||
|
macro(_FPHSA_FAILURE_MESSAGE _msg)
|
||||||
|
set (__msg "${_msg}")
|
||||||
|
if (FPHSA_REASON_FAILURE_MESSAGE)
|
||||||
|
string(APPEND __msg "\n Reason given by package: ${FPHSA_REASON_FAILURE_MESSAGE}\n")
|
||||||
|
endif()
|
||||||
|
if (${_NAME}_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "${__msg}")
|
||||||
|
else ()
|
||||||
|
if (NOT ${_NAME}_FIND_QUIETLY)
|
||||||
|
message(STATUS "${__msg}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
# internal helper macro to generate the failure message when used in CONFIG_MODE:
|
||||||
|
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
|
||||||
|
# <PackageName>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
|
||||||
|
if(${_NAME}_CONFIG)
|
||||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
|
||||||
|
else()
|
||||||
|
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
|
||||||
|
# List them all in the error message:
|
||||||
|
if(${_NAME}_CONSIDERED_CONFIGS)
|
||||||
|
set(configsText "")
|
||||||
|
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
|
||||||
|
math(EXPR configsCount "${configsCount} - 1")
|
||||||
|
foreach(currentConfigIndex RANGE ${configsCount})
|
||||||
|
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
|
||||||
|
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
|
||||||
|
string(APPEND configsText "\n ${filename} (version ${version})")
|
||||||
|
endforeach()
|
||||||
|
if (${_NAME}_NOT_FOUND_MESSAGE)
|
||||||
|
if (FPHSA_REASON_FAILURE_MESSAGE)
|
||||||
|
string(PREPEND FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}\n ")
|
||||||
|
else()
|
||||||
|
set(FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
string(APPEND configsText "\n")
|
||||||
|
endif()
|
||||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:${configsText}")
|
||||||
|
|
||||||
|
else()
|
||||||
|
# Simple case: No Config-file was found at all:
|
||||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
||||||
|
|
||||||
|
# Set up the arguments for `cmake_parse_arguments`.
|
||||||
|
set(options CONFIG_MODE HANDLE_COMPONENTS)
|
||||||
|
set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR)
|
||||||
|
set(multiValueArgs REQUIRED_VARS)
|
||||||
|
|
||||||
|
# Check whether we are in 'simple' or 'extended' mode:
|
||||||
|
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
|
||||||
|
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
|
||||||
|
|
||||||
|
if(${INDEX} EQUAL -1)
|
||||||
|
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
|
||||||
|
set(FPHSA_REQUIRED_VARS ${ARGN})
|
||||||
|
set(FPHSA_VERSION_VAR)
|
||||||
|
else()
|
||||||
|
cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
|
||||||
|
|
||||||
|
if(FPHSA_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FPHSA_FAIL_MESSAGE)
|
||||||
|
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# In config-mode, we rely on the variable <PackageName>_CONFIG, which is set by find_package()
|
||||||
|
# when it successfully found the config-file, including version checking:
|
||||||
|
if(FPHSA_CONFIG_MODE)
|
||||||
|
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
|
||||||
|
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
|
||||||
|
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT FPHSA_REQUIRED_VARS)
|
||||||
|
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# now that we collected all arguments, process them
|
||||||
|
|
||||||
|
if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")
|
||||||
|
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
|
||||||
|
|
||||||
|
string(TOUPPER ${_NAME} _NAME_UPPER)
|
||||||
|
string(TOLOWER ${_NAME} _NAME_LOWER)
|
||||||
|
|
||||||
|
if(FPHSA_FOUND_VAR)
|
||||||
|
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
|
||||||
|
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# collect all variables which were not found, so they can be printed, so the
|
||||||
|
# user knows better what went wrong (#6375)
|
||||||
|
set(MISSING_VARS "")
|
||||||
|
set(DETAILS "")
|
||||||
|
# check if all passed variables are valid
|
||||||
|
set(FPHSA_FOUND_${_NAME} TRUE)
|
||||||
|
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
|
||||||
|
if(NOT ${_CURRENT_VAR})
|
||||||
|
set(FPHSA_FOUND_${_NAME} FALSE)
|
||||||
|
string(APPEND MISSING_VARS " ${_CURRENT_VAR}")
|
||||||
|
else()
|
||||||
|
string(APPEND DETAILS "[${${_CURRENT_VAR}}]")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(FPHSA_FOUND_${_NAME})
|
||||||
|
set(${_NAME}_FOUND TRUE)
|
||||||
|
set(${_NAME_UPPER}_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
set(${_NAME}_FOUND FALSE)
|
||||||
|
set(${_NAME_UPPER}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# component handling
|
||||||
|
unset(FOUND_COMPONENTS_MSG)
|
||||||
|
unset(MISSING_COMPONENTS_MSG)
|
||||||
|
|
||||||
|
if(FPHSA_HANDLE_COMPONENTS)
|
||||||
|
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||||
|
if(${_NAME}_${comp}_FOUND)
|
||||||
|
|
||||||
|
if(NOT DEFINED FOUND_COMPONENTS_MSG)
|
||||||
|
set(FOUND_COMPONENTS_MSG "found components:")
|
||||||
|
endif()
|
||||||
|
string(APPEND FOUND_COMPONENTS_MSG " ${comp}")
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
if(NOT DEFINED MISSING_COMPONENTS_MSG)
|
||||||
|
set(MISSING_COMPONENTS_MSG "missing components:")
|
||||||
|
endif()
|
||||||
|
string(APPEND MISSING_COMPONENTS_MSG " ${comp}")
|
||||||
|
|
||||||
|
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||||
|
set(${_NAME}_FOUND FALSE)
|
||||||
|
string(APPEND MISSING_VARS " ${comp}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
|
||||||
|
string(APPEND DETAILS "[c${COMPONENT_MSG}]")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# version handling:
|
||||||
|
set(VERSION_MSG "")
|
||||||
|
set(VERSION_OK TRUE)
|
||||||
|
|
||||||
|
# check with DEFINED here as the requested or found version may be "0"
|
||||||
|
if (DEFINED ${_NAME}_FIND_VERSION)
|
||||||
|
if(DEFINED ${FPHSA_VERSION_VAR})
|
||||||
|
set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}})
|
||||||
|
|
||||||
|
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
||||||
|
# count the dots in the version string
|
||||||
|
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}")
|
||||||
|
# add one dot because there is one dot more than there are components
|
||||||
|
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
|
||||||
|
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
|
||||||
|
# Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT
|
||||||
|
# is at most 4 here. Therefore a simple lookup table is used.
|
||||||
|
if (${_NAME}_FIND_VERSION_COUNT EQUAL 1)
|
||||||
|
set(_VERSION_REGEX "[^.]*")
|
||||||
|
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2)
|
||||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*")
|
||||||
|
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3)
|
||||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*")
|
||||||
|
else ()
|
||||||
|
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
|
||||||
|
endif ()
|
||||||
|
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}")
|
||||||
|
unset(_VERSION_REGEX)
|
||||||
|
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
|
||||||
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||||
|
set(VERSION_OK FALSE)
|
||||||
|
else ()
|
||||||
|
set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
|
||||||
|
endif ()
|
||||||
|
unset(_VERSION_HEAD)
|
||||||
|
else ()
|
||||||
|
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION)
|
||||||
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||||
|
set(VERSION_OK FALSE)
|
||||||
|
else ()
|
||||||
|
set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
unset(_VERSION_DOTS)
|
||||||
|
|
||||||
|
else() # minimum version specified:
|
||||||
|
if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION)
|
||||||
|
set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
||||||
|
set(VERSION_OK FALSE)
|
||||||
|
else ()
|
||||||
|
set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
# if the package was not found, but a version was given, add that to the output:
|
||||||
|
if(${_NAME}_FIND_VERSION_EXACT)
|
||||||
|
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
|
||||||
|
else()
|
||||||
|
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
else ()
|
||||||
|
# Check with DEFINED as the found version may be 0.
|
||||||
|
if(DEFINED ${FPHSA_VERSION_VAR})
|
||||||
|
set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")")
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if(VERSION_OK)
|
||||||
|
string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]")
|
||||||
|
else()
|
||||||
|
set(${_NAME}_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# print the result:
|
||||||
|
if (${_NAME}_FOUND)
|
||||||
|
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
|
||||||
|
else ()
|
||||||
|
|
||||||
|
if(FPHSA_CONFIG_MODE)
|
||||||
|
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
|
||||||
|
else()
|
||||||
|
if(NOT VERSION_OK)
|
||||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
|
||||||
|
else()
|
||||||
|
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE)
|
||||||
|
set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE)
|
||||||
|
endfunction()
|
48
CMakeModules/FindPackageMessage.cmake
vendored
Normal file
48
CMakeModules/FindPackageMessage.cmake
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindPackageMessage
|
||||||
|
------------------
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
find_package_message(<name> "message for user" "find result details")
|
||||||
|
|
||||||
|
This function is intended to be used in FindXXX.cmake modules files.
|
||||||
|
It will print a message once for each unique find result. This is
|
||||||
|
useful for telling the user where a package was found. The first
|
||||||
|
argument specifies the name (XXX) of the package. The second argument
|
||||||
|
specifies the message to display. The third argument lists details
|
||||||
|
about the find result so that if they change the message will be
|
||||||
|
displayed again. The macro also obeys the QUIET argument to the
|
||||||
|
find_package command.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
if(X11_FOUND)
|
||||||
|
find_package_message(X11 "Found X11: ${X11_X11_LIB}"
|
||||||
|
"[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
|
||||||
|
else()
|
||||||
|
...
|
||||||
|
endif()
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
function(find_package_message pkg msg details)
|
||||||
|
# Avoid printing a message repeatedly for the same find result.
|
||||||
|
if(NOT ${pkg}_FIND_QUIETLY)
|
||||||
|
string(REPLACE "\n" "" details "${details}")
|
||||||
|
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
|
||||||
|
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
|
||||||
|
# The message has not yet been printed.
|
||||||
|
message(STATUS "${msg}")
|
||||||
|
|
||||||
|
# Save the find details in the cache to avoid printing the same
|
||||||
|
# message again.
|
||||||
|
set("${DETAILS_VAR}" "${details}"
|
||||||
|
CACHE INTERNAL "Details about finding ${pkg}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
47
README.md
47
README.md
@ -5,19 +5,40 @@
|
|||||||
|
|
||||||
sist2 (Simple incremental search tool)
|
sist2 (Simple incremental search tool)
|
||||||
|
|
||||||
|
*Warning: sist2 is in early development*
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
* Fast, low memory usage
|
||||||
|
* Portable (all its features are packaged in a single executable)
|
||||||
|
* Extracts text from common file types\*
|
||||||
|
* Generates thumbnails\*
|
||||||
|
* Incremental scanning
|
||||||
|
|
||||||
|
|
||||||
|
\* See [format support](#format-support)
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. Have an [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) instance running
|
||||||
|
1. Download the [latest sist2 release](https://github.com/simon987/sist2/releases)
|
||||||
|
|
||||||
|
*Windows users*: `sist2` runs under [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)
|
||||||
|
|
||||||
|
*Mac users*: See [#1](https://github.com/simon987/sist2/issues/1)
|
||||||
|
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
See help page `sist2 --help` for more details.
|
See help page `sist2 --help` for more details.
|
||||||
|
|
||||||
**Scan a directory**
|
**Scan a directory**
|
||||||
```bash
|
```bash
|
||||||
sist2 scan ~/Documents -o ./orig_idx/
|
sist2 scan ~/Documents -o ./orig_idx/
|
||||||
sist2 scan --threads 4 --content-size 16384 /mnt/Pictures
|
sist2 scan --threads 4 --content-size 16384 /mnt/Pictures
|
||||||
sist2 scan -i ./orig_idx/ -o ./updated_idx/ ~/Documents
|
sist2 scan --incremental ./orig_idx/ -o ./updated_idx/ ~/Documents
|
||||||
```
|
```
|
||||||
|
|
||||||
**Push index to Elasticsearch or file**
|
**Push index to Elasticsearch or file**
|
||||||
@ -46,22 +67,11 @@ docx, xlsx, pptx | | *planned* | no | *planned* |
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
1. Download runtime dependencies
|
|
||||||
|
|
||||||
`apt install curl bzip2`
|
|
||||||
|
|
||||||
1. Download binary
|
|
||||||
|
|
||||||
Get [the latest release](https://github.com/simon987/sist2/releases) from GitHub
|
|
||||||
|
|
||||||
1. (Optional) Add to search path
|
|
||||||
|
|
||||||
`mv sist2 /usr/bin/`
|
|
||||||
|
|
||||||
## Build from source
|
## Build from source
|
||||||
|
|
||||||
|
You can compile **sist2** by yourself if you don't want to use the pre-compiled
|
||||||
|
binaries.
|
||||||
|
|
||||||
1. Install compile-time dependencies
|
1. Install compile-time dependencies
|
||||||
|
|
||||||
*(Debian)*
|
*(Debian)*
|
||||||
@ -70,12 +80,7 @@ docx, xlsx, pptx | | *planned* | no | *planned* |
|
|||||||
libssl-dev uuid-dev libavformat-dev libswscale-dev \
|
libssl-dev uuid-dev libavformat-dev libswscale-dev \
|
||||||
python3 libmagic-dev libfreetype6-dev libcurl-dev \
|
python3 libmagic-dev libfreetype6-dev libcurl-dev \
|
||||||
libbz2-dev yasm
|
libbz2-dev yasm
|
||||||
```
|
|
||||||
*(Archlinux)*
|
|
||||||
```bash
|
|
||||||
pacman -S git ffmpeg pkg-config cmake openssl curl \
|
|
||||||
bzip2 yasm libutil-linux
|
|
||||||
```
|
|
||||||
2. Build
|
2. Build
|
||||||
```bash
|
```bash
|
||||||
git clone --recurse-submodules https://github.com/simon987/sist2
|
git clone --recurse-submodules https://github.com/simon987/sist2
|
||||||
|
@ -94,7 +94,7 @@ void parse(void *arg) {
|
|||||||
if (!(SHOULD_PARSE(doc.mime))) {
|
if (!(SHOULD_PARSE(doc.mime))) {
|
||||||
|
|
||||||
} else if ((mmime == MimeVideo && doc.size >= MIN_VIDEO_SIZE) || mmime == MimeAudio || mmime == MimeImage) {
|
} else if ((mmime == MimeVideo && doc.size >= MIN_VIDEO_SIZE) || mmime == MimeAudio || mmime == MimeImage) {
|
||||||
// parse_media(job->filepath, &doc);
|
parse_media(job->filepath, &doc);
|
||||||
|
|
||||||
} else if (IS_PDF(doc.mime)) {
|
} else if (IS_PDF(doc.mime)) {
|
||||||
void *pdf_buf = read_all(job, (char *) buf, bytes_read, &fd);
|
void *pdf_buf = read_all(job, (char *) buf, bytes_read, &fd);
|
||||||
@ -105,15 +105,15 @@ void parse(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (mmime == MimeText && ScanCtx.content_size > 0) {
|
} else if (mmime == MimeText && ScanCtx.content_size > 0) {
|
||||||
// parse_text(bytes_read, &fd, (char *) buf, &doc);
|
parse_text(bytes_read, &fd, (char *) buf, &doc);
|
||||||
|
|
||||||
} else if (IS_FONT(doc.mime)) {
|
} else if (IS_FONT(doc.mime)) {
|
||||||
// void *font_buf = read_all(job, (char *) buf, bytes_read, &fd);
|
void *font_buf = read_all(job, (char *) buf, bytes_read, &fd);
|
||||||
// parse_font(font_buf, doc.size, &doc);
|
parse_font(font_buf, doc.size, &doc);
|
||||||
//
|
|
||||||
// if (font_buf != buf) {
|
if (font_buf != buf) {
|
||||||
// free(font_buf);
|
free(font_buf);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write_document(&doc);
|
write_document(&doc);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
#include <src/ctx.h>
|
||||||
#include "pdf.h"
|
#include "pdf.h"
|
||||||
#include "src/ctx.h"
|
#include "src/ctx.h"
|
||||||
|
|
||||||
__always_inline
|
|
||||||
fz_page *render_cover(fz_context *ctx, document_t *doc, fz_document *fzdoc) {
|
fz_page *render_cover(fz_context *ctx, document_t *doc, fz_document *fzdoc) {
|
||||||
|
|
||||||
fz_page *cover = fz_load_page(ctx, fzdoc, 0);
|
fz_page *cover = fz_load_page(ctx, fzdoc, 0);
|
||||||
@ -25,8 +25,12 @@ fz_page *render_cover(fz_context *ctx, document_t *doc, fz_document *fzdoc) {
|
|||||||
fz_device *dev = fz_new_draw_device(ctx, m, pixmap);
|
fz_device *dev = fz_new_draw_device(ctx, m, pixmap);
|
||||||
|
|
||||||
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
||||||
|
fz_try(ctx)
|
||||||
fz_run_page(ctx, cover, dev, fz_identity, NULL);
|
fz_run_page(ctx, cover, dev, fz_identity, NULL);
|
||||||
|
fz_always(ctx)
|
||||||
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
||||||
|
fz_catch(ctx)
|
||||||
|
fz_rethrow(ctx);
|
||||||
|
|
||||||
fz_drop_device(ctx, dev);
|
fz_drop_device(ctx, dev);
|
||||||
|
|
||||||
@ -72,6 +76,7 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
|||||||
fzdoc = fz_open_document_with_stream(ctx, mime_get_mime_text(doc->mime), stream);
|
fzdoc = fz_open_document_with_stream(ctx, mime_get_mime_text(doc->mime), stream);
|
||||||
|
|
||||||
int page_count = fz_count_pages(ctx, fzdoc);
|
int page_count = fz_count_pages(ctx, fzdoc);
|
||||||
|
|
||||||
fz_page *cover = render_cover(ctx, doc, fzdoc);
|
fz_page *cover = render_cover(ctx, doc, fzdoc);
|
||||||
|
|
||||||
fz_stext_options opts;
|
fz_stext_options opts;
|
||||||
@ -90,8 +95,12 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
|
|||||||
fz_device *dev = fz_new_stext_device(ctx, stext, &opts);
|
fz_device *dev = fz_new_stext_device(ctx, stext, &opts);
|
||||||
|
|
||||||
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
pthread_mutex_lock(&ScanCtx.mupdf_mu);
|
||||||
|
fz_try(ctx)
|
||||||
fz_run_page_contents(ctx, page, dev, fz_identity, NULL);
|
fz_run_page_contents(ctx, page, dev, fz_identity, NULL);
|
||||||
|
fz_always(ctx)
|
||||||
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
pthread_mutex_unlock(&ScanCtx.mupdf_mu);
|
||||||
|
fz_catch(ctx)
|
||||||
|
fz_rethrow(ctx);
|
||||||
|
|
||||||
fz_drop_device(ctx, dev);
|
fz_drop_device(ctx, dev);
|
||||||
|
|
||||||
|
@ -167,8 +167,10 @@ void tpool_destroy(tpool_t *pool) {
|
|||||||
|
|
||||||
for (size_t i = 0; i < pool->thread_cnt; i++) {
|
for (size_t i = 0; i < pool->thread_cnt; i++) {
|
||||||
pthread_t thread = pool->threads[i];
|
pthread_t thread = pool->threads[i];
|
||||||
|
if (thread != 0) {
|
||||||
pthread_cancel(thread);
|
pthread_cancel(thread);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_destroy(&(pool->work_mutex));
|
pthread_mutex_destroy(&(pool->work_mutex));
|
||||||
pthread_cond_destroy(&(pool->has_work_cond));
|
pthread_cond_destroy(&(pool->has_work_cond));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user