-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
72 lines (67 loc) · 3.18 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
cmake_minimum_required(VERSION 3.9)
project(QtModelUtilities LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
option(BUILD_SHARED_LIBS "Build the library as a dynamically linked library" ON)
option(BUILD_EXAMPLES "Build the examples" OFF)
option(NO_GUI "Disable all features requiring QtGui and QtWidgets" OFF)
option(NO_WIDGETS "Disable all features requiring QtWidgets" OFF)
option(BUILD_DOCS "Enables or disables the build of the documentation" OFF)
option(BUILD_ROLEMASKPROXY "Enables or disables the build of Role Mask Proxy Model" ON)
option(BUILD_MODELSERIALISATION "Enables or disables the build of Model Serialisation" ON)
option(BUILD_INSERTPROXY "Enables or disables the build of Insert Proxy Model" ON)
option(BUILD_ROOTINDEXPROXY "Enables or disables the build of Root Index Proxy Model" ON)
option(BUILD_GENERICMODEL "Enables or disables the build of Generic Model" ON)
option(OPTIMISE_FOR_MANY_ROLES "Set this property to ON if you plan to store more than 20 different roles in the models to optimise performance" OFF)
option(MODEL_UTILITIES_INSTALL "Generate installation target" ON)
include(CTest)
include(GetGitRevisionDescription)
git_describe(GitTagVersion --tags)
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+.*" VERSION_MATCH "${GitTagVersion}")
if(VERSION_MATCH)
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GitTagVersion}")
else()
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
endif()
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("QtModelUtilities Version ${VERSION_SHORT}")
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(modelutilities_IS64BITS OFF)
else()
set(modelutilities_IS64BITS ON)
endif()
if(modelutilities_IS64BITS)
set(modelutilities_PlatformDir "x64")
else()
set(modelutilities_PlatformDir "x86")
endif()
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(BUILD_DOCS OFF)
endif()
add_subdirectory(src)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTING)
enable_testing()
option(TEST_OUTPUT_XML "Redirects the test output to xml files in the TestResults folder" OFF)
if(TEST_OUTPUT_XML)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/../TestResults")
endif()
add_subdirectory(tests)
endif()
if(MODEL_UTILITIES_INSTALL)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION licenses)
SET(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/VSRonin/QtModelUtilities")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_FILE_NAME "QtModelUtilities-${VERSION_SHORT}-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-Qt${QT_VERSION_MAJOR}-${modelutilities_PlatformDir}")
include(CPack)
endif()