cmake_policy(SET CMP0005 OLD)
# Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION
cmake_policy(SET CMP0006 NEW)
+ if(POLICY CMP0020)
+ cmake_policy(SET CMP0020 OLD)
+ endif()
+ if(POLICY CMP0028)
+ cmake_policy(SET CMP0028 OLD)
+ endif()
+ if(POLICY CMP0043)
+ # COMPILE_DEFINITIONS are not used yet. Enable new behavior.
+ cmake_policy(SET CMP0043 NEW)
+ endif()
endif()
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
endif()
if(NOT help AND NOT HELP)
- # 'project' triggers the searching for a compiler
- project(${LYX_PROJECT})
+ # 'project' triggers the searching for a compiler
+ project(${LYX_PROJECT})
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0")
+ message(STATUS "Gnu CXX compiler version = ${CMAKE_CXX_COMPILER_VERSION}")
+ message(STATUS "is too old, should be >= 4.0")
+ message(FATAL_ERROR "Exiting")
+ endif()
+ endif()
endif()
if(UNIX)
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(ASAN "Use address sanitizer" OFF ALL)
+LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5)
# GCC specific
LYX_OPTION(PROFILE "Build profile version" OFF GCC)
LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC)
LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
-LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC)
LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC)
LYX_OPTION(ENABLE_CXX11 "Build with options for c++11-mode" OFF GCC)
# 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)
set(LYX_GCC11_MODE)
if(UNIX OR MINGW)
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using GCC version ${GCC_VERSION}")
- if(NOT GCC_VERSION VERSION_LESS 4.4)
- set(LYX_USE_TR1 1)
- # GCC <= 4.5 does not support regex: there are linker errors
- # http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.tr1
- set(LYX_USE_TR1_REGEX 0)
+ if(GCC_VERSION VERSION_LESS 4.9)
+ # <regex> in gcc is unusable in versions less than 4.9.0
+ # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
+ set(LYX_USE_STD_REGEX 0)
endif()
if (LYX_ENABLE_CXX11)
find_package(CXX11Compiler)
set(LYX_GCC11_MODE "${CXX11_FLAG}")
endif()
else()
- if(MSVC10)
- set(LYX_USE_TR1 1)
- #set(LYX_USE_TR1_REGEX 1) #TODO should we use it in ECMAScript mode?
- endif()
+ set(LYX_USE_STD_REGEX 0)
+# if(MSVC10)
+# set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode?
+# endif()
endif()
endif()
endforeach(_c_l)
-if (LYX_LOCALVERSIONING)
- # Find the revision number and for later use
- FIND_PROGRAM(LYX_GITVERSION git)
- #message(STATUS "gitversion = ${LYX_GITVERSION}")
- if(LYX_GITVERSION)
- EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} describe --match 2.0.0 HEAD
- WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE LYX_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-.*$")
- # We will add offset of 40000 to get appropriate value to
- # previous svn.
- # We use this value than also to set the package-patch-value
- MATH(EXPR tmp_REVISION_VERSION "(${CMAKE_MATCH_1}+40000)")
- set(LYX_REVISION_VERSION "${LYX_PATCH_VERSION}-${tmp_REVISION_VERSION}git")
- set(ENABLE_DIST ON)
- endif()
- else()
- set(LYX_REVISION_VERSION git) #TODO use date
- endif()
-else()
- set(LYX_REVISION_VERSION ${LYX_PATCH_VERSION})
+FIND_PROGRAM(LYX_GITVERSION git)
+#message(STATUS "gitversion = ${LYX_GITVERSION}")
+set(LYX_REVISION_VERSION ${LYX_PATCH_VERSION})
+if(LYX_GITVERSION)
+ if (LYX_LOCALVERSIONING)
+ # Find the revision number and for later use
+ EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} describe --match 2.0.0 HEAD
+ WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE LYX_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-.*$")
+ # We will add offset of 40000 to get appropriate value to
+ # previous svn.
+ # We use this value than also to set the package-patch-value
+ MATH(EXPR tmp_REVISION_VERSION "(${CMAKE_MATCH_1}+40000)")
+ set(LYX_REVISION_VERSION "${LYX_PATCH_VERSION}-${tmp_REVISION_VERSION}git")
+ set(ENABLE_DIST ON)
+ endif()
+ endif()
endif()
-# Set the programs (lyx, tex2lyx, etc.) suffix
+# 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 "")
endif()
# lyx's source files
-set(LYX_CPP_FILES *.cpp)
-set(LYX_HPP_FILES *.h)
+set(LYX_CPP_FILES [a-zA-Z]*.cpp)
+set(LYX_HPP_FILES [a-zA-Z]*.h)
set(LYX_MOC_FILES moc_*.cpp)
include(ProjectSourceGroup)
if(NOT LYX_QUIET)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
- set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
+ 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()
- if(LYX_CONCEPT_CHECKS)
- set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCPP_CONCEPT_CHECKS")
- endif()
set(CMAKE_CXX_FLAGS "${LYX_CXX_FLAGS} -fno-strict-aliasing " CACHE TYPE STRING FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${LYX_CXX_FLAGS} -fno-strict-aliasing -O0 -g3 -D_DEBUG" CACHE TYPE STRING FORCE)
if(MINGW)
endif()
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})
+ list(APPEND CMAKE_FIND_ROOT_PATH ${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})
- endmacro()
- macro (qt_add_resources)
- qt5_add_resources(${ARGN})
- endmacro()
- macro (qt_wrap_uifiles)
- qt5_wrap_ui(${ARGN})
- endmacro()
- endif()
+ find_package(Qt5Core REQUIRED)
+ if (Qt5Core_FOUND)
+ find_package(Qt5Widgets REQUIRED)
+ if(APPLE)
+ find_package(Qt5MacExtras REQUIRED)
+ endif()
+ find_package(Qt5X11Extras QUIET)
+ find_package(Qt5WinExtras QUIET)
+ set(QTVERSION ${Qt5Core_VERSION})
+ macro (qt_use_modules)
+ qt5_use_modules(${ARGN})
+ endmacro()
+ macro (qt_add_resources)
+ qt5_add_resources(${ARGN})
+ endmacro()
+ macro (qt_wrap_uifiles)
+ qt5_wrap_ui(${ARGN})
+ endmacro()
+ message(STATUS "Found Qt-Version ${QTVERSION}")
+ endif()
elseif(LYX_USE_QT MATCHES "QT4")
+ 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()
find_package(Qt4 "4.5.0" REQUIRED)
macro (qt_use_modules)
endmacro()
endif()
endforeach()
+find_package(PythonInterp 2.7 QUIET)
+if(PYTHONINTERP_FOUND)
+ if(PYTHON_VERSION_STRING VERSION_GREATER 2.8)
+ unset(PYTHONINTERP_FOUND)
+ endif()
+endif()
+
+if (NOT PYTHONINTERP_FOUND)
+ unset(PYTHON_EXECUTABLE CACHE)
+ unset(PYTHON_VERSION_MAJOR)
+ unset(PYTHON_VERSION_MINOR)
+ unset(PYTHON_VERSION_STRING)
+ find_package(PythonInterp 3.3 REQUIRED)
+endif()
+
+set(LYX_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
+
if(LYX_NLS)
- FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python)
find_package(LyXGettext)
if(LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND)
add_subdirectory(po "${TOP_BINARY_DIR}/po")
if(LYX_EXTERNAL_BOOST)
message(STATUS "Searching for boost")
- find_package(Boost COMPONENTS signals regex) #TODO could REQUIRED be used
+ if(LYX_USE_STD_REGEX)
+ find_package(Boost COMPONENTS signals)
+ else()
+ find_package(Boost COMPONENTS signals regex)
+ endif()
if(Boost_FOUND)
message(STATUS "Boost found")
message(STATUS "Boost-libs = ${Boost_LIBRARIES}")
set(Lyx_Boost_Libraries ${Boost_LIBRARIES})
+ if (LYX_STDLIB_DEBUG)
+ # Comment from Jean-Marc Lasgouttes:
+ # In general, system boost libraries are incompatible with
+ # the use of stdlib-debug in libstdc++. See ticket #9736 for
+ # details.
+ message(WARNING "Compiling LyX with stdlib-debug and system boost libraries may lead to crashes. Consider using '-DLYX_STDLIB_DEBUG=OFF' or using '-DLYX_EXTERNAL_BOOST=OFF'")
+ endif()
else()
message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON})
endif()
else()
- if(LYX_USE_TR1_REGEX)
+ if(LYX_USE_STD_REGEX)
set(Lyx_Boost_Libraries boost_signals)
else()
set(Lyx_Boost_Libraries boost_signals boost_regex)
COMPILE_FLAGS "/Ycconfig.h /Fp\$(IntDir)/config.pch")
set(${name_}_sources ${${name_}_sources} ${TOP_BINARY_DIR}/config_pch.cpp
${TOP_BINARY_DIR}/pcheaders.h)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /DLYX_PCH_STL /DLYX_PCH_BOOST")
endmacro(lyx_add_msvc_pch)
macro(lyx_add_gcc_pch name_)
macro(lyx_add_msvc_pch name_)
endmacro()
macro(lyx_add_gcc_pch name_)
- add_definitions(-DLYX_PCH_STL -DLYX_PCH_BOOST -DLYX_PCH_QT4)
+ add_definitions(-DLYX_PCH_STL -DLYX_PCH_BOOST -DLYX_PCH_QT)
ADD_PRECOMPILED_HEADER(${name_} ${TOP_BINARY_DIR}/config_pch.cpp ${TOP_BINARY_DIR}/config.h.gch)
endmacro()
endif()
add_custom_target (lyx_run_tests COMMAND ${cmd})
set_target_properties(lyx_run_tests PROPERTIES FOLDER "tests")
+if(LYX_ASAN)
+ set(LYX_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g")
+ message(STATUS)
+ message(STATUS "Address sanitizer enabled. Usage:")
+ message(STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py")
+ message(STATUS " chmod +x ./asan_symbolize.py")
+ message(STATUS " ./bin/lyx2.2 2>&1 | ./asan_symbolize.py | c++filt ")
+ message(STATUS)
+endif()
if(LYX_INSTALL)
if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")