CMakeLists.txt 1.67 KB
Newer Older
1
2
3
4
5
6
7
#
# @author Tobias Weber
# @date dec-2018
# @license GPLv3, see 'LICENSE' file
#

cmake_minimum_required(VERSION 3.0)
Tobias WEBER's avatar
Tobias WEBER committed
8
project(structfact)
9

Tobias WEBER's avatar
Tobias WEBER committed
10
set(CMAKE_VERBOSE_MAKEFILE TRUE)
Tobias WEBER's avatar
Tobias WEBER committed
11
option(BUILD_LIB "build as dynamic library" FALSE)
Tobias WEBER's avatar
Tobias WEBER committed
12

13
14
15
16
17
18
19
20
21
22
# 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()

23
24
25
26
27
28
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
29
set(CMAKE_CXX_STANDARD 20)
30
31
32
add_compile_options(-std=c++20)
add_compile_options(${Boost_CXX_FLAGS})
add_compile_options(-Wall -Wextra)
33

Tobias WEBER's avatar
Tobias WEBER committed
34
35
36
37
38
include_directories(
	"${PROJECT_SOURCE_DIR}" "${Boost_INCLUDE_DIRS}/.." "../.."
	"ext" "ext/gemmi/include" "ext/gemmi/third_party"
	"../../ext/gemmi/include" "../../ext/gemmi/third_party"
)
39

Tobias WEBER's avatar
Tobias WEBER committed
40

Tobias WEBER's avatar
Tobias WEBER committed
41
42
43
44
if(BUILD_LIB)
	set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

	add_definitions(-DBUILD_LIB)
Tobias WEBER's avatar
Tobias WEBER committed
45
	add_library(takin_structfact SHARED
Tobias WEBER's avatar
Tobias WEBER committed
46
		structfact.cpp structfact.h
47
		../../tlibs2/libs/glplot.cpp ../../tlibs2/libs/glplot.h)
Tobias WEBER's avatar
Tobias WEBER committed
48
else()
Tobias WEBER's avatar
Tobias WEBER committed
49
	add_executable(takin_structfact
Tobias WEBER's avatar
Tobias WEBER committed
50
		structfact.cpp structfact.h
51
		../../tlibs2/libs/glplot.cpp ../../tlibs2/libs/glplot.h)
Tobias WEBER's avatar
Tobias WEBER committed
52
53
endif()

54
55
56
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
	target_link_options(takin_structfact
		# create an __info_plist section in the binary
Tobias WEBER's avatar
Tobias WEBER committed
57
		PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${PROJECT_SOURCE_DIR}/../../setup_mac/InfoStructFact.plist
58
59
60
	)
endif()

Tobias WEBER's avatar
Tobias WEBER committed
61
62
target_link_libraries(takin_structfact ${Boost_LIBRARIES})
qt5_use_modules(takin_structfact Core Gui Widgets OpenGL)