mirror of
https://github.com/Skycoder42/QHotkey.git
synced 2026-11-19 12:49:58 +03:00
Use QT_DEFAULT_MAJOR_VERSION
This commit is contained in:
+11
-9
@@ -8,18 +8,20 @@ option(QHOTKEY_INSTALL "Enable install rule" ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
set(QT_MAJOR 5 CACHE STRING "Qt major version to use")
|
||||
if(NOT QT_DEFAULT_MAJOR_VERSION)
|
||||
set(QT_DEFAULT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (5 or 6), defaults to 5")
|
||||
endif()
|
||||
|
||||
if(QT_MAJOR EQUAL 6)
|
||||
find_package(Qt${QT_MAJOR} 6.2.0 COMPONENTS Core Gui REQUIRED)
|
||||
if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
|
||||
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} 6.2.0 COMPONENTS Core Gui REQUIRED)
|
||||
else()
|
||||
find_package(Qt${QT_MAJOR} COMPONENTS Core Gui REQUIRED)
|
||||
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Core Gui REQUIRED)
|
||||
endif()
|
||||
|
||||
add_library(qhotkey QHotkey/qhotkey.cpp)
|
||||
add_library(QHotkey::QHotkey ALIAS qhotkey)
|
||||
target_link_libraries(qhotkey PUBLIC Qt${QT_MAJOR}::Core)
|
||||
target_link_libraries(qhotkey PRIVATE Qt${QT_MAJOR}::Gui)
|
||||
target_link_libraries(qhotkey PUBLIC Qt${QT_DEFAULT_MAJOR_VERSION}::Core)
|
||||
target_link_libraries(qhotkey PRIVATE Qt${QT_DEFAULT_MAJOR_VERSION}::Gui)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(qhotkey PRIVATE QHOTKEY_LIBRARY)
|
||||
@@ -36,14 +38,14 @@ elseif(WIN32)
|
||||
target_sources(qhotkey PRIVATE QHotkey/qhotkey_win.cpp)
|
||||
else()
|
||||
find_package(X11 REQUIRED)
|
||||
if(QT_MAJOR GREATER_EQUAL 6)
|
||||
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
|
||||
target_link_libraries(qhotkey PRIVATE ${X11_LIBRARIES})
|
||||
else()
|
||||
find_package(Qt${QT_MAJOR} COMPONENTS X11Extras REQUIRED)
|
||||
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS X11Extras REQUIRED)
|
||||
target_link_libraries(qhotkey
|
||||
PRIVATE
|
||||
${X11_LIBRARIES}
|
||||
Qt${QT_MAJOR}::X11Extras)
|
||||
Qt${QT_DEFAULT_MAJOR_VERSION}::X11Extras)
|
||||
endif()
|
||||
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
|
||||
Reference in New Issue
Block a user