CMakeLists.txt 2.29 KB
Newer Older
1
2
3
4
#
# @author Tobias Weber
# @date Oct-2018
# @license GPLv3, see 'LICENSE' file
Tobias WEBER's avatar
Tobias WEBER committed
5
# @desc The present version was forked on 8-Nov-2018 from my privately developed "magtools" project (https://github.com/t-weber/magtools).
6
7
8
#

cmake_minimum_required(VERSION 3.0)
Tobias WEBER's avatar
Tobias WEBER committed
9
project(pol)
10

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

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

# -----------------------------------------------------------------------------
# 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()
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# packages
30
31
32
33
34
find_package(Boost REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)

set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTOMOC TRUE)
35
36
# -----------------------------------------------------------------------------

37

38
39
# -----------------------------------------------------------------------------
# compiler settings
Tobias WEBER's avatar
Tobias WEBER committed
40
set(CMAKE_CXX_STANDARD 20)
Tobias WEBER's avatar
Tobias WEBER committed
41
42
43
add_compile_options(-std=c++20)
add_compile_options(${Boost_CXX_FLAGS})
add_compile_options(-Wall -Wextra)
Tobias WEBER's avatar
Tobias WEBER committed
44

45
include_directories("${PROJECT_SOURCE_DIR}" "${Boost_INCLUDE_DIRS}/.." "../..")
46
47
# -----------------------------------------------------------------------------

48

49
# -----------------------------------------------------------------------------
50
# linker settings
Tobias WEBER's avatar
Tobias WEBER committed
51
52
53
54
if(BUILD_LIB)
	set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

	add_definitions(-DBUILD_LIB)
Tobias WEBER's avatar
Tobias WEBER committed
55
	add_library(takin_pol SHARED pol.cpp
56
		../../tlibs2/libs/glplot.cpp ../../tlibs2/libs/glplot.h)
Tobias WEBER's avatar
Tobias WEBER committed
57
else()
Tobias WEBER's avatar
Tobias WEBER committed
58
	add_executable(takin_pol pol.cpp
59
		../../tlibs2/libs/glplot.cpp ../../tlibs2/libs/glplot.h)
Tobias WEBER's avatar
Tobias WEBER committed
60
61
endif()

62
63
64
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
	target_link_options(takin_pol
		# create an __info_plist section in the binary
Tobias WEBER's avatar
Tobias WEBER committed
65
		PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${PROJECT_SOURCE_DIR}/../../setup_mac/InfoPol.plist
66
67
68
	)
endif()

Tobias WEBER's avatar
Tobias WEBER committed
69
70
target_link_libraries(takin_pol ${Boost_LIBRARIES})
qt5_use_modules(takin_pol Core Gui Widgets OpenGL)
71
# -----------------------------------------------------------------------------