summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 4a1a3e24fd09b9d9e711c1edc10bdd287df464ce (plain)
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
# Ousía
# Copyright (C) 2014  Benjamin Paaßen, Andreas Stöckel
#
# 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, either version 3 of the License, or
# (at your option) any later version.
#
# 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/>.

################################################################################
# Basic Project Definitions and Dependencies                                   #
################################################################################

PROJECT(basicwriter)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)

SET(CMAKE_AUTOMOC ON)
FIND_PACKAGE(Qt5Core REQUIRED)

# Option for enabling testing. Turn on with 'cmake -Dtest=ON'.
OPTION(test "Build all tests." OFF) # Makes boolean 'test' available.

# Enable C++11 and all warnings
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0  -Wall -pedantic -std=c++11")

################################################################################
# Inclusion of gtest                                                           #
################################################################################

# Unit test handling
IF(test)
	# Compile gtest
	ADD_SUBDIRECTORY(lib/gtest-1.7.0)

	# Enable testing and declare some variables used for compiling the test cases
	ENABLE_TESTING()
	SET(GTEST_INCLUDE_DIR ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
	SET(GTEST_LIBRARIES gtest gtest_main)
ENDIF()

################################################################################
# Commands for building Ousía                                                  #
################################################################################

# Includ directories
INCLUDE_DIRECTORIES(
	src/
)

# ousia_model library (containing the code of the most important data structures
# and deduction algorithms -- this code does not depend on Qt).
ADD_LIBRARY(ousia_model
	src/model/GraphNode
	src/model/domain/Domain
	src/model/domain/Structure
	src/model/domain/ClassCategory
	src/model/domain/Class
	src/model/domain/ClassReferenceSet
	src/model/domain/ClassReference
	src/model/domain/Layer
	src/model/domain/AnnotationReference
	src/model/domain/Field
	src/model/domain/AnnotationCategory
	src/model/domain/Annotation
	src/model/types/Type
)

# ousia_xml library (containing the XML serialization/deserializing code for the
# data structures defined in the ousia_model library)
ADD_LIBRARY(ousia_xml
	src/xml/XmlReader
)

TARGET_LINK_LIBRARIES(ousia_xml
	ousia_model
)

# Link the ousia xml model against the core module of Qt5
QT5_USE_MODULES(ousia_xml Core Script)

# Definition of the main program
ADD_EXECUTABLE(ousia
	src/main
)

# Link the ousia executable against ousia_core
TARGET_LINK_LIBRARIES(ousia
	ousia_model
	ousia_xml
)

# Link the ousia executable against the Widgets module of Qt5
QT5_USE_MODULES(ousia Widgets)

# If testing is enabled, build the unit tests
IF(test)
	# Include the gtest include files and the src directory
	INCLUDE_DIRECTORIES(
		${GTEST_INCLUDE_DIR}
		src/
	)

	# Add all unit test files
	ADD_EXECUTABLE(ousia_test
		test/model/RangeSet
		test/model/GraphNode
	)

	TARGET_LINK_LIBRARIES(ousia_test
		${GTEST_LIBRARIES}
		ousia_model
		ousia_xml
	)

	# Register the unit test
	ADD_TEST(ousia_test ousia_test)
ENDIF()