This repository has been archived by the owner on Mar 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
147 lines (119 loc) · 4.33 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
project (vatsinator)
cmake_minimum_required (VERSION 3.7)
# Automatically link Qt executables to qtmain target on Windows
if (POLICY CMP0020)
cmake_policy (SET CMP0020 NEW)
endif ()
# Double colon in target name means ALIAS or IMPORTED target.
if (POLICY CMP0028)
cmake_policy (SET CMP0028 NEW)
endif ()
if (UNIX AND NOT APPLE AND NOT MINGW AND NOT ANDROID)
set (LINUX 1)
endif ()
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
# set configuration types (msvc/xcode)
if (CMAKE_CONFIGURATION_TYPES)
set (CMAKE_CONFIGURATION_TYPES Debug Release)
set (CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we actually need" FORCE
)
endif()
# set CMAKE_BUILD_TYPE (makefiles)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set (CMAKE_BUILD_TYPE Debug)
else ()
set (CMAKE_BUILD_TYPE Release)
endif ()
# set CXX_FLAGS
if (CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
set (CMAKE_CXX_FLAGS_RELEASE "-DQT_NO_DEBUG -DQT_NO_DEBUG_OUTPUT")
set (CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wpedantic -Wextra")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
endif ()
elseif (MSVC)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
set (CMAKE_CXX_FLAGS_DEBUG "/W4")
set (CMAKE_CXX_FLAGS_RELEASE "/DQT_NO_DEBUG /DQT_NO_DEBUG_OUTPUT")
set(CMAKE_CXX_FLAGS_RELEASE "/MD")
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
endif ()
set (CMAKE_CXX_STANDARD "14")
# find version
if (NOT vatsinator_VERSION)
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION vatsinator_VERSION)
string (REPLACE "\n" "" vatsinator_VERSION ${vatsinator_VERSION})
include (GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
if (NOT "${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
# shorten the sha
string (SUBSTRING "${GIT_SHA1}" 0 10 GIT_HASH)
set (vatsinator_VERSION ${vatsinator_VERSION}-${GIT_HASH}-git)
endif (NOT "${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
endif (NOT vatsinator_VERSION)
set (CMAKE_SKIP_BUILD_RPATH FALSE)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set (CMAKE_INSTALL_RPATH "")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
if (APPLE AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/Applications" CACHE PATH "..." FORCE)
endif ()
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
add_subdirectory (3rdparty)
add_subdirectory (src)
find_package (Qt5Test QUIET)
if (Qt5Test_FOUND)
include_directories (${Qt5Test_INCLUDE_DIRS})
include (CTest)
enable_testing ()
add_subdirectory (tests)
endif ()
# Sum up our configuration
message (STATUS "Vatsinator-${vatsinator_VERSION} will be built with the following options:")
message (STATUS " * install prefix: ${CMAKE_INSTALL_PREFIX}")
if (NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS " * build type: ${CMAKE_BUILD_TYPE}")
else ()
message (STATUS " * configuration types: ${CMAKE_CONFIGURATION_TYPES}")
endif ()
if (ANDROID)
message (STATUS " * platform: Android ABI: ${CMAKE_ANDROID_ARCH_ABI}")
endif ()
if (BUILD_TESTING)
message (STATUS " * tests: enabled")
else ()
message (STATUS " * tests: disabled")
endif ()
# uninstall target
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target (
uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
# doxygen documentation
find_package (Doxygen QUIET)
if (DOXYGEN_FOUND)
include (QtUtils)
query_qmake(qt_doc_root QT_INSTALL_DOCS)
if (qt_doc_root)
file (GLOB qt_doc_dirs RELATIVE ${qt_doc_root} ${qt_doc_root}/*)
foreach (dir ${qt_doc_dirs})
set (tag_file ${qt_doc_root}/${dir}/${dir}.tags)
if (EXISTS ${tag_file})
list (APPEND qt_tags "${tag_file}=http://doc.qt.io/qt-5/")
endif ()
endforeach ()
string (REGEX REPLACE ";" " \\\\\n" QT_TAGS "${qt_tags}")
endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating documentation with Doxygen" VERBATIM
)
endif ()