-
Notifications
You must be signed in to change notification settings - Fork 51
/
CMakeLists.txt
executable file
·55 lines (41 loc) · 2.15 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
cmake_minimum_required(VERSION 3.15)
project(tinympc VERSION 0.2.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(include/Eigen)
# find_package(Eigen3 REQUIRED)
# include_directories(${EIGEN3_INCLUDE_DIR})
# message("${EIGEN3_INCLUDE_DIR}")
# Create codegen directories
set( EMBEDDED_BUILD_ROOT_DIR "${CMAKE_BINARY_DIR}/codegen_src" )
set( EMBEDDED_BUILD_TINYMPC_DIR "${EMBEDDED_BUILD_ROOT_DIR}/tinympc" )
set( EMBEDDED_BUILD_INCLUDE_DIR "${EMBEDDED_BUILD_ROOT_DIR}/include" )
file( MAKE_DIRECTORY ${EMBEDDED_BUILD_ROOT_DIR} )
file( MAKE_DIRECTORY ${EMBEDDED_BUILD_TINYMPC_DIR} )
file( MAKE_DIRECTORY ${EMBEDDED_BUILD_INCLUDE_DIR} )
# Create target for copying files
add_custom_target(copy_codegen_files ALL
COMMENT "Copying source files needed for code generation" )
# Copy Eigen from include/* to codegen_src/include/
add_custom_target(copy_codegen_include_files)
add_custom_command(TARGET copy_codegen_include_files PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/include/*"
${EMBEDDED_BUILD_INCLUDE_DIR})
add_dependencies(copy_codegen_files copy_codegen_include_files)
# Set codegen install directory
set(TINY_CODEGEN_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/tinympc/codegen_files" CACHE PATH "Location of codegen install")
install(DIRECTORY
"${EMBEDDED_BUILD_ROOT_DIR}/"
DESTINATION "${TINY_CODEGEN_INSTALL_DIR}" COMPONENT codegen)
# Add tinympcstatic library
add_subdirectory(src/tinympc)
# Add example executables
add_subdirectory(examples)
# # Copy a sample makefile into the build tree
# add_custom_command(OUTPUT "${EMBEDDED_BUILD_ROOT_DIR}/Makefile"
# COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/configure/Makefile.emosqp" "${EMBEDDED_BUILD_ROOT_DIR}/Makefile"
# DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/configure/Makefile.emosqp"
# COMMENT "Copying codegen makefile" )
# add_custom_target( copy_codegen_makefile DEPENDS "${EMBEDDED_BUILD_ROOT_DIR}/Makefile" )
# add_dependencies( copy_codegen_files copy_codegen_makefile )