forked from rdeits/iris-distro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
189 lines (167 loc) · 6.48 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
188
189
cmake_minimum_required(VERSION 3.12)
project(iris_distro)
include(ExternalProject)
if(APPLE AND POLICY CMP0042)
# MACOSX_RPATH is enabled by default.
cmake_policy(SET CMP0042 NEW)
endif()
# Set the default build type.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build; options are Debug Release RelWithDebInfo MinSizeRel."
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
Debug Release RelWithDebInfo MinSizeRel)
endif()
# Set the default installation prefix.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING
"TODO" FORCE)
endif()
option(BUILD_TESTING "Build the testing tree." ON)
option(IRIS_WITH_EIGEN
"C++ matrix library. Only disable if you have this already." ON)
option(IRIS_WITH_MOSEK
"Convex optimization solver; free for academics. Only disable if you have this already."
ON)
option(IRIS_WITH_CDD
"Tool for converting representations of polytopes. Only disable if you have this already."
ON)
option(IRIS_WITH_PYBIND11
"Binding generator for Python based on C++11. Only disable if you have this already."
ON)
option(IRIS_WITH_MATLAB "Install the pure-MATLAB version of IRIS" OFF)
set(IRIS_DEPENDENCIES)
if(IRIS_WITH_EIGEN)
ExternalProject_Add(eigen3
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/eigen3-src"
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.3
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
-DEIGEN_TEST_NO_OPENGL=ON
-DEIGEN_TEST_NOQT=ON
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/eigen3-build")
ExternalProject_Get_Property(eigen3 SOURCE_DIR)
list(INSERT CMAKE_MODULE_PATH 0 "${SOURCE_DIR}/cmake")
list(APPEND IRIS_DEPENDENCIES eigen3)
endif()
if(IRIS_WITH_CDD)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
set(AUTOTOOLS_ENV
"${CMAKE_COMMAND}" -E env
"CC=${CMAKE_C_COMPILER}"
"CFLAGS=${CMAKE_C_FLAGS}"
"LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}")
endif()
find_program(PATCH_EXECUTABLE NAMES patch)
mark_as_advanced(PATCH_EXECUTABLE)
if(NOT PATCH_EXECUTABLE)
message(FATAL_ERROR "Could NOT find patch executable")
endif()
set(MAKE_COMMAND "${CMAKE_MAKE_PROGRAM}")
if(CMAKE_VERBOSE_MAKEFILE)
set(MAKE_COMMAND "${MAKE_COMMAND}" V=1)
endif()
ExternalProject_Add(cdd
DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/cdd-download"
URL https://github.com/cddlib/cddlib/releases/download/0.94m/cddlib-0.94m.tar.gz
URL_MD5 ec7f35912e34232b5306a643f99b6311
TLS_VERIFY 1
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/cdd-src"
CONFIGURE_COMMAND ${AUTOTOOLS_ENV} "<SOURCE_DIR>/configure" "--prefix=${CMAKE_INSTALL_PREFIX}"
BUILD_COMMAND ${AUTOTOOLS_ENV} ${MAKE_COMMAND}
BUILD_IN_SOURCE 1)
ExternalProject_Get_Property(cdd SOURCE_DIR)
list(APPEND IRIS_DEPENDENCIES cdd)
endif()
if(IRIS_WITH_MOSEK)
ExternalProject_Add(mosek
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/mosek-src"
GIT_REPOSITORY https://github.com/tardani95/mosek.git
GIT_TAG v9.3.10
CMAKE_ARGS
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
-DWITH_MATLAB=${IRIS_WITH_MATLAB}
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/mosek-build")
list(APPEND IRIS_DEPENDENCIES mosek)
endif()
if(IRIS_WITH_PYBIND11)
ExternalProject_Add(pybind11
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-src"
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG 7830e8509f2adc97ce9ee32bf99cd4b82089cc4c
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
-DPYBIND11_PYTHON_VERSION=${PYBIND11_PYTHON_VERSION}
-DPYBIND11_TEST=OFF
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-build")
list(APPEND IRIS_DEPENDENCIES pybind11)
endif()
list(INSERT CMAKE_PREFIX_PATH 0 "${CMAKE_INSTALL_PREFIX}")
set(IRIS_CMAKE_ARGS
-DBUILD_TESTING=${BUILD_TESTING}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DCMAKE_MODULE_LINKER_FLAGS=${CMAKE_MODULE_LINKER_FLAGS}"
"-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}"
"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
"-DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}"
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
-DPYBIND11_PYTHON_VERSION=${PYBIND11_PYTHON_VERSION}
-DWITH_MATLAB=${IRIS_WITH_MATLAB})
if(DEFINED EIGEN3_INCLUDE_DIR)
list(APPEND IRIS_CMAKE_ARGS "-DEIGEN3_INCLUDE_DIR=${EIGEN3_INCLUDE_DIR}")
endif()
if(DEFINED PYTHON_EXECUTABLE)
list(APPEND IRIS_CMAKE_ARGS "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
endif()
if(DEFINED PYTHON_INCLUDE_DIR)
list(APPEND IRIS_CMAKE_ARGS "-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}")
endif()
if(DEFINED PYTHON_LIBRARY)
list(APPEND IRIS_CMAKE_ARGS "-DPYTHON_LIBRARY=${PYTHON_LIBRARY}")
endif()
if(CMAKE_VERSION VERSION_LESS 3.2)
set(EXTERNAL_PROJECT_ADD_BUILD_ALWAYS)
else()
set(EXTERNAL_PROJECT_ADD_BUILD_ALWAYS BUILD_ALWAYS 1)
endif()
if(IRIS_WITH_CDD)
set(CDD_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/cdd-src/lib-src)
message(STATUS "ccd include dirs: ${CDD_INCLUDE_DIRS}")
list(APPEND IRIS_CMAKE_ARGS "-DCDD_INCLUDE_DIR=${CDD_INCLUDE_DIRS}")
endif()
ExternalProject_Add(iris
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src"
CMAKE_ARGS ${IRIS_CMAKE_ARGS}
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/iris-build"
${EXTERNAL_PROJECT_ADD_BUILD_ALWAYS}
DEPENDS ${IRIS_DEPENDENCIES})
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add_Step(iris build_always
COMMAND "${CMAKE_COMMAND}" -E echo "Force configure of IRIS"
DEPENDEES update
DEPENDERS configure
ALWAYS 1)
endif()