Commit 098cb6eb authored by Atsuhito Kohda's avatar Atsuhito Kohda

Imported Upstream version 0.5~svn1351

parent 55fa8d51
......@@ -21,3 +21,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FindLua.cmake is taken from https://github.com/LuaDist/lua/blob/7c6b93fc5d90f729ad40737655a4d936883102a2/cmake/FindLua.cmake
# Locate Lua library
# This module defines
# LUA_EXECUTABLE, if found
# LUA_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Modified to support Lua 5.2 by LuaDist 2012
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
#
# The required version of Lua can be specified using the
# standard syntax, e.g. FIND_PACKAGE(Lua 5.1)
# Otherwise the module will search for any available Lua implementation
# Always search for non-versioned lua first (recommended)
SET(_POSSIBLE_LUA_INCLUDE include include/lua)
SET(_POSSIBLE_LUA_EXECUTABLE lua)
SET(_POSSIBLE_LUA_LIBRARY lua)
# Determine possible naming suffixes (there is no standard for this)
IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}")
ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1")
ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
# Set up possible search names and locations
FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES})
LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}")
LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}")
LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}")
ENDFOREACH(_SUFFIX)
# Find the lua executable
FIND_PROGRAM(LUA_EXECUTABLE
NAMES ${_POSSIBLE_LUA_EXECUTABLE}
)
# Find the lua header
FIND_PATH(LUA_INCLUDE_DIR lua.h
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES ${_POSSIBLE_LUA_INCLUDE}
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
# Find the lua library
FIND_LIBRARY(LUA_LIBRARY
NAMES ${_POSSIBLE_LUA_LIBRARY}
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)
IF(LUA_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LUA_MATH_LIBRARY m)
SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
ELSE(UNIX AND NOT APPLE)
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
ENDIF(UNIX AND NOT APPLE)
ENDIF(LUA_LIBRARY)
# Determine Lua version
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
UNSET(lua_version_str)
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE)
......@@ -5,8 +5,8 @@
# POPPLER_HAS_XPDF - A boolean indicating if Poppler XPDF headers are available
# POPPLER_NEEDS_FONTCONFIG - A boolean indicating if libpoppler depends on libfontconfig
# POPPLER_XPDF_INCLUDE_DIR - the include directory for Poppler XPDF headers
# POPPLER_QT4_INCLUDE_DIR - the include directory for Poppler-Qt4 headers
# POPPLER_QT4_LIBRARIES - Link this to use only libpoppler-Qt4
# POPPLER_QT_INCLUDE_DIR - the include directory for Poppler-Qt4 headers
# POPPLER_QT_LIBRARIES - Link this to use only libpoppler-Qt4
# POPPLER_LIBRARIES - Link these to use Poppler and Poppler-Qt4
#
# Note: the Poppler-cpp include directory is currently not needed by TeXworks
......@@ -24,7 +24,7 @@ endif ( POPPLER_LIBRARIES )
if( NOT WIN32 )
find_package(PkgConfig)
pkg_check_modules(POPPLER_PKG QUIET poppler)
pkg_check_modules(POPPLER_BASE_PKG QUIET poppler)
pkg_check_modules(POPPLER_QT_PKG QUIET poppler-qt${QT_VERSION_MAJOR})
endif( NOT WIN32 )
......@@ -34,7 +34,7 @@ FIND_PATH(POPPLER_XPDF_INCLUDE_DIR NAMES poppler-config.h
/usr/local/include
/usr/include
HINTS
${POPPLER_PKG_INCLUDE_DIRS} # Generated by pkg-config
${POPPLER_BASE_PKG_INCLUDE_DIRS} # Generated by pkg-config
PATH_SUFFIXES
poppler
)
......@@ -47,24 +47,24 @@ ELSE( NOT(POPPLER_XPDF_INCLUDE_DIR) )
ENDIF( NOT(POPPLER_XPDF_INCLUDE_DIR) )
# Find libpoppler, libpoppler-qt4 and associated header files (Required)
FIND_LIBRARY(POPPLER_LIBRARIES NAMES poppler ${POPPLER_PKG_LIBRARIES}
FIND_LIBRARY(POPPLER_BASE_LIBRARIES NAMES poppler ${POPPLER_BASE_PKG_LIBRARIES}
PATHS
/usr/local
/usr
HINTS
${POPPLER_PKG_LIBRARY_DIRS} # Generated by pkg-config
${POPPLER_BASE_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
IF ( NOT(POPPLER_LIBRARIES) )
IF ( NOT(POPPLER_BASE_LIBRARIES) )
MESSAGE(STATUS "Could not find libpoppler." )
ENDIF ()
# Scan poppler libraries for dependencies on Fontconfig
INCLUDE(GetPrerequisites)
MARK_AS_ADVANCED(gp_cmd)
GET_PREREQUISITES("${POPPLER_LIBRARIES}" POPPLER_PREREQS TRUE FALSE "" "")
GET_PREREQUISITES("${POPPLER_BASE_LIBRARIES}" POPPLER_PREREQS TRUE FALSE "" "")
IF ("${POPPLER_PREREQS}" MATCHES "fontconfig")
SET(POPPLER_NEEDS_FONTCONFIG TRUE)
ELSE ()
......@@ -100,13 +100,21 @@ MARK_AS_ADVANCED(POPPLER_QT_LIBRARIES)
IF ( NOT(POPPLER_QT_LIBRARIES) )
MESSAGE(STATUS "Could not find libpoppler-qt${QT_VERSION_MAJOR}." )
ENDIF ()
LIST(INSERT POPPLER_LIBRARIES 0 ${POPPLER_QT_LIBRARIES})
SET(POPPLER_LIBRARIES ${POPPLER_QT_LIBRARIES} ${POPPLER_BASE_LIBRARIES})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Poppler DEFAULT_MSG POPPLER_LIBRARIES POPPLER_QT_INCLUDE_DIR )
IF ( POPPLER_QT_INCLUDE_DIR AND EXISTS "${POPPLER_QT_INCLUDE_DIR}/../poppler-config.h" )
file(STRINGS "${POPPLER_QT_INCLUDE_DIR}/../poppler-config.h" POPPLER_CONFIG_H REGEX "^#define POPPLER_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*POPPLER_VERSION \"([0-9]+).*$" "\\1" POPPLER_VERSION_MAJOR "${POPPLER_CONFIG_H}")
string(REGEX REPLACE "^.*POPPLER_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" POPPLER_VERSION_MINOR "${POPPLER_CONFIG_H}")
string(REGEX REPLACE "^.*POPPLER_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" POPPLER_VERSION_PATCH "${POPPLER_CONFIG_H}")
set(POPPLER_VERSION_STRING "${POPPLER_VERSION_MAJOR}.${POPPLER_VERSION_MINOR}.${POPPLER_VERSION_PATCH}")
ENDIF ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Poppler REQUIRED_VARS POPPLER_LIBRARIES POPPLER_QT_INCLUDE_DIR VERSION_VAR POPPLER_VERSION_STRING )
# show the POPPLER_(XPDF/QT4)_INCLUDE_DIR and POPPLER_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(POPPLER_XPDF_INCLUDE_DIR POPPLER_QT_INCLUDE_DIR POPPLER_LIBRARIES)
MARK_AS_ADVANCED(POPPLER_XPDF_INCLUDE_DIR POPPLER_QT_INCLUDE_DIR POPPLER_BASE_LIBRARIES POPPLER_LIBRARIES)
# Adapted from CMake 2.8 QT4_CREATE_TRANSLATION
# TODO: Find a better name for this
# Qt-version-agnostic wrappers
if (QT_VERSION_MAJOR EQUAL 5)
macro(QT_ADD_RESOURCES)
QT5_ADD_RESOURCES(${ARGV})
endmacro()
else()
macro(QT_ADD_RESOURCES)
QT4_ADD_RESOURCES(${ARGV})
endmacro()
endif()
macro (QT_EXTRACT_OPTIONS _qt_files _qt_options)
set(${_qt_files})
set(${_qt_options})
set(_QT_DOING_OPTIONS FALSE)
foreach(_currentArg ${ARGN})
if ("${_currentArg}" STREQUAL "OPTIONS")
set(_QT_DOING_OPTIONS TRUE)
else ()
if(_QT_DOING_OPTIONS)
list(APPEND ${_qt_options} "${_currentArg}")
else()
list(APPEND ${_qt_files} "${_currentArg}")
endif()
endif ()
endforeach()
endmacro ()
MACRO(CREATE_QT_PRO_FILE _pro_path _pro_include_path)
QT_EXTRACT_OPTIONS(_pro_files _pro_options ${ARGN})
SET(_my_sources)
SET(_my_headers)
SET(_my_forms)
SET(_my_dirs)
SET(_my_tsfiles)
SET(_ts_pro)
GET_FILENAME_COMPONENT(_pro_basepath ${_pro_path} PATH)
FOREACH (_file ${_pro_files})
GET_FILENAME_COMPONENT(_ext ${_file} EXT)
GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
IF(NOT _ext)
LIST(APPEND _my_dirs ${_abs_FILE})
ELSEIF(_ext MATCHES "ts")
LIST(APPEND _my_tsfiles ${_abs_FILE})
ELSEIF(_ext MATCHES "ui")
LIST(APPEND _my_forms ${_abs_FILE})
ELSEIF(_ext MATCHES ".(h|hpp|hxx)")
LIST(APPEND _my_headers ${_abs_FILE})
ELSEIF(_ext MATCHES "\\.(c|cpp|cxx|c\\+\\+)")
LIST(APPEND _my_sources ${_abs_FILE})
ELSE()
MESSAGE(AUTHOR_WARNING "CREATE_QT4_PRO_FILE cannot handle file '${_abs_FILE}'.")
ENDIF()
ENDFOREACH(_file)
# Construct the .pro file
# It includes SOURCES and TRANSLATIONS settings, but nothing else.
SET(_pro_content "# WARNING: This file was generated automatically by CMake.\n\n")
SET(_pro_content "${_pro_content}error(\"This file is not intended for building ${PROJECT_NAME}. Please use CMake instead. See the README for further instructions.\")\n\n")
SET(_pro_content "${_pro_content}# INCLUDEPATH must be set so lupdate finds headers, namespace declarations, etc.\n")
SET(_pro_content "${_pro_content}INCLUDEPATH += ${_pro_include_path}")
IF(_my_sources)
SET(_pro_content "${_pro_content}\n\nSOURCES =")
FOREACH(_pro_file ${_my_sources})
FILE(RELATIVE_PATH _pro_file ${_pro_basepath} ${_pro_file})
SET(_pro_content "${_pro_content} \\\n \"${_pro_file}\"")
ENDFOREACH(_pro_file ${_my_sources})
ENDIF(_my_sources)
IF(_my_headers)
SET(_pro_content "${_pro_content}\n\nHEADERS =")
FOREACH(_pro_file ${_my_headers})
FILE(RELATIVE_PATH _pro_file ${_pro_basepath} ${_pro_file})
SET(_pro_content "${_pro_content} \\\n \"${_pro_file}\"")
ENDFOREACH(_pro_file ${_my_headers})
ENDIF(_my_headers)
IF(_my_forms)
SET(_pro_content "${_pro_content}\n\FORMS =")
FOREACH(_pro_file ${_my_forms})
FILE(RELATIVE_PATH _pro_file ${_pro_basepath} ${_pro_file})
SET(_pro_content "${_pro_content} \\\n \"${_pro_file}\"")
ENDFOREACH(_pro_file ${_my_forms})
ENDIF(_my_forms)
IF(_my_tsfiles)
SET(_pro_content "${_pro_content}\n\nTRANSLATIONS =")
FOREACH(_pro_file ${_my_tsfiles})
FILE(RELATIVE_PATH _pro_file ${_pro_basepath} ${_pro_file})
SET(_pro_content "${_pro_content} \\\n \"${_pro_file}\"")
ENDFOREACH(_pro_file ${_my_tsfiles})
ENDIF(_my_tsfiles)
FILE(WRITE ${_pro_path} "${_pro_content}\n")
ENDMACRO(CREATE_QT_PRO_FILE)
# QT_ADD_QM_TRANSLATIONS(<output_var> <1.qm> [<2.qm> ...])
MACRO(QT_ADD_QM_TRANSLATIONS _qm_res)
# Construct an appropriate resource file
SET(_qm_qrc "<!DOCTYPE RCC>\n<RCC version=\"1.0\">\n<qresource>\n")
FOREACH(_qm_file ${ARGN})
FILE(RELATIVE_PATH _qm_file ${CMAKE_CURRENT_BINARY_DIR} ${_qm_file})
SET(_qm_qrc "${_qm_qrc}<file>${_qm_file}</file>\n")
ENDFOREACH(_qm_file ${_qm_files})
SET(_qm_qrc "${_qm_qrc}</qresource>\n</RCC>\n")
SET(_qm_qrc_path ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_trans.qrc)
FILE(WRITE ${_qm_qrc_path} ${_qm_qrc})
QT_ADD_RESOURCES(${_qm_res} ${_qm_qrc_path})
ENDMACRO(QT_ADD_QM_TRANSLATIONS)
......@@ -49,20 +49,13 @@ PROJECT(TeXworks)
# We require CMake v2.8 or greater because it is the first version that
# provides support for certain parts of Qt, such as the ScriptTools.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
CMAKE_POLICY(VERSION 2.8.6)
SET(CMAKE_COLOR_MAKEFILE ON)
# Always add the current source and binary directories to the header include
# path when compiling.
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
IF ( WIN32 )
MESSAGE( WARNING
"The CMake build system has only been tested on Mac OS X and Linux."
"\nIt probably won't work on Windows. Patches containing fixes are"
"\nwelcomed at:"
"\n https://github.com/Sharpie/TeXworks"
)
ENDIF ()
SET(CMAKE_AUTOMOC TRUE)
# Determine Version Numbers
# -------------------------
......@@ -152,23 +145,78 @@ ENDIF()
# directory contains scripts that locate project components such as Poppler.
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/Modules ${CMAKE_MODULE_PATH})
# Declare Qt libraries required by this project.
SET (QT_COMPONENTS
QtCore
QtGui
QtUiTools
QtScript
QtScriptTools
)
set(DESIRED_QT_VERSION "" CACHE STRING "Pick a version of Qt to use: 4 or 5")
MARK_AS_ADVANCED(DESIRED_QT_VERSION)
# Check for Qt4 by default
IF (NOT DESIRED_QT_VERSION OR DESIRED_QT_VERSION MATCHES 4)
# Declare Qt libraries required by this project.
SET (QT_COMPONENTS
QtCore
QtGui
QtUiTools
QtScript
QtScriptTools
)
IF ( UNIX AND NOT APPLE )
LIST(APPEND QT_COMPONENTS QtDbus)
ENDIF ()
# Locate Qt. `INCLUDE(UseQt4)` brings in a set of macros that helps us deal
# with Qt-specific tasks such as compiling resources or running `moc`.
FIND_PACKAGE(Qt4 COMPONENTS ${QT_COMPONENTS} REQUIRED)
INCLUDE(UseQt4)
ENDIF()
# If Qt4 is not found (or not desired), check for Qt5
IF (DESIRED_QT_VERSION MATCHES 5 OR NOT QT4_FOUND)
find_package(Qt5Widgets QUIET)
find_package(Qt5UiTools QUIET)
find_package(Qt5Script QUIET)
find_package(Qt5ScriptTools QUIET)
find_package(Qt5Xml QUIET)
IF ( UNIX AND NOT APPLE )
find_package(Qt5DBus QUIET)
ENDIF ()
IF( WIN32 AND NOT BUILD_SHARED_LIBS )
# For static Windows builds, we also need to pull in the Qt5 Platform
# support library, which is not exposed to CMake properly, unfortunately
GET_TARGET_PROPERTY(QT_LIB_DIR "${Qt5Widgets_LIBRARIES}" LOCATION)
GET_FILENAME_COMPONENT(QT_LIB_DIR "${QT_LIB_DIR}" PATH)
FIND_LIBRARY(Qt5Platform_LIBRARIES Qt5PlatformSupport
HINTS "${QT_LIB_DIR}"
)
FIND_LIBRARY(Qt5QWindows_LIBRARIES qwindows
HINTS "${QT_LIB_DIR}/../plugins/platforms"
)
ADD_DEFINITIONS(-DSTATIC_QT5)
ENDIF()
IF(Qt5Widgets_FOUND AND Qt5Core_FOUND AND Qt5UiTools_FOUND AND Qt5Script_FOUND AND Qt5ScriptTools_FOUND AND Qt5Xml_FOUND)
SET(QT5_FOUND TRUE)
SET(QT_INCLUDE_DIR "${Qt5Widgets_INCLUDE_DIRS} ${Qt5UiTools_INCLUDE_DIRS} ${Qt5Script_INCLUDE_DIRS} ${Qt5ScriptTools_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}")
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5UiTools_LIBRARIES} ${Qt5Script_LIBRARIES} ${Qt5ScriptTools_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Platform_LIBRARIES} ${Qt5QWindows_LIBRARIES})
# Note: Qt5 only sets Qt5Widgets_VERSION, etc., but not QT_VERSION_MAJOR,
# etc. which is used here.
string(REGEX REPLACE "^([0-9]+).*$" "\\1" QT_VERSION_MAJOR "${Qt5Widgets_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$" "\\1" QT_VERSION_MINOR "${Qt5Widgets_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" QT_VERSION_PATCH "${Qt5Widgets_VERSION}")
ENDIF()
ENDIF()
IF (NOT QT4_FOUND AND NOT QT5_FOUND)
MESSAGE(FATAL_ERROR "Could not find required Qt. Please install Qt (see http://qt-project.org/) and/or adjust DESIRED_QT_VERSION.")
ENDIF()
# Expose the major version number of Qt to the preprocessor. This is necessary
# to include the correct Qt headers (as QTVERSION is not defined before any Qt
# headers are included)
ADD_DEFINITIONS(-DQT_VERSION_MAJOR=${QT_VERSION_MAJOR})
INCLUDE( TranslationMacros )
IF ( UNIX AND NOT APPLE )
LIST(APPEND QT_COMPONENTS QtDbus)
ENDIF ()
# Locate Qt. `INCLUDE(UseQt4)` brings in a set of macros that helps us deal
# with Qt-specific tasks such as compiling resources or running `moc`.
FIND_PACKAGE(Qt4 COMPONENTS ${QT_COMPONENTS} REQUIRED)
INCLUDE(UseQt4)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(Hunspell REQUIRED)
......@@ -195,20 +243,23 @@ ENDIF ()
SET(TeXworks_LIB_DIRS ${QT_LIBRARY_DIR})
set(TEXWORKS_ADDITIONAL_LIBS "" CACHE STRING "Additional libraries not found by CMake")
MARK_AS_ADVANCED(TEXWORKS_ADDITIONAL_LIBS)
SET(TeXworks_LIBS
${QT_LIBRARIES}
${POPPLER_LIBRARIES}
${HUNSPELL_LIBRARIES}
${QT_LIBRARIES}
${ZLIB_LIBRARIES}
${TEXWORKS_ADDITIONAL_LIBS}
)
# Configure Optional Dependencies
# -------------------------------
# CMake 2.8 has separate find scripts for Lua 5.1 and Lua 5.0. We assume that
# the most recent Lua version is installed.
IF ( WITH_LUA )
FIND_PACKAGE(Lua51)
FIND_PACKAGE(Lua)
ENDIF()
IF ( WITH_PYTHON )
......@@ -226,7 +277,7 @@ IF ( WITH_PYTHON )
ENDIF ()
ENDIF()
IF ( LUA51_FOUND AND WITH_LUA AND NOT ${BUILD_SHARED_LIBS})
IF ( LUA_FOUND AND WITH_LUA AND NOT ${BUILD_SHARED_LIBS})
ADD_DEFINITIONS(-DQT_STATICPLUGIN -DSTATIC_LUA_SCRIPTING_PLUGIN)
ENDIF ()
......@@ -256,13 +307,6 @@ ENDIF ()
# Building
# ========
# Build main TeXworks application
# -------------------------------
ADD_SUBDIRECTORY(src)
# Build Plugins
# -------------
# On OS X, the plugins should live inside the application bundle.
IF ( APPLE )
SET(TeXworks_PLUGIN_DIR ${PROJECT_NAME}.app/Contents/PlugIns)
......@@ -278,9 +322,15 @@ ELSE ()
MARK_AS_ADVANCED(TeXworks_PLUGIN_DIR)
ENDIF ()
# Build main TeXworks application
# -------------------------------
ADD_SUBDIRECTORY(src)
# Build Plugins
# -------------
# Build scripting language plugins if the required libraries are available.
IF ( LUA51_FOUND AND WITH_LUA )
IF ( LUA_FOUND AND WITH_LUA )
ADD_SUBDIRECTORY(${TeXworks_SOURCE_DIR}/plugins-src/TWLuaPlugin)
ENDIF ()
......@@ -387,7 +437,7 @@ CONFIG_INFO("Qt version" ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PA
CONFIG_INFO("Compiler optimization" ${CMAKE_BUILD_TYPE})
MESSAGE("")
CONFIG_YESNO("Lua scripting plugin" LUA51_FOUND)
CONFIG_YESNO("Lua scripting plugin" LUA_FOUND)
CONFIG_YESNO("Python scripting plugin" PYTHONLIBS_FOUND)
IF( APPLE )
CONFIG_YESNO(" OS X system python" USE_SYSTEM_PYTHON)
......
......@@ -206,10 +206,13 @@ SOURCES += src/main.cpp \
src/TWScriptable.cpp \
src/TWScript.cpp \
src/TWScriptAPI.cpp \
src/TWSystemCmd.cpp \
src/TeXDocument.cpp \
src/ClickableLabel.cpp \
src/ClosableTabWidget.cpp \
src/CommandlineParser.cpp \
src/CompletingEdit.cpp \
src/ConfigurableApp.cpp \
src/TeXHighlighter.cpp \
src/TeXDocks.cpp \
src/PDFDocument.cpp \
......
*.o
icons.cpp
pdf_viewer
unit-tests/*_test
QtPDF.pro
......@@ -20,51 +20,125 @@ if( PKG_CONFIG_FOUND )
pkg_check_modules(MUPDF_PKG QUIET mupdf)
endif( PKG_CONFIG_FOUND )
# Find libmupdf, libfitz and associated header files (Required)
FIND_LIBRARY(MUPDF_LIBRARY NAMES mupdf
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
FIND_LIBRARY(FITZ_LIBRARY NAMES fitz
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
MARK_AS_ADVANCED(MUPDF_LIBRARY)
MARK_AS_ADVANCED(FITZ_LIBRARY)
IF ( NOT(MUPDF_LIBRARY) OR NOT(FITZ_LIBRARY) )
MESSAGE(STATUS "Could not find MuPDF libraries." )
ELSE()
SET(MUPDF_LIBRARIES ${MUPDF_LIBRARY} ${FITZ_LIBRARY})
ENDIF()
FIND_PATH(MUPDF_INCLUDE_DIR NAMES mupdf.h
FIND_PATH(MUPDF_INCLUDE_DIR NAMES mupdf/pdf.h
PATHS
/usr/local/include
/usr/include
HINTS
${MUPDF_PKG_INCLUDE_DIRS} # Generated by pkg-config
)
IF ( NOT(MUPDF_INCLUDE_DIR) )
FIND_PATH(MUPDF_INCLUDE_DIR NAMES mupdf.h
PATHS
/usr/local/include
/usr/include
HINTS
${MUPDF_PKG_INCLUDE_DIRS} # Generated by pkg-config
)
ENDIF()
IF ( NOT(MUPDF_INCLUDE_DIR) )
MESSAGE(STATUS "Could not find MuPDF headers." )
ENDIF ()
IF (MUPDF_INCLUDE_DIR)
IF (EXISTS "${MUPDF_INCLUDE_DIR}/mupdf/pdf.h")
SET(MUPDF_VERSION_STRING "1.3")
ELSEIF (EXISTS "${MUPDF_INCLUDE_DIR}/mupdf.h")
FILE(STRINGS "${MUPDF_INCLUDE_DIR}/mupdf.h" MUPDF_H)
STRING(FIND "${MUPDF_H}" "pdf_new_obj_from_str" MUPDF_H_NEW_OBJ)
STRING(FIND "${MUPDF_H}" "pdf_new_rect" MUPDF_H_NEW_RECT)
STRING(FIND "${MUPDF_H}" "pdf_new_null" MUPDF_H_NEW_NULL)
IF (MUPDF_H_NEW_OBJ GREATER -1)
SET(MUPDF_VERSION_STRING "1.2")
ELSEIF (MUPDF_H_NEW_RECT GREATER -1)
SET(MUPDF_VERSION_STRING "1.1")
ELSEIF (MUPDF_H_NEW_NULL GREATER -1)
SET(MUPDF_VERSION_STRING "1.0")
ELSE()
SET(MUPDF_VERSION_STRING "0.9")
ENDIF()
ENDIF()
ENDIF()
# Find the libraries (Required; these vary between versions)
IF ("${MUPDF_VERSION_STRING}" VERSION_LESS "1.0")
FIND_LIBRARY(MUPDF_LIBRARY NAMES mupdf
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
FIND_LIBRARY(FITZ_LIBRARY NAMES fitz
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
MARK_AS_ADVANCED(MUPDF_LIBRARY)
MARK_AS_ADVANCED(FITZ_LIBRARY)
IF ( NOT(MUPDF_LIBRARY) OR NOT(FITZ_LIBRARY) )
MESSAGE(STATUS "Could not find MuPDF libraries." )
ELSE()
SET(MUPDF_LIBRARIES ${MUPDF_LIBRARY} ${FITZ_LIBRARY})
ENDIF()
ELSEIF( "${MUPDF_VERSION_STRING}" VERSION_LESS "1.3" )
FIND_LIBRARY(FITZ_LIBRARY NAMES fitz
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
MARK_AS_ADVANCED(FITZ_LIBRARY)
IF ( NOT(FITZ_LIBRARY) )
MESSAGE(STATUS "Could not find MuPDF libraries." )
ELSE()
SET(MUPDF_LIBRARIES ${FITZ_LIBRARY})
ENDIF()
ELSE()
FIND_LIBRARY(MUPDF_LIBRARY NAMES mupdf
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
FIND_LIBRARY(MUPDF_JS_LIBRARY NAMES mupdf-js-none
PATHS
/usr/local
/usr
HINTS
${MUPDF_PKG_LIBRARY_DIRS} # Generated by pkg-config
PATH_SUFFIXES
lib64
lib
)
MARK_AS_ADVANCED(MUPDF_LIBRARY MUPDF_JS_LIBRARY)
IF ( NOT(MUPDF_LIBRARY) OR NOT(MUPDF_JS_LIBRARY) )
MESSAGE(STATUS "Could not find MuPDF libraries." )
ELSE()
SET(MUPDF_LIBRARIES ${MUPDF_LIBRARY} ${MUPDF_JS_LIBRARY})
ENDIF()
ENDIF()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MuPDF DEFAULT_MSG MUPDF_LIBRARIES MUPDF_INCLUDE_DIR )
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MuPDF REQUIRED_VARS MUPDF_LIBRARIES MUPDF_INCLUDE_DIR VERSION_VAR MUPDF_VERSION_STRING)
# show the MUPDF_(XPDF/QT4)_INCLUDE_DIR and MUPDF_LIBRARIES variables only in the advanced view
......
......@@ -51,8 +51,20 @@ IF ( NOT(OPENJPEG_INCLUDE_DIR) )
MESSAGE(STATUS "Could not find OpenJPEG headers." )
ENDIF ()
IF ( OPENJPEG_LIBRARIES AND OPENJPEG_INCLUDE_DIR )
TRY_RUN(
OPENJPEG_VERSION_RUN
OPENJPEG_VERSION_COMPILE
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp
${CMAKE_CURRENT_LIST_DIR}/FindOpenJPEGVersion.c
CMAKE_FLAGS "-DLINK_LIBRARIES=openjpeg"
COMPILE_OUTPUT_VARIABLE TMP_OUT
RUN_OUTPUT_VARIABLE OPENJPEG_VERSION_STRING
)
ENDIF ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenJPEG DEFAULT_MSG OPENJPEG_LIBRARIES OPENJPEG_INCLUDE_DIR )