]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Give more tips in beamer-article.lyx
[lyx.git] / CMakeLists.txt
index f68222a3e868bfab26737b8eb234aa4453e10c71..d7cc165de365cc2fd399cddf7e95afea5a8321a5 100644 (file)
@@ -47,6 +47,19 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 # Supress regeneration
 set(CMAKE_SUPPRESS_REGENERATION FALSE)
 
+if(LYX_XMINGW)
+    set(CMAKE_SYSTEM_NAME Windows)
+    set(TOOLNAME ${LYX_XMINGW})
+    set(TOOLCHAIN "${TOOLNAME}-")
+    set(CMAKE_C_COMPILER   "${TOOLCHAIN}gcc"     CACHE PATH "Mingw C compiler" FORCE)
+    set(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++"     CACHE PATH "Mingw C++ compiler" FORCE)
+    set(CMAKE_RC_COMPILER  "${TOOLCHAIN}windres" CACHE PATH "Mingw rc compiler" FORCE)
+
+    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
+    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endif()
+
 if(NOT help AND NOT HELP)
        # 'project' triggers the searching for a compiler
        project(${LYX_PROJECT})
@@ -76,6 +89,11 @@ include(LyXMacros)
 # 3. parameter: default value, ON or OFF
 # 4. parameter: system on which option is used: ALL, GCC, MSVC, ...
 
+# Usage LYX_COMBO
+# 1. parameter: name without prefix 'LYX_'
+# 2. parameter: description
+# 3. parameter: default value
+# 4-n parameter: possible other string values
 
 LYX_OPTION_INIT()
 
@@ -84,6 +102,7 @@ LYX_OPTION(CPACK            "Use the CPack management (Implies LYX_INSTALL optio
 LYX_OPTION(LOCALVERSIONING  "Add version info to created package name (only used if LYX_CPACK option set)" OFF ALL)
 LYX_OPTION(INSTALL          "Build install projects/rules (implies a bunch of other options)" OFF ALL)
 LYX_OPTION(NLS              "Enable Native Language Support (NLS)" ON ALL)
+LYX_OPTION(REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL)
 LYX_OPTION(ASPELL           "Require aspell" OFF ALL)
 LYX_OPTION(ENCHANT          "Require Enchant" OFF ALL)
 LYX_OPTION(HUNSPELL         "Require Hunspell" OFF ALL)
@@ -121,6 +140,11 @@ LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC)
 # APPLE specific
 LYX_OPTION(DMG                   "Build as Mac bundle, needed for .dmg  (experimental) " OFF MAC)
 LYX_OPTION(COCOA                 "Use Cocoa on Mac" OFF MAC)
+if(LYX_XMINGW)
+  LYX_COMBO(USE_QT               "Use Qt version as frontend for MINGW" QT4)
+else()
+  LYX_COMBO(USE_QT               "Use Qt version as frontend" QT4 QT5)
+endif()
 
 
 if(help OR HELP)
@@ -145,7 +169,7 @@ endif()
 
 if(LYX_INSTALL)
        set(LYX_NLS ON)
-       if (WIN32)
+        if(WIN32 AND NOT MINGW)
                set(LYX_HUNSPELL ON)
        endif()
        if(LYX_CONSOLE MATCHES "FORCE")
@@ -167,6 +191,7 @@ else()
        set(LYX_MERGE_REBUILD OFF)
 endif()
 
+
 if(LYX_DEPENDENCIES_DOWNLOAD)
        message(STATUS)
        set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2010-deps)
@@ -190,6 +215,10 @@ if(LYX_DEPENDENCIES_DOWNLOAD)
                endif()
        endforeach()
        set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/deps20)
+    if(MSVC12)
+        # handle error in msvc12 when linking against msvc10 libs
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vd2")
+    endif()
 endif()
 
 
@@ -204,8 +233,7 @@ else()
 endif()
 
 
-# Variable that hold the flags that should only be used with C++ files
-set(LYX_CXX_SPECIFIC_FLAGS)
+set(LYX_GCC11_MODE)
 if(UNIX OR MINGW)
        execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
        message(STATUS "Using GCC version ${GCC_VERSION}")
@@ -220,7 +248,7 @@ if(UNIX OR MINGW)
                if(NOT CXX11COMPILER_FOUND)
                        message(FATAL_ERROR "A C++11 compatible compiler is required.")
                endif()
-               set(LYX_CXX_SPECIFIC_FLAGS "${LYX_CXX_SPECIFIC_FLAGS} ${CXX11_FLAG}")
+               set(LYX_GCC11_MODE "${CXX11_FLAG}")
        endif()
 else()
        if(MSVC10)
@@ -302,7 +330,7 @@ endif()
 # Set the programs (lyx, tex2lyx, etc.) suffix 
 # When building an OS X bundle, we will append
 # the suffix only to the bundle, not to the programs
-       set(PROGRAM_SUFFIX "")
+set(PROGRAM_SUFFIX "")
 if(LYX_PROGRAM_SUFFIX AND NOT (APPLE AND LYX_BUNDLE))
        set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}")
 endif()
@@ -374,13 +402,14 @@ if(LYX_INSTALL_PREFIX)
 endif()
 set(LYX_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
 
+string(REGEX REPLACE "/lyx${LYX_INSTALL_SUFFIX}$" "/share" SYSTEM_DATADIR ${CMAKE_INSTALL_PREFIX})
+
 if(LYX_PACKAGE_SUFFIX)
        set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
 else()
        set(PACKAGE ${PACKAGE_BASE})
 endif()
 
-
 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
        # see http://www.cmake.org/pipermail/cmake/2006-October/011559.html
        if (UNIX)
@@ -484,7 +513,7 @@ if(NOT MSVC)
        if(NOT LYX_QUIET)
                set(CMAKE_VERBOSE_MAKEFILE ON)
        endif()
-       set(LYX_CXX_FLAGS "-Wall -Wunused-parameter")
+       set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
        if(LYX_STDLIB_DEBUG)
                set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
        endif()
@@ -508,9 +537,15 @@ if(LYX_CXX_FLAGS_EXTRA)
        endforeach()
 endif()
 
-find_package(Qt5Core QUIET)
-if (Qt5Core_FOUND)
+if(LYX_XMINGW)
+    set(QT_MINGW_DIR ${LYX_QT4} CACHE PATH "Qt for Mingw" FORCE)
+    list(APPEND CMAKE_FIND_ROOT_PATH ${QT_MINGW_DIR} ${GNUWIN32_DIR})
+endif()
+if(LYX_USE_QT MATCHES "QT5")
+  find_package(Qt5Core REQUIRED)
+  if (Qt5Core_FOUND)
        find_package(Qt5Widgets REQUIRED)
+        find_package(Qt5X11Extras)
        set(QTVERSION ${Qt5Core_VERSION})
        macro (qt_use_modules)
                qt5_use_modules(${ARGN})
@@ -521,7 +556,8 @@ if (Qt5Core_FOUND)
        macro (qt_wrap_uifiles)
                qt5_wrap_ui(${ARGN})
        endmacro()
-else()
+  endif()
+elseif(LYX_USE_QT MATCHES "QT4")
        find_package(Qt4 "4.5.0" REQUIRED)
        macro (qt_use_modules)
        endmacro()
@@ -531,6 +567,8 @@ else()
        macro (qt_wrap_uifiles)
                qt4_wrap_ui(${ARGN})
        endmacro()
+else()
+  message(FATAL_ERROR "Unhandled value for LYX_USE_QT (${LYX_USE_QT})")
 endif()
 
 find_package(Magic)
@@ -540,20 +578,25 @@ endif()
 
 include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
 
-if(LYX_ASPELL)
-       find_package(ASPELL)
-       include_directories(${ASPELL_INCLUDE_DIR})
-endif()
-
-if(LYX_ENCHANT)
-       find_package(Enchant REQUIRED)
-       include_directories(${ENCHANT_INCLUDE_DIR})
-endif()
-
-if(LYX_HUNSPELL)
-       find_package(Hunspell REQUIRED)
-       include_directories(${HUNSPELL_INCLUDE_DIR})
-endif()
+set(Spelling_FOUND OFF)
+set(Include_used_spellchecker)   # String will be inserted into config.h
+
+foreach(_spell "ASPELL" "Enchant" "Hunspell")
+  string(TOUPPER ${_spell} _upspell)
+  find_package(${_spell})
+  if (${_upspell}_FOUND)
+    include_directories(${${_upspell}_INCLUDE_DIR})
+    set(Spelling_FOUND ON)
+    message(STATUS "Building with USE_${_upspell}")
+    set(Include_used_spellchecker "${Include_used_spellchecker}#define USE_${_upspell} 1\n")
+  else()
+    if(LYX_${_upspell})
+      message(FATAL_ERROR "Required ${_spell} devel package not found")
+    else()
+      message(STATUS "${_upspell} not found, building without ${_spell} support")
+    endif()
+  endif()
+endforeach()
 
 if(LYX_NLS)
        FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python)
@@ -571,6 +614,7 @@ if(LYX_NLS)
        endif()
 endif()
 
+
 find_package(ICONV REQUIRED)
 find_package(ZLIB REQUIRED)
 
@@ -591,6 +635,7 @@ else()
                set(Lyx_Boost_Libraries boost_signals boost_regex)
        endif()
        add_definitions(-DBOOST_USER_CONFIG="<config.h>")
+       add_definitions(-DBOOST_SIGNALS_NO_DEPRECATION_WARNING=1)
        include_directories(${TOP_SRC_DIR}/boost)
        add_subdirectory(boost "${TOP_BINARY_DIR}/boost")
 endif()
@@ -783,11 +828,13 @@ if(LYX_INSTALL)
        if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
                message(STATUS "Python required to create doc!")
        else()
-               add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+               if(UNIX)
+                       add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+               endif()
                add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
        endif()
-               include(../Install)
-       endif()
+       include(../Install)
+endif()
 
 add_subdirectory(src "${TOP_BINARY_DIR}/src")
 add_subdirectory(lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx")
@@ -800,8 +847,9 @@ if(LYX_ENABLE_URLTESTS)
 endif()
 
 message(STATUS)
-message(STATUS "Build options, switch LYX_* variables by -DLYX_*=ON or OFF:")
+message(STATUS "Build params, switch LYX_* options by -DLYX_*=ON or OFF, LYX_* combos by -DLYX_*=value:")
 message(STATUS)
+
 LYX_OPTION_LIST_ALL(used)
 
 
@@ -818,6 +866,17 @@ if(LYX_NLS)
        message(STATUS)
 endif()
 
+# Apple has builtin native spell checker,
+# no need to warn for missing Aspell, Hunspell or Enchant
+if(NOT Spelling_FOUND AND NOT APPLE)
+  if(LYX_REQUIRE_SPELLCHECK)
+    set(_mode "FATAL_ERROR")
+  else()
+    set(_mode "STATUS")
+  endif()
+  message(${_mode} "No spellcheck libraries found. LyX will be unable use spellchecking")
+endif()
+
 include("${TOP_CMAKE_PATH}/LyxPackaging.cmake")
 
 if(ENABLE_DIST)