-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathCMakeLists.txt
177 lines (139 loc) · 5.64 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required(VERSION 3.0)
project(BTpp)
set(CMAKE_BUILD_TYPE Release)
add_definitions(-lX11 -Wall -lglut -lGL -lgtest -std=c++11 -lrt )
# Needed for using threads
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
#########################################################
# FIND X11
#########################################################
find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR})
link_directories(${X11_LIBRARIES})
#########################################################
# FIND GTest
#########################################################
find_package(GTest)
include_directories(${GTEST_INCLUDE_DIRS})
if(NOT GTEST_FOUND)
message(WARINING " GTest not found!")
endif(NOT GTEST_FOUND)
#########################################################
# FIND GLUT
#########################################################
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
link_directories(${GLUT_LIBRARY_DIRS})
add_definitions(${GLUT_DEFINITIONS})
if(NOT GLUT_FOUND)
message(ERROR " GLUT not found!")
endif(NOT GLUT_FOUND)
#########################################################
# FIND OPENGL
#########################################################
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OPENGL_FOUND)
message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include/)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/gtest/include/)
if(APPLE)
include_directories(AFTER "/opt/X11/include")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
if(CMAKE_GENERATOR STREQUAL Xcode)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")
endif()
endif()
#########################################################
# Make relative paths absolute (needed later on)
#########################################################
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
file(GLOB_RECURSE BTHeadLibrary include/*.h)
set(BTSrcLibrary
src/action_node.cpp
src/behavior_tree.cpp
src/condition_node.cpp
src/control_node.cpp
src/draw.cpp
src/exceptions.cpp
src/leaf_node.cpp
src/tick_engine.cpp
src/parallel_node.cpp
src/fallback_node.cpp
src/sequence_node.cpp
src/fallback_node_with_memory.cpp
src/sequence_node_with_memory.cpp
src/tree_node.cpp
gtest/src/action_test_node.cpp
gtest/src/condition_test_node.cpp
)
######################################################
# SETTING BINARIES AND LIBRARY OUTPUT LOCATIONS
######################################################
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sample)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
######################################################
# COMPILING GTEST
######################################################
if(GTEST_FOUND)
#add_executable(btpp_gtest gtest/gtest_tree.cpp ${BTSrcLibrary} ${BTHeadLibrary})
#target_link_libraries(btpp_gtest ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} ${X11_LIBRARIES})
endif(GTEST_FOUND)
######################################################
# COMPILING SAMPLE EXAMPLE
######################################################
add_executable(btpp_example src/example.cpp ${BTSrcLibrary} ${BTHeadLibrary})
target_link_libraries(btpp_example ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${X11_LIBRARIES})
######################################################
# COMPILING LIBRARY
######################################################
add_library(BTppLib STATIC ${BTSrcLibrary} ${BTHeadLibrary})
target_link_libraries(BTppLib ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${X11_LIBRARIES})
######################################################
# INSTALLATION OF LIBRARY AND EXECUTABLE
######################################################
# Add all targets to the build-tree export set
export(TARGETS BTppLib
FILE "${PROJECT_BINARY_DIR}/BTppTargets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE BTpp)
install(FILES ${BTHeadLibrary} DESTINATION ${INSTALL_INCLUDE_DIR}/include/BTpp)
install(TARGETS BTppLib
# IMPORTANT: Add the library to the "export-set"
EXPORT BTppTargets
ARCHIVE DESTINATION "${INSTALL_CMAKE_DIR}/BTpp/lib"
RUNTIME DESTINATION "${PROJECT_BINARY_DIR}/bin" COMPONENT ${PROJECT_BINARY_DIR}/bin
LIBRARY DESTINATION "${PROJECT_BINARY_DIR}/lib" COMPONENT ${PROJECT_BINARY_DIR}/shlib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/include/BTpp"
COMPONENT ${INSTALL_CMAKE_DIR}"include/BTpp")
# Create the BTppConfig.cmake and BTppConfigVersion files
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
# ... for the build tree
set(CONF_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}include/BTpp")
configure_file(conf/BTppConfig.cmake.in
"${PROJECT_BINARY_DIR}/BTppConfig.cmake" @ONLY)
# ... for the install tree
#set(CONF_INCLUDE_DIRS "\${BTpp_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(conf/BTppConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BTppConfig.cmake" @ONLY)
# ... for both
configure_file(conf/BTppConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/BTppConfigVersion.cmake" @ONLY)
# Install the BTppConfig.cmake and BTppConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BTppConfig.cmake"
"${PROJECT_BINARY_DIR}/BTppConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
# Install the export set for use with the install-tree
install(EXPORT BTppTargets DESTINATION
"${INSTALL_CMAKE_DIR}" COMPONENT dev)