Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
110 lines (90 loc) · 3.39 KB
/
Copy pathCMakeLists.txt
File metadata and controls
110 lines (90 loc) · 3.39 KB
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
102
103
104
105
106
107
108
109
110
cmake_minimum_required(VERSION 3.16)
# Generate compile_commands.json.
#
# This is primarily useful for development tools such as clangd,
# clang-tidy, and other static-analysis tools.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Enable the MSVC runtime library selection abstraction introduced with
# CMake 3.15. This allows CMAKE_MSVC_RUNTIME_LIBRARY and the
# MSVC_RUNTIME_LIBRARY target property to be used consistently.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# ---------------------------------------------------------------------------
# CMake modules
# ---------------------------------------------------------------------------
# Add the project's custom CMake modules, e.g. Versioning.cmake, to the
# module search path.
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# ---------------------------------------------------------------------------
# Project
# ---------------------------------------------------------------------------
project(
QtADS
VERSION 5.1.1
LANGUAGES CXX
)
# Determine whether QtADS is being built as the top-level project.
#
# PROJECT_IS_TOP_LEVEL was introduced with CMake 3.21. For older CMake
# versions, determine the state manually.
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
set(QtADS_IS_TOP_LEVEL "${PROJECT_IS_TOP_LEVEL}")
else()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(QtADS_IS_TOP_LEVEL TRUE)
else()
set(QtADS_IS_TOP_LEVEL FALSE)
endif()
endif()
# ---------------------------------------------------------------------------
# Build options
# ---------------------------------------------------------------------------
# Build QtADS as a static library instead of a shared library.
option(BUILD_STATIC "Build the static library" OFF)
# Build the example applications and demo.
option(BUILD_EXAMPLES "Build the examples" ON)
# ---------------------------------------------------------------------------
# Platform directory
# ---------------------------------------------------------------------------
# Determine the platform-specific directory name.
#
# By default, the directory is derived from the target pointer size:
#
# 32-bit -> x86
# 64-bit -> x64
#
# ADS_PLATFORM_DIR may be specified by the caller to override this
# automatically detected value.
if(ADS_PLATFORM_DIR)
set(ads_PlatformDir "${ADS_PLATFORM_DIR}")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ads_PlatformDir "x86")
else()
set(ads_PlatformDir "x64")
endif()
# ---------------------------------------------------------------------------
# CMake policies
# ---------------------------------------------------------------------------
if(QtADS_IS_TOP_LEVEL)
# Enable folder organization by default for generators supporting it.
# CMP0143 was introduced with CMake 3.26.
if(POLICY CMP0143)
cmake_policy(SET CMP0143 NEW)
endif()
# Enable parallel compilation when building with MSVC.
if(MSVC)
add_compile_options(/MP)
endif()
endif()
# ---------------------------------------------------------------------------
# Library
# ---------------------------------------------------------------------------
add_subdirectory(src)
# ---------------------------------------------------------------------------
# Examples
# ---------------------------------------------------------------------------
if(BUILD_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(demo)
endif()