forked from tweber-ill/ill_mirror-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
220 lines (172 loc) · 6.57 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#
# TAS-Paths main cmake file
# @author Tobias Weber <[email protected]>
# @date feb-2021
# @license GPLv3, see 'LICENSE' file
#
# -----------------------------------------------------------------------------
# TAS-Paths (part of the Takin software suite)
# Copyright (C) 2021 Tobias WEBER (Institut Laue-Langevin (ILL),
# Grenoble, France).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
#
cmake_minimum_required(VERSION 3.5)
project(gl)
enable_language(CXX)
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/cmake"
)
option(USE_QT6 "use qt 6" FALSE)
option(USE_BULLET "use bullet physics" TRUE)
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_VERBOSE_MAKEFILE TRUE)
endif()
set(GL_MAJOR_VER 3)
set(GL_MINOR_VER 3)
if(USE_QT6)
set(QT_VER 6)
else()
set(QT_VER 5)
endif()
message("Build type: ${CMAKE_BUILD_TYPE}.")
message("Compiler: " ${CMAKE_CXX_COMPILER_ID}.)
message("Selected Qt version ${QT_VER}.")
message("Selected GL version ${GL_MAJOR_VER}.${GL_MINOR_VER}.")
set(WARN_OPTS -Wall -Wextra -Weffc++)
add_compile_options(${WARN_OPTS})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# generate debug symbols
add_compile_options(-g -ggdb)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options("-DNDEBUG")
add_compile_options("-Wno-#pragma-messages")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# remove pragma messages
# see: https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html
add_compile_options(-fcompare-debug-second)
endif()
endif()
# -----------------------------------------------------------------------------
# compiler settings
# -----------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
add_compile_options(-std=c++20)
add_definitions(-D_GL_MAJ_VER=${GL_MAJOR_VER} -D_GL_MIN_VER=${GL_MINOR_VER})
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# system specific settings
# -----------------------------------------------------------------------------
message("Building for ${CMAKE_SYSTEM_NAME} systems.")
set(BOOST_SUFFIX)
set(MINGW_WINSOCK)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# pass linker --subsystem option
add_compile_options(-Wl,--subsystem,windows)
set(BOOST_SUFFIX -x64)
set(MINGW_WINSOCK "ws2_32")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
#add_compile_options(-mmacosx-version-min=10.15)
add_compile_options(-mmacosx-version-min=11.0)
endif()
include_directories("${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/externals")
if(QT_VER EQUAL 6)
include_directories(SYSTEM "${Qt6Core_INCLUDE_DIRS}/..")
elseif(QT_VER EQUAL 5)
include_directories(SYSTEM "${Qt5Core_INCLUDE_DIRS}/..")
endif()
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# packages
# -----------------------------------------------------------------------------
find_package(Threads REQUIRED)
set(Boost_NO_BOOST_CMAKE FALSE)
set(Boost_USE_MULTITHREADED TRUE)
set(Boost_FIND_QUIETLY FALSE)
find_package(Boost REQUIRED COMPONENTS filesystem${BOOST_SUFFIX} iostreams${BOOST_SUFFIX})
message("Using Boost version ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}.")
include_directories(SYSTEM "${Boost_INCLUDE_DIRS}/..")
if(USE_BULLET)
find_package(Bullet)
if(Bullet_FOUND)
message("Bullet enabled.")
add_definitions(-DUSE_BULLET)
include_directories(SYSTEM "${BULLET_INCLUDE_DIRS}")
else()
message("Bullet disabled.")
endif()
endif()
if(QT_VER EQUAL 6)
find_package(Qt6 REQUIRED
COMPONENTS Core Gui Svg Widgets
OpenGLWidgets PrintSupport)
list(APPEND QtBaseLibraries Qt6::Core Qt6::Gui Qt6::Widgets
Qt6::Svg)
list(APPEND QtAllLibraries Qt6::Core Qt6::Gui Qt6::Widgets
Qt6::Svg Qt6::OpenGLWidgets Qt6::PrintSupport)
elseif(QT_VER EQUAL 5)
find_package(Qt5 REQUIRED
COMPONENTS Core Gui Svg Widgets PrintSupport)
list(APPEND QtBaseLibraries Qt5::Core Qt5::Gui Qt5::Widgets
Qt5::Svg)
list(APPEND QtAllLibraries Qt5::Core Qt5::Gui Qt5::Widgets
Qt5::Svg Qt5::PrintSupport)
else()
message(FATAL_ERROR "Unknown Qt version selected: ${QT_VER}")
endif()
set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTOMOC TRUE)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# more compiler settings
# -----------------------------------------------------------------------------
add_compile_options(${Boost_CXX_FLAGS})
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# disable some warnings for generated source files
set_source_files_properties("${PROJECT_BINARY_DIR}/taspaths_autogen/mocs_compilation.cpp"
PROPERTIES COMPILE_FLAGS "-Wno-effc++")
endif()
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# target executable settings
# -----------------------------------------------------------------------------
add_executable(gl
src/main.cpp
src/MainWnd.cpp src/MainWnd.h
src/settings_variables.cpp src/settings_variables.h
src/renderer/GlRenderer.cpp src/renderer/GlRenderer.h
src/renderer/GlRenderer_input.cpp
src/renderer/Camera.h
src/dock/CamProperties.cpp src/dock/CamProperties.h
src/dock/SimProperties.cpp src/dock/SimProperties.h
src/dock/SelectionProperties.cpp src/dock/SelectionProperties.h
src/dialogs/About.cpp src/dialogs/About.h
src/dialogs/GeoBrowser.cpp src/dialogs/GeoBrowser.h
src/dialogs/TextureBrowser.cpp src/dialogs/TextureBrowser.h
src/dialogs/TrafoCalculator.cpp src/dialogs/TrafoCalculator.h
src/dialogs/Settings.h
src/Geometry.cpp src/Geometry.h
src/Scene.cpp src/Scene.h
src/common/Resources.cpp src/common/Resources.h
src/common/Recent.h
src/common/ExprParser.cpp src/common/ExprParser.h
)
target_link_libraries(gl
"${Boost_LIBRARIES}"
"${MINGW_WINSOCK}"
Threads::Threads
"${QtAllLibraries}"
"${BULLET_LIBRARIES}"
)