-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
111 lines (92 loc) · 3.42 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
102
103
104
105
106
107
108
109
110
111
# This file is part of KDBindings.
#
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sean Harmer <sean.harmer@kdab.com>
#
# SPDX-License-Identifier: MIT
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# This is the top-level CMakeLists.txt file for the KDBindings project.
#
# Pass the following variables to cmake to control the build:
# (See INSTALL.txt for more information)
#
# -DKDBindings_TESTS=[true|false]
# Build the test harness.
# Default=true
#
# -DKDBindings_EXAMPLES=[true|false]
# Build the examples.
# Default=true
#
# -DKDBindings_DOCS=[true|false]
# Build the API documentation. Enables the 'docs' build target.
# Default=false
#
cmake_minimum_required(VERSION 3.12) # for `project(... HOMEPAGE_URL ...)`
project(
KDBindings
DESCRIPTION "Bindings, from the comfort and speed of C++ and without Qt"
LANGUAGES CXX
VERSION 1.0.95
HOMEPAGE_URL "https://github.com/KDAB/KDBindings"
)
include(FeatureSummary)
option(${PROJECT_NAME}_TESTS "Build the tests" ON)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
option(${PROJECT_NAME}_ENABLE_WARN_UNUSED "Enable warnings for unused ConnectionHandles" ON)
option(${PROJECT_NAME}_ERROR_ON_WARNING "Enable all compiler warnings and treat them as errors" OFF)
option(${PROJECT_NAME}_QT_NO_EMIT "Qt Compatibility: Disable Qt's `emit` keyword" OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules)
# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to ${default_build_type} as none was specified.")
set(CMAKE_BUILD_TYPE
"${default_build_type}"
CACHE STRING "Choose the type of build." FORCE
)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# setup default install locations
include(InstallLocation)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(${PROJECT_NAME}_IS_ROOT_PROJECT TRUE)
message(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION} in ${CMAKE_BUILD_TYPE} mode.")
install(FILES README.md DESTINATION ${INSTALL_DOC_DIR})
install(DIRECTORY LICENSES DESTINATION ${INSTALL_DOC_DIR})
else()
#Always disable tests, examples, docs when used as a submodule
set(${PROJECT_NAME}_IS_ROOT_PROJECT FALSE)
set(${PROJECT_NAME}_TESTS FALSE)
set(${PROJECT_NAME}_EXAMPLES FALSE)
set(${PROJECT_NAME}_DOCS FALSE)
endif()
if(${PROJECT_NAME}_TESTS)
enable_testing()
endif()
add_subdirectory(src/kdbindings)
if(${PROJECT_NAME}_TESTS)
add_subdirectory(tests)
endif()
if(${PROJECT_NAME}_EXAMPLES)
add_subdirectory(examples)
endif()
if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
endif()
if(${PROJECT_NAME}_IS_ROOT_PROJECT)
# Add uninstall target (not for submodules since parent projects typically have uninstall too)
include(ECMUninstallTarget)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)