mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Cmake build: Simplify use of qt5 modules
According to this page: http://doc.qt.io/qt-5/cmake-manual.html the way to replace use of qt5_use_modules() for module "_mod" and target "_target" is to use 1.) cmake_minimum_required(VERSION 3.1.0) 2.) find_package(Qt5${_mod} CONFIG REQUIRED) 3.) target_link_libraries(${_target} Qt5::${_mod}) The last one sets all reguired libraries, compile flags and needed includes for the ${_target}
This commit is contained in:
parent
d6b21e20e2
commit
72a2f92239
@ -4,7 +4,7 @@
|
|||||||
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
|
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
|
||||||
# Copyright (c) 2008-2011 Kornel Benko, <Kornel.Benko@berlin.de>
|
# Copyright (c) 2008-2011 Kornel Benko, <Kornel.Benko@berlin.de>
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6.4)
|
cmake_minimum_required(VERSION 3.1.0)
|
||||||
|
|
||||||
set(LYX_PROJECT LyX)
|
set(LYX_PROJECT LyX)
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ if(COMMAND cmake_policy)
|
|||||||
cmake_policy(SET CMP0043 NEW)
|
cmake_policy(SET CMP0043 NEW)
|
||||||
endif()
|
endif()
|
||||||
cmake_policy(SET CMP0020 NEW)
|
cmake_policy(SET CMP0020 NEW)
|
||||||
|
cmake_policy(SET CMP0075 OLD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
@ -622,7 +623,7 @@ endif()
|
|||||||
set(min_qt5_version "5.6")
|
set(min_qt5_version "5.6")
|
||||||
if(LYX_USE_QT MATCHES "AUTO")
|
if(LYX_USE_QT MATCHES "AUTO")
|
||||||
# try qt5 first
|
# try qt5 first
|
||||||
find_package(Qt5Core QUIET)
|
find_package(Qt5Core CONFIG QUIET)
|
||||||
if(Qt5Core_FOUND)
|
if(Qt5Core_FOUND)
|
||||||
set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
|
set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
|
||||||
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
|
message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
|
||||||
@ -638,14 +639,14 @@ if(LYX_USE_QT MATCHES "AUTO")
|
|||||||
endif()
|
endif()
|
||||||
if(LYX_USE_QT MATCHES "QT5")
|
if(LYX_USE_QT MATCHES "QT5")
|
||||||
# set QPA_XCB if QT uses X11
|
# set QPA_XCB if QT uses X11
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core CONFIG REQUIRED)
|
||||||
if (Qt5Core_FOUND)
|
if (Qt5Core_FOUND)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
find_package(Qt5MacExtras REQUIRED)
|
find_package(Qt5MacExtras CONFIG REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
find_package(Qt5X11Extras QUIET)
|
find_package(Qt5X11Extras CONFIG QUIET)
|
||||||
find_package(Qt5WinExtras QUIET)
|
find_package(Qt5WinExtras CONFIG QUIET)
|
||||||
set(QTVERSION ${Qt5Core_VERSION})
|
set(QTVERSION ${Qt5Core_VERSION})
|
||||||
if (QTVERSION VERSION_LESS ${min_qt5_version})
|
if (QTVERSION VERSION_LESS ${min_qt5_version})
|
||||||
message(STATUS "QTVERSION = \"${QTVERSION}\"")
|
message(STATUS "QTVERSION = \"${QTVERSION}\"")
|
||||||
@ -658,17 +659,9 @@ if(LYX_USE_QT MATCHES "QT5")
|
|||||||
#message(FATAL_ERROR "Wrong Qt-Version")
|
#message(FATAL_ERROR "Wrong Qt-Version")
|
||||||
endif()
|
endif()
|
||||||
macro (qt_use_modules lyxtarget)
|
macro (qt_use_modules lyxtarget)
|
||||||
if (Qt5_POSITION_INDEPENDENT_CODE
|
|
||||||
AND (CMAKE_VERSION VERSION_LESS 2.8.12
|
|
||||||
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
|
||||||
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)))
|
|
||||||
set_property(TARGET ${lyxtarget} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
|
|
||||||
endif()
|
|
||||||
foreach (_tg ${ARGN})
|
foreach (_tg ${ARGN})
|
||||||
find_package(Qt5${_tg} REQUIRED)
|
find_package(Qt5${_tg} CONFIG REQUIRED)
|
||||||
include_directories(${Qt5${_tg}_INCLUDE_DIRS})
|
target_link_libraries(${lyxtarget} Qt5::${_tg})
|
||||||
set_property(TARGET ${lyxtarget} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_tg}_COMPILE_DEFINITIONS})
|
|
||||||
target_link_libraries(${lyxtarget} ${Qt5${_tg}_LIBRARIES})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
macro (qt_add_resources)
|
macro (qt_add_resources)
|
||||||
|
Loading…
Reference in New Issue
Block a user