forked from inertialsense/inertial-sense-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (81 loc) · 2.42 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.0)
project(InertialSenseSDK)
file(GLOB SOURCES_SDK
"src/*.c"
"src/*.cpp"
"src/*.h"
"src/protocol/*.cpp"
"src/protocol/*.h"
"src/util/*.cpp"
"src/util/*.h"
"hw-libs/bootloader/bootloaderShared.c"
"tests/runtime/*.cpp"
"tests/runtime/*.h"
"src/yaml-cpp/*.cpp"
"src/yaml-cpp/*.h"
"src/yaml-cpp/contrib/*.cpp"
"src/yaml-cpp/contrib/*.h"
"src/yaml-cpp/node/*.cpp"
"src/yaml-cpp/node/*.h"
)
# Compile libusb from source
if(WIN32)
file(GLOB SOURCES_LIB_USB
"src/libusb/libusb/*.h"
"src/libusb/libusb/*.c"
"src/libusb/libusb/os/*windows*"
)
else()
file(GLOB SOURCES_LIB_USB
"src/libusb/libusb/*.h"
"src/libusb/libusb/*.c"
"src/libusb/libusb/os/*linux*"
"src/libusb/libusb/os/*posix*"
)
endif()
# Ignore bootloader files
# list(FILTER SOURCES_SDK EXCLUDE REGEX "ISBootloader.*")
list(FILTER SOURCES_SDK EXCLUDE REGEX "ISBootloaderSony.*")
list(FILTER SOURCES_SDK EXCLUDE REGEX "ISBootloaderSTM32.*")
list(APPEND SOURCES_SDK ${SOURCES_LIB_USB})
# find_package(udev)
find_library( UDEV_LIB udev )
add_library(${PROJECT_NAME} STATIC ${SOURCES_SDK})
# Include paths
target_include_directories(${PROJECT_NAME} PUBLIC
src
src/util
src/protocol
src/libusb
src/libusb/libusb
src/yaml-cpp
tests/runtime
external
)
# Build using C11 and CXX20
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
# Other settings
if(WIN32)
# yamlcpp needs to know it's a static lib
add_definitions(-DYAML_CPP_STATIC_DEFINE)
# Windows specific include dir
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/libusb/msvc
)
# We need to ensure windows static libs are found
target_link_libraries(${PROJECT_NAME} Ws2_32.lib)
else()
# Linux specific include dir
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/libusb/linux
)
# Linux compiler flags
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-missing-field-initializers")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-missing-field-initializers")
# Set Linux compiler linker flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
# Link in Linux specific packages
target_link_libraries(${PROJECT_NAME} udev m)
endif()