]> git.lyx.org Git - features.git/commitdiff
Cmake build: Added user choise of QT version to use.
authorKornel Benko <kornel@lyx.org>
Thu, 26 Jun 2014 07:39:47 +0000 (09:39 +0200)
committerKornel Benko <kornel@lyx.org>
Thu, 26 Jun 2014 07:39:47 +0000 (09:39 +0200)
To use Qt5 one has to configure with:
        cmake .... -DLYX_USE_QT=QT5
Default is QT4, so on systems without Qt4 the QT5 choice is mandatory.

CMakeLists.txt
development/cmake/modules/LyXMacros.cmake

index 023c3e14b71e9d51a766724c9f924e6fffc395b7..f2b700c4dc0e0a78e7f62c2eb5e8f21675ec726c 100644 (file)
@@ -74,6 +74,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()
 
@@ -119,7 +124,7 @@ 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)
-
+LYX_COMBO(USE_QT                 "Use Qt version as frontend" QT4 QT5)
 
 if(help OR HELP)
        message(STATUS)
@@ -477,9 +482,11 @@ if(LYX_CXX_FLAGS_EXTRA)
        endforeach()
 endif()
 
-find_package(Qt5Core QUIET)
-if (Qt5Core_FOUND)
+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})
@@ -490,7 +497,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()
@@ -500,6 +508,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)
@@ -517,12 +527,12 @@ endif()
 if(LYX_ENCHANT)
        find_package(Enchant REQUIRED)
        include_directories(${ENCHANT_INCLUDE_DIR})
-endif()
+    endif()
 
 if(LYX_HUNSPELL)
        find_package(Hunspell REQUIRED)
        include_directories(${HUNSPELL_INCLUDE_DIR})
-endif()
+  endif()
 
 if(LYX_NLS)
        FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python)
@@ -760,12 +770,12 @@ 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")
+                       add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
                add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
        endif()
        if(NOT(LYX_BUNDLE AND APPLE))
-               include(../Install)
-       endif()
+       include(../Install)
+endif()
 endif()
 
 add_subdirectory(sourcedoc "${TOP_BINARY_DIR}/sourcedoc")
@@ -775,7 +785,7 @@ 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)
 
index 48e29d8031f5ffc195276f37b3d05117a6d98f6d..4ce1566a32e6bbe9d26f05b05e455a0d5fa4d6aa 100644 (file)
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
+#  Copyright (c) 2006-2011 Peter Kmmel, <syntheticpp@gmx.net>
 #
 #  Redistribution and use in source and binary forms, with or without
 #  modification, are permitted provided that the following conditions
@@ -173,7 +173,7 @@ macro(lyx_const_touched_files _allinone_name _list)
        else()
                lyx_add_info_files(MergedFiles ${${_list}})
        endif()
-       
+
        set(${_file_list} ${_file_const} ${_file_touched} ${lyx_${groupname}_info_files})
 
        foreach (_current_FILE ${${_list}})
@@ -232,6 +232,21 @@ macro(LYX_OPTION _name _description _default _sys)
        set(LYX_${_name}_show_message ${_msg})
 endmacro()
 
+macro(LYX_COMBO _name _description _default)
+  set(_lyx_name "LYX_${_name}")
+  set(${_lyx_name} ${_default} CACHE STRING "${_description}")
+  set(_combo_list ${_default} ${ARGN})
+  set_property(CACHE ${_lyx_name} PROPERTY STRINGS ${_combo_list})
+  list(APPEND LYX_OPTIONS ${_lyx_name})
+  set(${_lyx_name}_show_message ON)
+  string(REGEX REPLACE ";" " " _use_list "${_combo_list}")
+  set(${_lyx_name}_description "${_description} (${_use_list})")
+  # Now check the value
+  list(FIND _combo_list ${${_lyx_name}} _idx)
+  if (_idx LESS 0)
+    message(FATAL_ERROR "${_lyx_name} set to \"${${_lyx_name}}\", but has to be only one of (${_use_list})")
+  endif()
+endmacro()
 
 macro(LYX_OPTION_LIST_ALL)
        if(UNIX)
@@ -249,7 +264,10 @@ macro(LYX_OPTION_LIST_ALL)
        foreach(_option ${LYX_OPTIONS})
                if(${_option}_show_message OR ${ARGV0} STREQUAL "help")
                        string(SUBSTRING "${_option}                            " 0 25 _var)
-                       if(${_option})
+                        get_property(_prop CACHE ${_option} PROPERTY STRINGS)
+                        if(_prop)
+                          set(_isset ${${_option}})
+                       elseif(${_option})
                                set(_isset ON)
                        else()
                                set(_isset OFF)