-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
99 lines (79 loc) · 3.09 KB
/
CMakeLists.txt
File metadata and controls
99 lines (79 loc) · 3.09 KB
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
# This file is part of mpc.
# mpc is free software: you can redistribute it and/or
# modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# mpc 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with mpc. If not, see
# <http://www.gnu.org/licenses/>.
# Version minimum
cmake_minimum_required(VERSION 2.8)
include(cmake/base.cmake)
include(cmake/eigen.cmake)
include(cmake/boost.cmake)
set(PROJECT_NAME mpc)
set(PROJECT_DESCRIPTION "This a generic model preview control")
set(PROJECT_URL "https://github.com/vsamy/preview_controller")
#SET(CXX_DISABLE_WERROR True)
set(DOXYGEN_USE_MATHJAX "YES")
project(${PROJECT_NAME} CXX)
# Check compiler version
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0")
message(FATAL_ERROR "Insufficient gcc version (version superior to 5.0 is required)")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "3.4")
message(FATAL_ERROR "Insufficient clang version (version superior to 3.4 is required)")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "14.0")
message(FATAL_ERROR "Insufficient msvc version (version superior to 14.0 is required)")
endif()
endif()
string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_case)
if(lower_case STREQUAL "debug")
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG")
endif()
if(NOT DEFINED PYTHON_BINDINGS)
set(PYTHON_BINDINGS ON)
endif()
if(NOT DEFINED BUILD_CXX_TESTS)
set(BUILD_CXX_TESTS OFF)
endif()
SETUP_PROJECT()
set(BOOST_REQUIRED 1.48)
set(BOOST_COMPONENTS system timer)
set(Eigen_REQUIRED "eigen3 >= 3.2.0")
SEARCH_FOR_EIGEN()
if(${_Eigen_VERSION} VERSION_LESS 3.3)
add_definitions(-DEIGEN_3_2_FOUND) # Will add Eigen::Index as in 3.3
endif()
ADD_REQUIRED_DEPENDENCY("eigen-quadprog")
ADD_OPTIONAL_DEPENDENCY("eigen-qld")
ADD_OPTIONAL_DEPENDENCY("eigen-lssol")
ADD_OPTIONAL_DEPENDENCY("eigen-gurobi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++14 -pedantic")
# Header for define and include found c++ QP solver
configure_file(cmake/solverConfig.cmake.in include/${HEADER_DIR}/solverConfig.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR}/solverConfig.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_DIR})
# Include the automatically generated configuration files.
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR})
add_subdirectory(src)
if(${BUILD_CXX_TESTS})
add_subdirectory(tests)
endif()
if(${PYTHON_BINDINGS})
add_subdirectory(binding/python)
endif()
# Add dependency towards the library in the pkg-config file.
pkg_config_append_libs(${PROJECT_NAME})
SETUP_PROJECT_FINALIZE()