]> git.lyx.org Git - features.git/blobdiff - CMakeLists.txt
std::min/max are defined in <algorithm>
[features.git] / CMakeLists.txt
index 8ab1bea25829a72c3d5e9239fb9492a88a60ea2a..5e403abc27e8bc8efdbe4fec86d2cdcbcccf3923 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})
@@ -84,6 +97,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)
@@ -145,7 +159,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 +181,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 +205,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()
 
 
@@ -373,13 +392,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)
@@ -507,9 +527,15 @@ if(LYX_CXX_FLAGS_EXTRA)
        endforeach()
 endif()
 
-find_package(Qt5Core QUIET)
+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})
+else()
+    find_package(Qt5Core QUIET)
+endif()
 if (Qt5Core_FOUND)
        find_package(Qt5Widgets REQUIRED)
+        find_package(Qt5X11Extras)
        set(QTVERSION ${Qt5Core_VERSION})
        macro (qt_use_modules)
                qt5_use_modules(${ARGN})
@@ -539,20 +565,25 @@ endif()
 
 include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
 
-if(LYX_ASPELL)
-       find_package(ASPELL REQUIRED)
-       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)
@@ -570,6 +601,7 @@ if(LYX_NLS)
        endif()
 endif()
 
+
 find_package(ICONV REQUIRED)
 find_package(ZLIB REQUIRED)
 
@@ -783,7 +815,9 @@ 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)
@@ -818,6 +852,15 @@ if(LYX_NLS)
        message(STATUS)
 endif()
 
+if(NOT Spelling_FOUND)
+  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)