link against X11 using find_package
This commit is contained in:
parent
bffe7b999c
commit
4cca128180
|
@ -107,7 +107,6 @@ endif(MINGW)
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DGUI_QTWIDGETS
|
-DGUI_QTWIDGETS
|
||||||
-DMODEL_UNDO_SUPPORT
|
-DMODEL_UNDO_SUPPORT
|
||||||
-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
|
||||||
-D_GLIBCXX_USE_CXX11_ABI=0
|
-D_GLIBCXX_USE_CXX11_ABI=0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,10 +123,17 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
# executable and linking
|
# executable and linking
|
||||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_UI_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_UI_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
if(WIN32)
|
||||||
set(EXTRA_LIBS X11)
|
# WinAPI provides functions required for capslock detection
|
||||||
|
add_definitions(-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
|
||||||
|
else()
|
||||||
|
# X11 can provide functions required for capslock detection under non-Windows environments
|
||||||
|
find_package(X11)
|
||||||
|
if(X11_FOUND)
|
||||||
|
add_definitions(-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION -DX_AVAILABLE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::Widgets ${EXTRA_LIBS})
|
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::Widgets ${X11_LIBRARIES})
|
||||||
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||||
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
||||||
SOVERSION ${META_VERSION_MAJOR}
|
SOVERSION ${META_VERSION_MAJOR}
|
||||||
|
@ -136,7 +142,7 @@ set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
# enable static library when building with mingw-w64
|
# enable static library when building with mingw-w64
|
||||||
add_library(${META_PROJECT_NAME}_static STATIC ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
add_library(${META_PROJECT_NAME}_static STATIC ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||||
target_link_libraries(${META_PROJECT_NAME}_static c++utilities Qt5::Core Qt5::Widgets ${EXTRA_LIBS})
|
target_link_libraries(${META_PROJECT_NAME}_static c++utilities Qt5::Core Qt5::Widgets ${X11_LIBRARIES})
|
||||||
set_target_properties(${META_PROJECT_NAME}_static PROPERTIES
|
set_target_properties(${META_PROJECT_NAME}_static PROPERTIES
|
||||||
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
||||||
SOVERSION ${META_VERSION_MAJOR}
|
SOVERSION ${META_VERSION_MAJOR}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||||
# if defined(Q_OS_WIN32)
|
# if defined(Q_OS_WIN32)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# elif defined(Q_OS_UNIX)
|
# elif defined(X_AVAILABLE)
|
||||||
# include <X11/XKBlib.h>
|
# include <X11/XKBlib.h>
|
||||||
# undef KeyPress
|
# undef KeyPress
|
||||||
# undef KeyRelease
|
# undef KeyRelease
|
||||||
|
@ -313,7 +313,7 @@ bool EnterPasswordDialog::isCapslockPressed()
|
||||||
// platform dependent method of determining if CAPS LOCK is pressed
|
// platform dependent method of determining if CAPS LOCK is pressed
|
||||||
# if defined(Q_OS_WIN32)
|
# if defined(Q_OS_WIN32)
|
||||||
return GetKeyState(VK_CAPITAL) == 1;
|
return GetKeyState(VK_CAPITAL) == 1;
|
||||||
# elif defined(Q_OS_UNIX)
|
# elif defined(X_AVAILABLE)
|
||||||
Display *d = XOpenDisplay((char*)0);
|
Display *d = XOpenDisplay((char*)0);
|
||||||
bool caps_state = false;
|
bool caps_state = false;
|
||||||
if (d) {
|
if (d) {
|
||||||
|
|
|
@ -99,6 +99,7 @@ CONFIG(debug, debug|release) {
|
||||||
contains(DEFINES, PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) {
|
contains(DEFINES, PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) {
|
||||||
x11 {
|
x11 {
|
||||||
LIBS += -lX11
|
LIBS += -lX11
|
||||||
|
DEFINES += X_AVAILABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue