-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
60 lines (51 loc) · 1.74 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Sticky Window Snapping Demo for Qt and WIN32
# Copyright (C) 2021-2023 Pedro López-Cabanillas <plcl@users.sourceforge.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
project(WinSnap LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_WIN32_EXECUTABLE ON)
if(NOT WIN32)
message(FATAL_ERROR "This project is for Windows!")
endif()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <windows.h>
int main()
{
EnumWindows([](HWND, LPARAM) -> BOOL { return true; }, 0);
return 0;
}" COMPILER_SUPPORTED
)
if (NOT COMPILER_SUPPORTED)
message(FATAL_ERROR "Sorry, your compiler is not supported: ${CMAKE_CXX_COMPILER}")
endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
add_executable(WinSnap
main.cpp
snapwindow.cpp
snapwindow.h
winsnap.cpp
winsnap.h
)
target_link_libraries(WinSnap PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
$<$<BOOL:${WIN32}>:dwmapi>
)