-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
162 lines (128 loc) · 4.79 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Root CMake file for Obvi project.
#
# # # # # # # # # # # #
# The MIT License (MIT)
#
# Copyright (c) 2019 Stephen Sorley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# # # # # # # # # # # #
cmake_minimum_required(VERSION 3.14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ProjectSetup)
project(Obvi
VERSION 0.1
LANGUAGES CXX
)
include(IDESetup)
include(InstallDeps)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set up compiler and linker options.
include(AddFlags)
# Require C++14, and disable compiler-specific extensions (if possible).
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Find third-party dependencies.
# -- Find Qt 5
set(qt_libs
Gui
)
include(AddQtPath)
find_package(Qt5 REQUIRED COMPONENTS ${qt_libs})
# Hide most of the Qt5 cache variables in cmake-gui.
foreach(lib ${qt_libs})
mark_as_advanced(FORCE "Qt5${lib}_DIR")
endforeach()
# Get list of import libs to link against (e.g., Qt5::Core).
list(TRANSFORM qt_libs PREPEND "Qt5::")
# -- Find OpenMP
find_package(OpenMP QUIET COMPONENTS CXX)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Build rules.
include(CTest) # Adds a 'test' phony target for running unit tests (must be in root to work).
add_subdirectory(util)
add_subdirectory(tests)
add_executable(obvi
main.cpp
main_window.cpp
shaders/shaders.qrc
)
set_target_properties(obvi PROPERTIES
AUTOMOC TRUE
AUTORCC TRUE
)
target_link_libraries(obvi PRIVATE
${qt_libs}
util
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Install rules.
install(TARGETS obvi
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# We're using desktop OpenGL, so we don't need to deploy ANGLE libs.
set(INSTALL_DEPS_QT_INCLUDE_ANGLE_GL FALSE)
install_deps(lib bin
${qt_libs}
)
install_deps_system(lib bin)
if(WIN32)
configure_file(LICENSE LICENSE.txt NEWLINE_STYLE WIN32)
configure_file(README.md README.txt NEWLINE_STYLE WIN32)
set(license_file "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
set(readme_file "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
else()
set(license_file "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(readme_file "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
endif()
install(FILES "${license_file}" "${readme_file}"
DESTINATION .
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Packaging rules.
set(CPACK_GENERATOR ZIP) # Always generate a ZIP archive.
if(WIN32)
# If targeting windows, also use WiX to create an MSI, if available.
if(EXISTS "$ENV{WIX}" OR EXISTS "${CPACK_WIX_ROOT}")
set(def TRUE)
else()
set(def FALSE)
endif()
option(PKG_WIX "Use WiX Toolset to create installer?" ${def})
if(PKG_WIX)
list(APPEND CPACK_GENERATOR WIX)
set(CPACK_WIX_UPGRADE_GUID A76A99AE-47AC-49D8-BB0A-D53DD991B6DB)
set(CPACK_WIX_PROPERTY_ARPHELPLINK "https://github.com/stephen-sorley/obvi/")
endif()
else()
# If targeting *nix, also create a self-extracting gzipped tar file.
list(APPEND CPACK_GENERATOR STGZ)
endif()
set(CPACK_VERBATIM_VARIABLES TRUE)
# Don't include version number in default installation directory.
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "Stephen Sorley")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Obvi (Object Visualizer)")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_RESOURCE_FILE_README "${readme_file}")
set(CPACK_RESOURCE_FILE_LICENSE "${license_file}")
include(CPack)