CMakeLists.txt 2.66 KB
Newer Older
1
2
3
4
5
#
# @author Tobias Weber
# @date jan-2019
# @license GPLv3, see 'LICENSE' file
#
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ----------------------------------------------------------------------------
# mag-core (part of the Takin software suite)
# Copyright (C) 2018-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/>.
# ----------------------------------------------------------------------------
#
24
25
26
27
28

cmake_minimum_required(VERSION 3.0)
project(magstructfact)

set(CMAKE_VERBOSE_MAKEFILE TRUE)
Tobias WEBER's avatar
Tobias WEBER committed
29
option(BUILD_LIB "build as dynamic library" FALSE)
30

31
32
33
34
35
36
37
38
39
40
# system specific settings
message("Building for ${CMAKE_SYSTEM_NAME} systems.")

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
	# pass linker --subsystem option
	add_compile_options(-Wl,--subsystem,windows)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
	add_compile_options(-mmacosx-version-min=10.10)
endif()

41
42
43
44
45
46
find_package(Boost REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)

set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTOMOC TRUE)

Tobias WEBER's avatar
Tobias WEBER committed
47
48
set(CMAKE_CXX_STANDARD 20)
add_definitions(-std=c++20)
49
50
add_definitions(${Boost_CXX_FLAGS})

Tobias WEBER's avatar
Tobias WEBER committed
51
52
53
54
55
include_directories(
	"${PROJECT_SOURCE_DIR}" "${Boost_INCLUDE_DIRS}/.." "../.."
	"ext" "ext/gemmi/include" "ext/gemmi/third_party"
	"../../ext/gemmi/include" "../../ext/gemmi/third_party"
)
56
57
58
59
60

if(BUILD_LIB)
	set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

	add_definitions(-DBUILD_LIB)
Tobias WEBER's avatar
Tobias WEBER committed
61
	add_library(takin_magstructfact SHARED
62
		magstructfact.cpp magstructfact.h
Tobias WEBER's avatar
Tobias WEBER committed
63
64
		../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
		../../tlibs2/libs/qt/glplot.cpp ../../tlibs2/libs/qt/glplot.h)
65
else()
Tobias WEBER's avatar
Tobias WEBER committed
66
	add_executable(takin_magstructfact
67
		magstructfact.cpp magstructfact.h
Tobias WEBER's avatar
Tobias WEBER committed
68
69
		../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
		../../tlibs2/libs/qt/glplot.cpp ../../tlibs2/libs/qt/glplot.h)
70
71
endif()

72
73
74
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
	target_link_options(takin_magstructfact
		# create an __info_plist section in the binary
Tobias WEBER's avatar
Tobias WEBER committed
75
		PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${PROJECT_SOURCE_DIR}/../../setup_mac/InfoMagStructFact.plist
76
77
78
	)
endif()

Tobias WEBER's avatar
Tobias WEBER committed
79
target_link_libraries(takin_magstructfact ${Boost_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)