-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
101 lines (81 loc) · 2.38 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
cmake_minimum_required(VERSION 2.8.3)
project(eigen_linear_mpc)
FIND_PACKAGE (PythonLibs 2.7)
find_package(OsqpEigen REQUIRED)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-Wall -Wextra)
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, recommanded options are: Debug or Release" FORCE)
endif()
include(CMakePackageConfigHelpers)
include_directories(include
${PYTHON_INCLUDE_DIRS}
)
set(LIBRARY_TARGET_NAME LinMpcEigen)
set(LIBRARY_VERSION 0.0)
set(LIBRARY_HEADERS
include/LinMpcEigen.hpp
include/QpProblem.hpp
include/OsqpEigenOptimization.hpp
)
add_library(${LIBRARY_TARGET_NAME}
src/LinMpcEigen.cpp
src/OsqpEigenOptimization.cpp
)
target_link_libraries(${LIBRARY_TARGET_NAME}
PUBLIC OsqpEigen::OsqpEigen
)
install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT LinMpcEigenTargets
COMPONENT runtime
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include/${LIBRARY_TARGET_NAME})
install(FILES ${LIBRARY_HEADERS}
DESTINATION "include/${LIBRARY_TARGET_NAME}")
install(EXPORT LinMpcEigenTargets
FILE LinMpcEigenTargets.cmake
NAMESPACE LinMpcEigen::
DESTINATION lib/cmake/${LIBRARY_TARGET_NAME})
write_basic_package_version_file(
"LinMpcEigenConfigVersion.cmake"
VERSION ${LIBRARY_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES "cmake/LinMpcEigenConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LinMpcEigenConfigVersion.cmake"
DESTINATION lib/cmake/${LIBRARY_TARGET_NAME})
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
)
#-----------------tests-----------------
add_executable(test_example
src/test_example.cpp
src/LinMpcEigen.cpp
src/OsqpEigenOptimization.cpp
)
target_link_libraries(test_example
PRIVATE ${LIBRARY_TARGET_NAME}
${PYTHON_LIBRARIES}
)
add_executable(test_example_2
src/test_example_2.cpp
src/LinMpcEigen.cpp
src/OsqpEigenOptimization.cpp
)
target_link_libraries(test_example_2
PRIVATE ${LIBRARY_TARGET_NAME}
${PYTHON_LIBRARIES}
)
add_executable(test_example_3
src/test_example_3.cpp
src/LinMpcEigen.cpp
src/OsqpEigenOptimization.cpp
)
target_link_libraries(test_example_3
PRIVATE ${LIBRARY_TARGET_NAME}
${PYTHON_LIBRARIES}
)