forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
187 lines (155 loc) · 7.03 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
178
179
180
181
182
183
184
185
186
187
cmake_minimum_required(VERSION 2.8.6) # for UseJava.cmake
#cmake_policy(SET CMP0042 NEW)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 OLD) # so variables inside quotes are still evaluated in if() statements
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# set up pods
set(POD_NAME drake)
include(cmake/pods.cmake)
option(BUILD_SHARED_LIBS "Build Drake with shared libraries." ON)
# set up Java, use a target of 1.6
find_package(Java REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS ${CMAKE_JAVA_COMPILE_FLAGS} -source 6 -target 6)
if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreturn-type -Wuninitialized -Wunused-variable") # -Wunused-parameter")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3))
message(FATAL_ERROR "requires gcc version >= 4.3") # to support the c++0x flag below
elseif(GCC_VERSION VERSION_LESS 4.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreturn-type -Wuninitialized -Wunused-variable") # -Wunused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (APPLE) # this was a step towards getting things to work with
# clang on mac, but ultimately we didn't get there... (but I would
# be worried about sharing pointers between objects compiled against
# different c++ libs, so removing it)
# # http://stackoverflow.com/questions/13445742/apple-and-shared-ptr
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
elseif (MSVC)
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2 /openmp")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2 /openmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251")
# disable warning C4251: e.g.'RigidBody::linkname' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'RigidBody'
# followed by template linking errors. After reading, e.g.:
# https://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports
# I think we're not being sufficiently careful with our library interfaces (on other platforms as well) - Russ
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # disable sprintf security warning
endif()
# set up matlab build
include(cmake/mex.cmake)
mex_setup()
# frustratingly, this didn't seem to work, so instead I've added a -C argument to both the Makefile and the drake-admin/runUnitTests scripts
#if (NOT CTEST_CONFIGURATION_TYPE)
# set(CTEST_CONFIGURATION_TYPE ${CMAKE_BUILD_TYPE})
# message("Setting CTEST Configuration Type to ${CTEST_CONFIGURATION_TYPE}")
#endif()
enable_testing()
include(CTest)
set(drake_jar_javafiles util/Transform.java)
set(drake_jar_requires)
# set up and build lcm types
include(cmake/lcmtypes.cmake)
if (LCM_FOUND)
#add_subdirectory(lcmtypes)
lcmtypes_build()
pods_use_pkg_config_classpath(lcm-java)
list(APPEND drake_jar_javafiles
util/MyLCMTypeDatabase.java
util/MessageMonitor.java
util/CoordinateFrameData.java
util/LCMCoder.java
)
list(APPEND drake_jar_requires lcm-java lcmtypes_drake-java)
# add lcmgl
# annoyingly, libbot does not define a classpath variable. there might be a cleaner way to do this
execute_process(COMMAND pkg-config --variable=prefix bot2-lcmgl-client OUTPUT_VARIABLE LCMGL_BUILD_DIR)
if (NOT LCMGL_BUILD_DIR)
message(WARNING "\n\n----- WARNING: bot2-lcmgl not found")
else ()
string(STRIP ${LCMGL_BUILD_DIR} LCMGL_BUILD_DIR)
find_jar(LCMGL_JAR_FILE bot2-lcmgl
PATHS "${LCMGL_BUILD_DIR}/share/java/")
if (NOT LCMGL_JAR_FILE)
message(FATAL_ERROR "\n\n----- ERROR: bot2-lcmgl not found")
else()
message(STATUS "Found bot2-lcmgl")
endif()
set(CMAKE_JAVA_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}:${LCMGL_JAR_FILE})
list(APPEND drake_jar_javafiles
util/BotLCMGLClient.java
)
endif()
endif()
add_jar(drake SOURCES ${drake_jar_javafiles})
install_jar(drake share/java)
pods_install_pkg_config_file(drake-java
CLASSPATH drake
REQUIRES ${drake_jar_requires}
VERSION 0.0.1)
pods_find_pkg_config(eigen3 3.2)
if (eigen3_FOUND)
pods_use_pkg_config_includes( eigen3 )
else()
# then use the traditional approach to finding Eigen3
find_package( Eigen3 3.2 )
if (Eigen3_FOUND)
set(eigen3_FOUND 1)
include_directories( EIGEN3_INCLUDE_DIR )
else()
message(FATAL_ERROR "Could not find eigen, which is a required depedency")
endif()
endif()
include_directories(thirdParty/spruce/include)
add_subdirectory(util)
add_subdirectory(solvers)
add_subdirectory(systems)
add_subdirectory(thirdParty/GetFullPath)
add_subdirectory(thirdParty/spruce)
# setup matlab pods-compliance
include(cmake/matlab_pods.cmake)
pods_configure_matlab_paths()
get_relative_path("${CMAKE_INSTALL_PREFIX}/matlab" "${CMAKE_CURRENT_SOURCE_DIR}" relpath)
message(STATUS "Writing addpath_drake.m and rmpath_drake.m to ${CMAKE_INSTALL_PREFIX}/matlab")
file(WRITE ${CMAKE_INSTALL_PREFIX}/matlab/addpath_drake.m
"function addpath_drake()\n"
" mfiledir = fileparts(which(mfilename));\n"
" wd = cd(fullfile(mfiledir,'${relpath}'));\n"
" addpath_drake();\n"
" cd(wd);\n"
)
file(WRITE ${CMAKE_INSTALL_PREFIX}/matlab/rmpath_drake.m
"function rmpath_drake()\n"
" mfiledir = fileparts(which(mfilename));\n"
" wd = cd(fullfile(mfiledir,'${relpath}'));\n"
" rmpath_drake();\n"
" cd(wd);\n"
)
find_program(avl avl PATHS ${CMAKE_INSTALL_DIR}/bin )
find_program(xfoil xfoil PATHS ${CMAKE_INSTALL_DIR}/bin )
find_program(ffmpeg ffmpeg)
# todo: build doxygen here (and remove it from the Makefile)
# http://majewsky.wordpress.com/2010/08/14/tip-of-the-day-cmake-and-doxygen/
# write some additional information to the CMake cache
set(lcm_java_classpath "${lcm-java_CLASSPATH}" CACHE FILEPATH "${lcm-java_CLASSPATH}" FORCE)
if (APPLE)
set(DYLD_LIBRARY_PATH "$ENV{DYLD_LIBRARY_PATH}" CACHE STRING "Environment variable used to launch processes from Matlab")
set(DYLD_FRAMEWORK_PATH "$ENV{DYLD_FRAMEWORK_PATH}" CACHE STRING "Environment variable used to launch processes from Matlab")
mark_as_advanced(DYLD_LIBRARY_PATH)
mark_as_advanced(DYLD_FRAMEWORK_PATH)
else()
set(LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}" CACHE STRING "Environment variable used to launch processes from Matlab")
mark_as_advanced(LD_LIBRARY_PATH)
endif()
add_test(NAME "RigidBodyManipulatorMemoryTest"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/Acrobot"
COMMAND "matlab" #"${CMAKE_SOURCE_DIR}/cmake/matlab_clean.pl"
"-nosplash" "-nodisplay" "-wait" "-r" "addpath('${CMAKE_INSTALL_PREFIX}/matlab'); addpath_${POD_NAME}; try, r = RigidBodyManipulator('Acrobot.urdf'); megaclear; catch ex, disp(getReport(ex,'extended')); disp(''); force_close_system; exit(1); end; force_close_system; exit(0)")
set_tests_properties(RigidBodyManipulatorMemoryTest PROPERTIES TIMEOUT 300)