]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Do not for copies in range-based for loops.
[lyx.git] / CMakeLists.txt
index 76c4d5756be1936f9c02118eac93ef900d208d9f..2a123e7c34974938be7eca1d424f1db0e54dc681 100644 (file)
@@ -139,6 +139,11 @@ LYX_OPTION(BUNDLE           "Build bundle  (experimental) " OFF ALL)
 LYX_OPTION(ENABLE_URLTESTS  "Enable for URL tests" OFF ALL)
 LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL)
 LYX_OPTION(ENABLE_KEYTESTS  "Enable for keytests" OFF ALL)
+if (NOT CMAKE_VERSION VERSION_LESS "3.17")
+LYX_OPTION(ENABLE_VALGRIND_TESTS  "Enable for tests involving valgrind" OFF ALL)
+else()
+unset(LYX_ENABLE_VALGRIND_TESTS CACHE)
+endif()
 LYX_OPTION(ASAN             "Use address sanitizer" OFF ALL)
 #LYX_COMBO(USE_FILEDIALOG    "Use native or QT file dialog" QT NATIVE)
 LYX_COMBO(USE_QT            "Use Qt version as frontend" AUTO QT4 QT5)
@@ -146,6 +151,7 @@ LYX_COMBO(USE_IPO           "Interprocedural optimization" OFF AUTO ON)
 #LYX_OPTION(3RDPARTY_BUILD   "Build 3rdparty libs" OFF ALL)
 LYX_OPTION(DISABLE_CALLSTACK_PRINTING "do not print a callstack when crashing" OFF ALL)
 LYX_OPTION(EXTERNAL_Z       "OFF := Build 3rdparty lib zlib" ON ALL)
+LYX_OPTION(EXTERNAL_DTL     "OFF := Build 3rdparty commands dt2dv and dv2dt" ON ALL)
 LYX_OPTION(EXTERNAL_ICONV   "OFF := Build 3rdparty lib iconvlib" ON ALL)
 LYX_OPTION(EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ON ALL)
 LYX_COMBO(EXTERNAL_MYTHES   "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON)
@@ -179,6 +185,12 @@ if(help OR HELP)
 endif()
 
 # Check option dependencies
+if (LYX_ENABLE_VALGRIND_TESTS)
+       find_program(VALGRIND_EXECUTABLE "valgrind")
+       if (NOT VALGRIND_EXECUTABLE)
+               message(FATAL_ERROR "Cannot use valgrind tests, executable valgrind is missing. Please disable LYX_ENABLE_VALGRIND_TESTS")
+       endif()
+endif()
 
 if(LYX_DMG)
        set(LYX_BUNDLE ON)
@@ -275,7 +287,7 @@ find_package(CXX11Compiler)
 if(NOT CXX11COMPILER_FOUND)
        message(FATAL_ERROR "A C++11 compatible compiler is required.")
 endif()
-set(LYX_GCC11_MODE)
+unset(LYX_GCC11_MODE)
 if(UNIX OR MINGW)
        if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
          # ignore the GCC_VERSION for clang
@@ -317,8 +329,6 @@ else()
 endif()
 
 
-set(VERSION_INFO "CMake Build")
-
 # Try to get some informations from configure.ac
 
 include(LyXPaths)
@@ -384,6 +394,7 @@ foreach(_c_l ${_config_lines} )
                        if (NOT LYX_RELEASE_PATCH)
                                set(LYX_RELEASE_PATCH 0)
                        endif()
+                       set(LYX_VERSION "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
                        if ("${LYX_SUFFIX_VALUE}" MATCHES "")
                          set(LYX_INSTALL_SUFFIX "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
                        else()
@@ -395,6 +406,7 @@ foreach(_c_l ${_config_lines} )
                set(LYX_DATE "${CMAKE_MATCH_1}")
        endif()
 endforeach(_c_l)
+unset(_config_lines)
 
 FIND_PROGRAM(LYX_GITVERSION git)
 #message(STATUS "gitversion = ${LYX_GITVERSION}")
@@ -564,22 +576,27 @@ if(NOT LYX_DATA_SUBDIR)
        endif()
 endif()
 
-set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}")
+set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}/${LYX_DATA_SUBDIR}")
 get_locale_destination(LYX_LOCALEDIR)
 set(LYX_ABS_INSTALLED_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LYX_LOCALEDIR}")
 set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
 
 if(LYX_BUNDLE AND APPLE)
-       set(LYX_MAN_DIR "${LYX_DATA_SUBDIR}" CACHE STRING "Install location for man pages.")
+       set(LYX_MAN_DIR_tmp "${LYX_DATA_SUBDIR}")
 else()
        if(WIN32)
-               set(LYX_MAN_DIR "${CMAKE_BINARY_DIR}/usr/local/man" CACHE STRING "Install location for man pages.")
+               set(LYX_MAN_DIR_tmp "${CMAKE_BINARY_DIR}/usr/local/man/")
        elseif(UNIX)
-               set(LYX_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE STRING "Install location for man pages.")
+               set(LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/share/man/")
        else()
-               set(LYX_MAN_DIR "${CMAKE_INSTALL_PREFIX}/man" CACHE STRING "Install location for man pages.")
+               set(LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/man/")
        endif()
 endif()
+if (NOT LYX_MAN_DIR_tmp EQUAL "${LYX_MAN_DIR}")
+       unset(LYX_MAN_DIR CACHE)
+       set(LYX_MAN_DIR "${LYX_MAN_DIR_tmp}" CACHE STRING "Install location for man pages.")
+endif()
+unset(LYX_MAN_DIR_tmp)
 mark_as_advanced(LYX_MAN_DIR)
 
 # The Win installer cannot be built by CMake because one needs to install plugins for NSIS
@@ -870,6 +887,10 @@ else()
   add_subdirectory(3rdparty/zlib)
 endif()
 
+if(NOT LYX_EXTERNAL_DTL)
+  add_subdirectory(3rdparty/dtl)
+endif()
+
 if(LYX_USE_STD_REGEX)
   # Set only include path.
   # Use internal boost, which is known to exist
@@ -928,7 +949,7 @@ endif()
 
 message(STATUS "")
 foreach(_v PACKAGE PACKAGE_VERSION
-       PROGRAM_SUFFIX LYX_DIR_VER LYX_USERDIR_VER
+       PROGRAM_SUFFIX LYX_VERSION LYX_DIR_VER LYX_USERDIR_VER
        LYX_ABS_TOP_SRCDIR
        LYX_ABS_INSTALLED_DATADIR LYX_ABS_INSTALLED_LOCALEDIR LYX_INSTALL_SUFFIX)
        if(NOT DEFINED ${_v})
@@ -1070,7 +1091,43 @@ endif()
 include(${LYX_CMAKE_DIR}/ConfigureChecks.cmake)
 configure_file(${LYX_CMAKE_DIR}/configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h)
 
+unset(opts)
+foreach(_option ${LYX_OPTIONS})
+  if(${_option}_show_message)
+    string(SUBSTRING "${_option}                            " 0 31 _var)
+    get_property(_prop CACHE ${_option} PROPERTY STRINGS)
+    list(FIND LYX_OPTION_STRINGS ${_option} _index)
+    if (${_index} GREATER -1)
+      set(_isset ${${_option}})
+    elseif(${_option})
+      set(_isset ON)
+    else()
+      set(_isset OFF)
+    endif()
+    string(SUBSTRING "${_isset}           " 0 10 _val)
+    set(opts "${opts} ${_option}(${${_option}})")
+  endif()
+endforeach()
+set(tmp_vi "CMake Build")
+list(APPEND tmp_vi "  Host name:               ${CMAKE_HOST_SYSTEM_NAME}")
+list(APPEND tmp_vi "  Host processor:          ${CMAKE_HOST_SYSTEM_PROCESSOR}")
+list(APPEND tmp_vi "  Build flags:             ${opts}")
+list(APPEND tmp_vi "  C++ Compiler:            ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION})")
+list(APPEND tmp_vi "  C++ Compiler flags:      ${CMAKE_CXX_FLAGS}")
+if (LYX_DEBUG)
+list(APPEND tmp_vi "  C++ Compiler user flags: ${CMAKE_CXX_FLAGS_DEBUG}")
+else()
+list(APPEND tmp_vi "  C++ Compiler user flags: ${CMAKE_CXX_FLAGS_RELEASE}")
+endif()
+list(APPEND tmp_vi "  Qt version:              ${QTVERSION}")
+list(APPEND tmp_vi "  LyX binary dir:          ${CMAKE_INSTALL_PREFIX}/${LYX_UTILITIES_INSTALL_PATH}")
+get_data_destination(dest_data)
+list(APPEND tmp_vi "  LyX files dir:           ${CMAKE_INSTALL_PREFIX}/${dest_data}")
+string(REPLACE ";" "\\n" VERSION_INFO "${tmp_vi}")
+
 configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
+unset(opts)
+unset(tmp_vi)
 
 if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
        MATH(EXPR QT4_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}")