-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
69 lines (58 loc) · 2.15 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
# SPDX-FileCopyrightText: 2021-2022 Paul Colby <git@colby.id.au>
# SPDX-License-Identifier: LGPL-3.0-or-later
cmake_minimum_required(VERSION 3.0)
message(STATUS "CMake version is ${CMAKE_VERSION}")
if (DEFINED CMAKE_BUILD_TYPE)
message(STATUS "CMake build type is ${CMAKE_BUILD_TYPE}")
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
project(QtFit VERSION 0.1.0 LANGUAGES CXX)
set(PROJECT_PRE_RELEASE pre)
#set(PROJECT_PRE_RELEASE rc1)
#unset(PROJECT_PRE_RELEASE)
if (PRE_RELEASE)
add_definitions(-DPROJECT_PRE_RELEASE="${PRE_RELEASE}")
set(PROJECT_VERSION_SUFFIX "-${PRE_RELEASE}")
endif()
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}")
file(WRITE "${PROJECT_BINARY_DIR}/version.txt" "${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}\n")
add_definitions(
-DPROJECT_NAME="${PROJECT_NAME}"
-DPROJECT_VERSION="${PROJECT_VERSION}")
# Disable automatic ASCII conversions.
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
# Enable most compiler warnings, and treat as errors.
if (MSVC)
add_compile_options(/W3 /WX)
else()
add_compile_options(-Wall -Wextra -Werror)
endif()
# Optional test coverage reporting (off by default, and gcc only for now).
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
option(ENABLE_COVERAGE "Enable test coverage reporting" OFF)
else()
set(ENABLE_COVERAGE OFF)
endif()
if (ENABLE_COVERAGE)
message(STATUS "Enabling test coverage reporting")
add_compile_options(-coverage)
add_link_options(--coverage)
endif()
# Default to Qt6 where available, otherwise Qt5.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(QT REQUIRED COMPONENTS Core Network NAMES Qt6 Qt5)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network)
message(STATUS "Found Qt ${Qt${QT_VERSION_MAJOR}_VERSION}")
message(STATUS "Found Qt Network ${Qt${QT_VERSION_MAJOR}Network_VERSION}")
include(CTest)
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(test)
# Optional codegen sub-project (requires Grantlee; off by default).
option(BUILD_CODEGEN "Build codegen sub-project" OFF)
if (BUILD_CODEGEN)
find_package(Grantlee5 REQUIRED)
message(STATUS "Found Grantlee ${Grantlee5_VERSION}")
add_subdirectory(codegen)
endif()