-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists_externals.txt
159 lines (125 loc) · 4.63 KB
/
CMakeLists_externals.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
#
# cmake file for external libraries like qcustomplot
# @author Tobias Weber <tweber@ill.fr>
# @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(taspaths_externals)
enable_language(CXX)
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/cmake"
"${PROJECT_SOURCE_DIR}/tlibs2/cmake"
)
option(USE_QT6 "use qt 6" FALSE)
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_VERBOSE_MAKEFILE TRUE)
endif()
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}.")
set(WARN_OPTS -Wall -Wextra)
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")
endif()
# -----------------------------------------------------------------------------
# compiler settings
# -----------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
add_compile_options(-std=c++20)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# system specific settings
# -----------------------------------------------------------------------------
message("Building for ${CMAKE_SYSTEM_NAME} systems.")
set(MINGW_WINSOCK)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# pass linker --subsystem option
add_compile_options(-Wl,--subsystem,windows)
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}")
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/externals")
if(QT_VER EQUAL 6)
include_directories("${Qt6Core_INCLUDE_DIRS}/..")
elseif(QT_VER EQUAL 5)
include_directories("${Qt5Core_INCLUDE_DIRS}/..")
endif()
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# packages
# -----------------------------------------------------------------------------
if(QT_VER EQUAL 6)
find_package(Qt6 REQUIRED
COMPONENTS Core Gui Svg Widgets
OpenGL OpenGLWidgets
PrintSupport)
elseif(QT_VER EQUAL 5)
find_package(Qt5 REQUIRED
COMPONENTS Core Gui Svg Widgets OpenGL
PrintSupport)
else()
message(FATAL_ERROR "Unknown Qt version selected: ${QT_VER}")
endif()
set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTOMOC TRUE)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# more compiler settings
# -----------------------------------------------------------------------------
#add_definitions(-DQCUSTOMPLOT_USE_OPENGL)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# target library settings
# -----------------------------------------------------------------------------
# make a 3rd party qcustomplot library
add_library(qcustomplot SHARED
qcustomplot/qcustomplot.cpp qcustomplot/qcustomplot.h
)
set_property(TARGET qcustomplot
PROPERTY POSITION_INDEPENDENT_CODE True)
if(QT_VER EQUAL 6)
target_link_libraries(qcustomplot
Qt6::Core Qt6::Gui Qt6::Widgets
#Qt6::OpenGL Qt6::OpenGLWidgets
Qt6::PrintSupport
)
elseif(QT_VER EQUAL 5)
target_link_libraries(qcustomplot
Qt5::Core Qt5::Gui Qt5::Widgets
#Qt5::OpenGL
Qt5::PrintSupport
)
endif()
# -----------------------------------------------------------------------------