-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
101 lines (80 loc) · 3.09 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
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required(VERSION 3.10)
project(QtNetworkCrumbs)
enable_testing()
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(QncMacros)
set(CMAKE_CXX_STANDARD 17) # ------------------------------------------------------------------- setup compiler behavior
enable_language(CXX)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU|Clang)
set(QNC_COMPILE_OPTIONS
-Wall -Wextra
-Werror=conversion -Werror=missing-field-initializers -Werror=reorder
-Werror=switch -Werror=uninitialized -Werror=unused)
endif()
if (NOT CMAKE_CXX_COMPILER_LAUNCHER)
find_program(COMPILER_CACHE_EXECUTABLE sccache ccache)
if (COMPILER_CACHE_EXECUTABLE)
message(STATUS "Using compiler cache: ${COMPILER_CACHE_EXECUTABLE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_CACHE_EXECUTABLE}")
endif()
endif()
set(QNC_COMPILE_DEFINITIONS
-DQT_NO_CAST_FROM_ASCII=1
-DQT_NO_URL_CAST_FROM_STRING=1)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if (NOT QT_DIR) # -------------------------------------------------------------------------------- find the Qt framework
find_package(Qt6 QUIET COMPONENTS Core)
set(QT_DIR "${Qt6_DIR}")
endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core)
if (QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS Network Test)
find_package(Qt6 QUIET COMPONENTS Zlib)
if (QT_VERSION VERSION_GREATER_EQUAL 6.5)
list(APPEND QNC_COMPILE_DEFINITIONS
-DQT_DISABLE_DEPRECATED_UP_TO=0x060500)
else()
list(APPEND QNC_COMPILE_DEFINITIONS
-DQT_DISABLE_DEPRECATED_BEFORE=0x060500)
endif()
set(Qt_DIR ${QT6_INSTALL_PREFIX})
set(Qt_VERSION ${Qt6_VERSION})
elseif (QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 5.15 REQUIRED COMPONENTS Network Test)
find_package(Qt5 QUIET COMPONENTS Zlib)
list(APPEND QNC_COMPILE_DEFINITIONS
-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00)
set(Qt_VERSION ${Qt5_VERSION})
set(Qt_DIR ${Qt5_DIR})
else()
message(FATAL_ERROR "Could NOT find Qt")
return()
endif()
message(STATUS "Using Qt ${Qt_VERSION} from ${Qt_DIR}")
add_library(QncZlib INTERFACE) # ------------------------------------------ figure out today's name of Qt's bundled zlib
add_library(Qnc::Zlib ALIAS QncZlib)
if (TARGET Qt::ZlibPrivate AND NOT ANDROID)
# Qt::ZlibPrivate only provides headers, but no linkable symbols for Android
message(STATUS "Using Qt::ZlibPrivate")
target_link_libraries(QncZlib INTERFACE Qt::ZlibPrivate)
else()
find_package(WrapZLIB QUIET)
if (WrapZLIB_FOUND)
target_link_libraries(QncZlib INTERFACE WrapZLIB::WrapZLIB)
else()
find_package(ZLIB REQUIRED)
target_link_libraries(QncZlib INTERFACE ZLIB::ZLIB)
endif()
endif()
add_custom_target(metadata SOURCES LICENSE README.md) # ------------------------------ define custom targets and subdirs
add_subdirectory(.github)
add_subdirectory(core)
add_subdirectory(http)
add_subdirectory(mdns)
add_subdirectory(ssdp)
add_subdirectory(xml)
if (NOT IOS) # FIXME Figure out code signing on Github
add_subdirectory(tests)
endif()