forked from giaf/hpipm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
186 lines (169 loc) · 7.93 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
###################################################################################################
# #
# This file is part of HPIPM. #
# #
# HPIPM -- High-Performance Interior Point Method. #
# Copyright (C) 2017-2018 by Gianluca Frison. #
# Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. #
# All rights reserved. #
# #
# 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 <https://www.gnu.org/licenses/>. #
# #
# The authors designate this particular file as subject to the "Classpath" exception #
# as provided by the authors in the LICENSE file that accompained this code. #
# #
# Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de #
# #
###################################################################################################
cmake_minimum_required(VERSION 2.8.11)
project(hpipm)
# Target architecture
set(TARGET GENERIC)
# BLAS and LAPACK version (for LA=BLAS in BLASFEO)
set(REF_BLAS 0)
#set(REF_BLAS OPENBLAS)
#set(REF_BLAS NETLIB)
#set(REF_BLAS MKL)
#set(REF_BLAS BLIS)
#set(REF_BLAS ATLAS)
# BLASFEO
if(NOT TARGET blasfeo)
# BLASFEO installation directory
set(BLASFEO_PATH /opt/blasfeo)
add_library(blasfeo STATIC IMPORTED)
set_target_properties(blasfeo PROPERTIES IMPORTED_LOCATION ${BLASFEO_PATH}/lib/libblasfeo.a)
set(BLASFEO_INCLUDE_DIR ${BLASFEO_PATH}/include)
else()
# TODO: horrible hardcode; needs to go
set(BLASFEO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../blasfeo/include)
endif()
# headers installation directory
set(HPIPM_HEADERS_INSTALLATION_DIRECTORY "include" CACHE STRING "Headers local installation directory")
# enable runtine checks
set(RUNTIME_CHECKS 0)
#set(RUNTIME_CHECKS 1)
## compiler flags
#set(CMAKE_C_FLAGS "")
#
## optimization flags
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
#if(CMAKE_COMPILER_ID MATCHES "GNU" OR CMAKE_COMPILER_ID MATCHES "Clang")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
#endif()
#
if(${REF_BLAS} MATCHES 0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ")
endif(${REF_BLAS} MATCHES 0)
if(${REF_BLAS} MATCHES OPENBLAS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DREF_BLAS_OPENBLAS -I/opt/openblas/include")
endif(${REF_BLAS} MATCHES OPENBLAS)
if(${REF_BLAS} MATCHES BLIS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DREF_BLAS_BLIS -std=c99")
endif(${REF_BLAS} MATCHES BLIS)
if(${REF_BLAS} MATCHES NETLIB)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DREF_BLAS_NETLIB")
endif(${REF_BLAS} MATCHES NETLIB)
if(${REF_BLAS} MATCHES MKL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DREF_BLAS_MKL -m64 -I/opt/intel/mkl/include")
endif(${REF_BLAS} MATCHES MKL)
if(${REF_BLAS} MATCHES ATLAS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DREF_BLAS_ATLAS")
endif(${REF_BLAS} MATCHES ATLAS)
#
if(${RUNTIME_CHECKS} MATCHES 1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DRUNTIME_CHECKS")
endif(${RUNTIME_CHECKS} MATCHES 1)
# architecture-specific flags
if(${TARGET} MATCHES GENERIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_GENERIC")
endif(${TARGET} MATCHES GENERIC)
# source files
# cond
file(GLOB COND_SRC
${PROJECT_SOURCE_DIR}/cond/d_cond.c
${PROJECT_SOURCE_DIR}/cond/d_cond_aux.c
${PROJECT_SOURCE_DIR}/cond/d_part_cond.c
${PROJECT_SOURCE_DIR}/cond/s_cond.c
${PROJECT_SOURCE_DIR}/cond/s_cond_aux.c
${PROJECT_SOURCE_DIR}/cond/s_part_cond.c
)
# dense qp
file(GLOB DENSE_QP_SRC
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp.c
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp_dim.c
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp_sol.c
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp_kkt.c
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp_ipm.c
${PROJECT_SOURCE_DIR}/dense_qp/d_dense_qp_res.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp_dim.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp_sol.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp_kkt.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp_ipm.c
${PROJECT_SOURCE_DIR}/dense_qp/s_dense_qp_res.c
)
# core ipm
file(GLOB IPM_CORE_SRC
${PROJECT_SOURCE_DIR}/ipm_core/d_core_qp_ipm_aux.c
${PROJECT_SOURCE_DIR}/ipm_core/d_core_qp_ipm.c
${PROJECT_SOURCE_DIR}/ipm_core/s_core_qp_ipm_aux.c
${PROJECT_SOURCE_DIR}/ipm_core/s_core_qp_ipm.c
)
# ocp qp
file(GLOB OCP_QP_SRC
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_dim.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_sol.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_kkt.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_ipm.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_res.c
${PROJECT_SOURCE_DIR}/ocp_qp/d_ocp_qp_utils.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_dim.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_sol.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_kkt.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_ipm.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_res.c
${PROJECT_SOURCE_DIR}/ocp_qp/s_ocp_qp_utils.c
# ${PROJECT_SOURCE_DIR}/ocp_qp/m_ocp_qp.c
# ${PROJECT_SOURCE_DIR}/ocp_qp/m_ocp_qp_kkt.c
# ${PROJECT_SOURCE_DIR}/ocp_qp/m_ocp_qp_ipm_hard.c
)
# tree qp
file(GLOB TREE_OCP_QP_SRC
${PROJECT_SOURCE_DIR}/tree_ocp_qp/scenario_tree.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/d_tree_ocp_qp.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/d_tree_ocp_qp_sol.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/d_tree_ocp_qp_kkt.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/d_tree_ocp_qp_ipm.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/d_tree_ocp_qp_res.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/s_tree_ocp_qp.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/s_tree_ocp_qp_sol.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/s_tree_ocp_qp_kkt.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/s_tree_ocp_qp_ipm.c
${PROJECT_SOURCE_DIR}/tree_ocp_qp/s_tree_ocp_qp_res.c
)
set(HPIPM_SRC ${COND_SRC} ${DENSE_QP_SRC} ${IPM_CORE_SRC} ${OCP_QP_SRC} ${TREE_OCP_QP_SRC})
add_library(hpipm ${HPIPM_SRC})
target_include_directories(hpipm PRIVATE "include" "${BLASFEO_INCLUDE_DIR}")
target_link_libraries(hpipm blasfeo)
install(TARGETS hpipm EXPORT hpipmConfig
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin)
install(EXPORT hpipmConfig DESTINATION cmake)
file(GLOB_RECURSE HPIPM_HEADERS "include/*.h")
install(FILES ${HPIPM_HEADERS} DESTINATION ${HPIPM_HEADERS_INSTALLATION_DIRECTORY})
# test problems
#add_subdirectory(test_problems)