forked from AlexandrePTJ/kemai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (76 loc) · 2.54 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
cmake_minimum_required(VERSION 3.11)
project(KemaiProject VERSION 0.6.0 LANGUAGES CXX)
# Point CMake to the custom modules
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Install spdlog
include(FetchContent)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.9.2)
FetchContent_GetProperties(spdlog)
if (NOT spdlog_POPULATED)
FetchContent_Populate(spdlog)
add_subdirectory(${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR})
endif ()
include_directories(${spdlog_SOURCE_DIR}/include)
# Common configuration
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Setup Qt
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt6 QUIET COMPONENTS Widgets Network LinguistTools)
if (NOT Qt6_FOUND)
message(NOTICE "Qt6 not found. Fallback to Qt5")
find_package(Qt5 COMPONENTS Widgets Network LinguistTools REQUIRED)
add_compile_definitions(UNICODE _UNICODE)
message(STATUS "Using Qt ${Qt5_VERSION}")
else ()
message(STATUS "Using Qt ${Qt6_VERSION}")
endif ()
# Common package configuration
set(KEMAI_GUID "88815E44-85A0-469C-9740-B4887D456BAA")
set(KEMAI_PROJECT_NAME "Kemai")
set(CPACK_PACKAGE_NAME ${KEMAI_PROJECT_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
# OS Dependant options / configurations
if (WIN32)
# Hide console
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(OS_BUNDLE WIN32)
endif ()
# Add Qt libs and installer for windows platform
include(WinDeployQt)
# Add OpenSSL binaries for installer
include(WinDeployOpenSSL)
# Package
set(DEPLOY_DIR .)
set(CPACK_GENERATOR WIX)
set(CPACK_WIX_UPGRADE_GUID ${KEMAI_GUID})
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${KEMAI_PROJECT_NAME})
set(CPACK_PACKAGE_EXECUTABLES Kemai;${KEMAI_PROJECT_NAME})
set(CPACK_CREATE_DESKTOP_LINKS Kemai;${KEMAI_PROJECT_NAME})
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
elseif (APPLE)
set(OS_BUNDLE MACOSX_BUNDLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
set(DEPLOY_DIR .)
set(CPACK_GENERATOR DragNDrop)
else ()
set(OS_BUNDLE)
set(DEPLOY_DIR bin)
endif ()
# Project code
add_subdirectory(src)
# Install targets and files
install(TARGETS Kemai DESTINATION ${DEPLOY_DIR})
install(FILES LICENSE.txt DESTINATION ${DEPLOY_DIR})
if (WIN32)
windeployqt(Kemai ${DEPLOY_DIR})
windeployopenssl(${DEPLOY_DIR})
endif ()
include(CPack)