forked from WPISmartmouse/Smartmouse_2018
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
88 lines (70 loc) · 3.07 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
cmake_minimum_required(VERSION 3.1)
option(PROFILE "profile real robot code" OFF)
option(BUILD_SIM "build simulations" OFF)
include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} common/Eigen)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
if (NOT ${BUILD_SIM})
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/teensy-arm.toolchain.cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
endif ()
project(smartmouse)
get_filename_component(UTIL_HEADER common/core/util.h ABSOLUTE)
file(GLOB_RECURSE CORE_COM_SRC common/commanduino/*.cpp common/core/*.cpp)
file(GLOB COM_COMMAND_SRC common/commands/*.cpp)
file(GLOB COM_SRC
common/*.cpp
common/math/*.cpp
common/commanduino/*.cpp
common/KinematicController/*.cpp
common/argparse/*.cpp)
if (NOT ${BUILD_SIM})
include(Teensy)
file(GLOB REAL_SRC
real/*.cpp
real/commands/*.cpp)
file(GLOB_RECURSE REAL_LIBS_SRC
real/lib/*.cpp)
file(GLOB REAL_LIB_DIRS real/lib/*)
include_directories(${CMAKE_SOURCE_DIR} ${REAL_LIB_DIRS} real real/commands common/Eigen)
add_definitions(-DEMBED)
import_arduino_library(Bounce2)
import_arduino_library(i2c_t3)
import_arduino_library(SPI)
add_teensy_executable(main real/main/main.cpp ${COM_SRC} ${CORE_COM_SRC} ${COM_COMMAND_SRC} ${REAL_SRC} ${REAL_LIBS_SRC})
set_target_properties(main PROPERTIES COMPILE_FLAGS "-include ${UTIL_HEADER}")
if (PROFILE)
target_compile_definitions(main PRIVATE PROFILE)
message("proflilng...")
endif ()
add_teensy_executable(profile_encoders real/main/profile_encoders.cpp ${COM_SRC} ${CORE_COM_SRC} ${REAL_SRC} ${REAL_LIBS_SRC})
set_target_properties(profile_encoders PROPERTIES COMPILE_FLAGS "-include ${UTIL_HEADER}")
add_teensy_executable(eigen_test real/main/eigen_test.cpp common/core/util.cpp)
set_target_properties(eigen_test PROPERTIES COMPILE_FLAGS "-include ${UTIL_HEADER}")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
################################
# gtest
################################
add_subdirectory(gtest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
################################
# common tests
################################
add_executable(common_tests common/test/CommonTest.cpp ${COM_SRC} ${CORE_COM_SRC})
target_link_libraries(common_tests gtest gtest_main)
set_target_properties(common_tests PROPERTIES COMPILE_FLAGS "-include ${UTIL_HEADER}")
################################
# console
################################
add_subdirectory(console)
################################
# all simulation stuff
################################
if (BUILD_SIM)
add_subdirectory(sim)
endif ()
endif ()