-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
135 lines (111 loc) · 4.59 KB
/
CMakeLists.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
cmake_minimum_required (VERSION 3.3)
project (ontology
VERSION 0.0.1
LANGUAGES CXX)
###############################################################################
# options
###############################################################################
option (ONTOLOGY_ASSERT "Enables assertion. If exceptions are enabled, this option will have no effect" OFF)
option (ONTOLOGY_EXCEPTIONS "Enables exceptions. If assertion is enabled, this will override that option" ON)
option (ONTOLOGY_INSTALL "Whether or not to install files" ON)
option (ONTOLOGY_PIC "Generate position independent code" OFF)
option (ONTOLOGY_SHARED "Whether to build a shared or static version of this library" OFF)
option (ONTOLOGY_TESTS "Whether or not to build ontology's tests" OFF)
option (ONTOLOGY_THREADS "Enables entities to be processed by systems in parallel" OFF)
if (ONTOLOGY_SHARED)
set (LIB_TYPE "SHARED")
else ()
set (LIB_TYPE "STATIC")
endif ()
# generate config file
configure_file ("ontology/include/ontology/Config.hpp.in" "ontology/include/ontology/Config.hpp")
###############################################################################
# source and header files
###############################################################################
set (ontology_CONFIG_IN
"ontology/include/ontology/Config.hpp.in")
set (ontology_HEADERS
"ontology/include/ontology/Config.hpp"
"ontology/include/ontology/Component.hpp"
"ontology/include/ontology/Entity.hpp"
"ontology/include/ontology/Entity.hxx"
"ontology/include/ontology/EntityManager.hpp"
"ontology/include/ontology/EntityManagerInterface.hpp"
"ontology/include/ontology/EntityManagerListener.hpp"
"ontology/include/ontology/Exception.hpp"
"ontology/include/ontology/ListenerDispatcher.hpp"
"ontology/include/ontology/ListenerDispatcher.hxx"
"ontology/include/ontology/System.hpp"
"ontology/include/ontology/System.hxx"
"ontology/include/ontology/SystemManager.hpp"
"ontology/include/ontology/SystemManager.hxx"
"ontology/include/ontology/Type.hpp"
"ontology/include/ontology/Type.hxx"
"ontology/include/ontology/TypeContainers.hpp"
"ontology/include/ontology/World.hpp"
"ontology/include/ontology/Ontology.hpp")
set (ontology_SOURCES
"ontology/src/Component.cpp"
"ontology/src/Entity.cpp"
"ontology/src/EntityManager.cpp"
"ontology/src/EntityManagerListener.cpp"
"ontology/src/Exception.cpp"
"ontology/src/System.cpp"
"ontology/src/SystemManager.cpp"
"ontology/src/Type.cpp"
"ontology/src/World.cpp")
###############################################################################
# create target
###############################################################################
add_library (ontology ${LIB_TYPE}
${ontology_CONFIG_IN}
${ontology_HEADERS}
${ontology_SOURCES})
###############################################################################
# compiler flags
###############################################################################
target_compile_options (ontology
PUBLIC
$<$<CXX_COMPILER_ID:GNU>:-pedantic>
$<$<CXX_COMPILER_ID:Clang>:-pedantic>)
target_compile_features (ontology
PUBLIC
cxx_std_11)
target_compile_definitions (ontology
PRIVATE
ONTOLOGY_BUILDING)
set_property (TARGET ontology
PROPERTY POSITION_INDEPENDENT_CODE ${ONTOLOGY_PIC})
target_include_directories (ontology
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ontology/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/ontology/include>
$<INSTALL_INTERFACE:include>)
###############################################################################
# handle multithreading option - boost is required if enabled
###############################################################################
if (ONTOLOGY_THREAD)
find_package (Boost REQUIRED COMPONENTS
system
thread
)
target_link_libraries (ontology
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
)
# work around gcc bug on unix where -pthread doesn't link against
# pthread and -fopenmp doesn't link against libgomp
if (UNIX)
target_link_libraries (ontology PRIVATE pthread gomp)
endif ()
endif ()
###############################################################################
# install targets
###############################################################################
if (ONTOLOGY_INSTALL)
install (TARGETS ontology DESTINATION "lib")
install (FILES ${ontology_HEADERS} DESTINATION "include/ontology")
endif ()
if (ONTOLOGY_TESTS)
add_subdirectory ("tests")
endif ()