mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Amend 635a7d77
: Allow compiling with Qt6 with cmake
Thanks Scott for checking. TODO: Check compilation on Windows and Mac.
This commit is contained in:
parent
6fa973b377
commit
02a3705496
@ -219,7 +219,7 @@ else()
|
||||
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)
|
||||
LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5 QT6)
|
||||
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)
|
||||
@ -743,32 +743,58 @@ endif()
|
||||
|
||||
set(min_qt5_version "5.6")
|
||||
if(LYX_USE_QT MATCHES "AUTO")
|
||||
# try qt5 first
|
||||
find_package(Qt5Core CONFIG QUIET)
|
||||
if(Qt5Core_FOUND)
|
||||
set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
|
||||
# try qt6 first
|
||||
find_package(Qt6Core CONFIG QUIET)
|
||||
if (Qt6Core_Found)
|
||||
set(LYX_USE_QT "QT6" CACHE STRING "Valid qt version" FORCE)
|
||||
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
|
||||
if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version})
|
||||
find_package(Qt4 "4.5.0" QUIET)
|
||||
if(QT4_FOUND)
|
||||
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
|
||||
find_package(Qt5Core CONFIG QUIET)
|
||||
if(Qt5Core_FOUND)
|
||||
set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
|
||||
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
|
||||
if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version})
|
||||
find_package(Qt4 "4.5.0" QUIET)
|
||||
if(QT4_FOUND)
|
||||
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(LYX_USE_QT MATCHES "QT5")
|
||||
|
||||
set(QtCore5CompatLibrary)
|
||||
set(QtCore5CompatModule)
|
||||
if(LYX_USE_QT MATCHES "QT6|QT5")
|
||||
if (LYX_USE_QT MATCHES "QT6")
|
||||
set(QtVal "Qt6")
|
||||
macro (qt_add_resources)
|
||||
Qt6_add_resources(${ARGN})
|
||||
endmacro()
|
||||
macro (qt_wrap_uifiles)
|
||||
Qt6_wrap_ui(${ARGN})
|
||||
endmacro()
|
||||
else()
|
||||
set(QtVal "Qt5")
|
||||
macro (qt_add_resources)
|
||||
Qt5_add_resources(${ARGN})
|
||||
endmacro()
|
||||
macro (qt_wrap_uifiles)
|
||||
Qt5_wrap_ui(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
# set QPA_XCB if QT uses X11
|
||||
find_package(Qt5Core CONFIG REQUIRED)
|
||||
if (Qt5Core_FOUND)
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
find_package(${QtVal}Core CONFIG REQUIRED)
|
||||
if (${QtVal}Core_FOUND)
|
||||
find_package(${QtVal}Widgets CONFIG REQUIRED)
|
||||
if(APPLE)
|
||||
find_package(Qt5MacExtras CONFIG REQUIRED)
|
||||
find_package(${QtVal}MacExtras CONFIG REQUIRED)
|
||||
endif()
|
||||
find_package(Qt5X11Extras CONFIG QUIET)
|
||||
find_package(Qt5WinExtras CONFIG QUIET)
|
||||
set(QTVERSION ${Qt5Core_VERSION})
|
||||
find_package(${QtVal}X11Extras CONFIG QUIET)
|
||||
find_package(${QtVal}WinExtras CONFIG QUIET)
|
||||
set(QTVERSION ${${QtVal}Core_VERSION})
|
||||
if (QTVERSION VERSION_LESS ${min_qt5_version})
|
||||
message(STATUS "QTVERSION = \"${QTVERSION}\"")
|
||||
message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or")
|
||||
@ -781,19 +807,20 @@ if(LYX_USE_QT MATCHES "QT5")
|
||||
endif()
|
||||
macro (qt_use_modules lyxtarget)
|
||||
foreach (_tg ${ARGN})
|
||||
find_package(Qt5${_tg} CONFIG REQUIRED)
|
||||
target_link_libraries(${lyxtarget} Qt5::${_tg})
|
||||
find_package(${QtVal}${_tg} CONFIG REQUIRED)
|
||||
target_link_libraries(${lyxtarget} ${QtVal}::${_tg})
|
||||
endforeach()
|
||||
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}")
|
||||
if(WIN32)
|
||||
set(LYX_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES})
|
||||
set(LYX_QTMAIN_LIBRARY ${${QtVal}Core_QTMAIN_LIBRARIES})
|
||||
endif()
|
||||
if (LYX_USE_QT MATCHES "QT6")
|
||||
get_target_property(QT_MOC_EXECUTABLE Qt6::moc LOCATION)
|
||||
find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
|
||||
include_directories(${Qt6Core5Compat_INCLUDE_DIRS})
|
||||
set(QtCore5CompatLibrary Qt6::Core5Compat)
|
||||
set(QtCore5CompatModule Core5Compat)
|
||||
endif()
|
||||
endif()
|
||||
elseif(LYX_USE_QT MATCHES "QT4")
|
||||
|
@ -277,11 +277,16 @@ endif()
|
||||
|
||||
set(QPA_XCB)
|
||||
set(HAVE_QT5_X11_EXTRAS)
|
||||
if(LYX_USE_QT MATCHES "QT5")
|
||||
|
||||
set(HAVE_QT6_X11_EXTRAS)
|
||||
if (LYX_USE_QT MATCHES "QT5|QT6")
|
||||
if (LYX_USE_QT MATCHES "QT5")
|
||||
set(QtVal Qt5)
|
||||
else()
|
||||
set(QtVal Qt6)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_INCLUDES ${Qt5Core_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
#message(STATUS "Qt5Core_INCLUDE_DIRS = ${Qt5Core_INCLUDE_DIRS}")
|
||||
#message(STATUS "${QtVal}Core_INCLUDE_DIRS = ${${QtVal}Core_INCLUDE_DIRS}")
|
||||
check_include_file_cxx(QtGui/qtgui-config.h HAVE_QTGUI_CONFIG_H)
|
||||
if (HAVE_QTGUI_CONFIG_H)
|
||||
set(lyx_qt5_config "QtGui/qtgui-config.h")
|
||||
@ -312,14 +317,14 @@ if(LYX_USE_QT MATCHES "QT5")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (Qt5X11Extras_FOUND)
|
||||
get_target_property(_x11extra_prop Qt5::X11Extras IMPORTED_CONFIGURATIONS)
|
||||
get_target_property(_x11extra_link_libraries Qt5::X11Extras IMPORTED_LOCATION_${_x11extra_prop})
|
||||
if (${QtVal}X11Extras_FOUND)
|
||||
get_target_property(_x11extra_prop ${QtVal}::X11Extras IMPORTED_CONFIGURATIONS)
|
||||
get_target_property(_x11extra_link_libraries ${QtVal}::X11Extras IMPORTED_LOCATION_${_x11extra_prop})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_x11extra_link_libraries})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${Qt5X11Extras_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${Qt5X11Extras_EXECUTABLE_COMPILE_FLAGS} -fPIC -DQT_NO_VERSION_TAGGING")
|
||||
set(CMAKE_REQUIRED_INCLUDES ${${QtVal}X11Extras_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${${QtVal}X11Extras_EXECUTABLE_COMPILE_FLAGS} -fPIC -DQT_NO_VERSION_TAGGING")
|
||||
#message(STATUS "CMAKE_REQUIRED_LIBRARIES = ${_x11extra_link_libraries}")
|
||||
#message(STATUS "CMAKE_REQUIRED_INCLUDES = ${Qt5X11Extras_INCLUDE_DIRS}")
|
||||
#message(STATUS "CMAKE_REQUIRED_INCLUDES = ${${QtVal}X11Extras_INCLUDE_DIRS}")
|
||||
#message(STATUS "CMAKE_REQUIRED_FLAGS = ${CMAKE_REQUIRED_FLAGS}")
|
||||
check_cxx_source_compiles(
|
||||
"
|
||||
@ -333,13 +338,13 @@ if(LYX_USE_QT MATCHES "QT5")
|
||||
set(HAVE_QT5_X11_EXTRAS ${QT_HAS_X11_EXTRAS})
|
||||
set(LYX_QT5_X11_EXTRAS_LIBRARY ${_x11extra_link_libraries})
|
||||
endif()
|
||||
if (Qt5WinExtras_FOUND)
|
||||
get_target_property(_winextra_prop Qt5::WinExtras IMPORTED_CONFIGURATIONS)
|
||||
if (${QtVal}WinExtras_FOUND)
|
||||
get_target_property(_winextra_prop ${QtVal}::WinExtras IMPORTED_CONFIGURATIONS)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
|
||||
get_target_property(_winextra_link_libraries Qt5::WinExtras IMPORTED_LOCATION_${BUILD_TYPE})
|
||||
get_target_property(_winextra_link_libraries ${QtVal}::WinExtras IMPORTED_LOCATION_${BUILD_TYPE})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_winextra_link_libraries})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${Qt5WinExtras_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_FLAGS ${Qt5WinExtras_EXECUTABLE_COMPILE_FLAGS})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${${QtVal}WinExtras_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_FLAGS ${${QtVal}WinExtras_EXECUTABLE_COMPILE_FLAGS})
|
||||
endif()
|
||||
elseif(LYX_USE_QT MATCHES "QT4")
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${QT_QTGUI_LIBRARY})
|
||||
|
@ -154,7 +154,7 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${LYX_PROJECT}-${LYX_INSTALL_SUFFIX}")
|
||||
# Currently no need to specify versions for pythonx since they are only
|
||||
# available in newest distributions.
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python (>= 2.7) | python3 | python2")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "editors")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "universe/editors")
|
||||
|
||||
# use dpkg-shlibdeps to generate additional info for package dependency list.
|
||||
set(CPACK_DEBIAN_PACKAGE_RELEASE ${LYX_PACKAGE_RELEASE})
|
||||
|
@ -141,7 +141,8 @@ target_link_libraries(${_lyx}
|
||||
${LYX_QTMAIN_LIBRARY}
|
||||
${vld_dll})
|
||||
|
||||
qt_use_modules(${_lyx} Core Gui)
|
||||
qt_use_modules(${_lyx} Core Gui ${QtCore5CompatModule})
|
||||
target_link_libraries(${_lyx} ${QtCore5CompatLibrary})
|
||||
|
||||
if(QT_USES_X11)
|
||||
find_package(X11 REQUIRED)
|
||||
|
@ -26,8 +26,10 @@ target_link_libraries(${_lyxclient}
|
||||
${Lyx_Boost_Libraries}
|
||||
${ICONV_LIBRARY}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY})
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QtCore5CompatLibrary})
|
||||
|
||||
qt_use_modules(${_lyxclient} ${QtCore5CompatModule})
|
||||
lyx_target_link_libraries(${_lyxclient} Magic ASPELL)
|
||||
|
||||
if(APPLE)
|
||||
|
@ -14,13 +14,14 @@ macro(sources _program)
|
||||
set(${_program}_SOURCES ${_tmplist})
|
||||
add_executable(${_program} ${_tmplist})
|
||||
target_link_libraries(${_program} support
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY}
|
||||
${Lyx_Boost_Libraries}
|
||||
${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QtCore5CompatLibrary}
|
||||
${ZLIB_LIBRARY} ${ICONV_LIBRARY})
|
||||
lyx_target_link_libraries(${_program} Magic)
|
||||
if(CYGWIN)
|
||||
target_link_libraries(${_program} shlwapi)
|
||||
endif()
|
||||
qt_use_modules(${_program} Core)
|
||||
qt_use_modules(${_program} Core ${QtCore5CompatModule})
|
||||
set_property(TARGET ${_program} PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
|
||||
endmacro()
|
||||
|
||||
|
@ -17,7 +17,7 @@ include_directories(${TOP_SRC_DIR}/src/support/tests)
|
||||
add_executable(check_layout ${check_layout_SOURCES})
|
||||
|
||||
target_link_libraries(check_layout support
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY}
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QtCore5CompatLibrary}
|
||||
${ZLIB_LIBRARY} ${ICONV_LIBRARY})
|
||||
if(CYGWIN)
|
||||
target_link_libraries(check_layout shlwapi)
|
||||
@ -75,7 +75,7 @@ include_directories(${TOP_SRC_DIR}/src/tests)
|
||||
add_executable(check_ExternalTransforms ${check_ExternalTransforms_SOURCES})
|
||||
|
||||
target_link_libraries(check_ExternalTransforms support
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QtCore5CompatLibrary})
|
||||
lyx_target_link_libraries(check_ExternalTransforms Magic)
|
||||
|
||||
add_dependencies(lyx_run_tests check_ExternalTransforms)
|
||||
@ -96,7 +96,7 @@ endforeach()
|
||||
add_executable(check_Length ${check_Length_SOURCES})
|
||||
|
||||
target_link_libraries(check_Length support
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QtCore5CompatLibrary})
|
||||
lyx_target_link_libraries(check_Length Magic)
|
||||
|
||||
add_dependencies(lyx_run_tests check_Length)
|
||||
@ -118,7 +118,7 @@ endforeach()
|
||||
add_executable(check_ListingsCaption ${check_ListingsCaption_SOURCES})
|
||||
|
||||
target_link_libraries(check_ListingsCaption support
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
|
||||
${Lyx_Boost_Libraries} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY} ${QtCore5CompatLibrary})
|
||||
lyx_target_link_libraries(check_ListingsCaption Magic)
|
||||
|
||||
add_dependencies(lyx_run_tests check_ListingsCaption)
|
||||
|
@ -48,8 +48,10 @@ target_link_libraries(${_tex2lyx}
|
||||
${Lyx_Boost_Libraries}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QtCore5CompatLibrary}
|
||||
${ICONV_LIBRARY})
|
||||
|
||||
qt_use_modules(${_tex2lyx} ${QtCore5CompatModule})
|
||||
lyx_target_link_libraries(${_tex2lyx} Magic)
|
||||
|
||||
add_dependencies(${_tex2lyx} lyx_version)
|
||||
|
Loading…
Reference in New Issue
Block a user