This repository was archived by the owner on Feb 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
82 lines (68 loc) · 2.41 KB
/
CMakeLists.txt
File metadata and controls
82 lines (68 loc) · 2.41 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
cmake_minimum_required(VERSION 3.16)
project("mip_packet_example_cpp"
VERSION "1.0.0"
DESCRIPTION "Simple example for creating MIP packets using C++"
LANGUAGES C CXX
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# TODO: Set MIP_SDK_ROOT_DIR if building as a standalone project
if(DEFINED MIP_SDK_ROOT_DIR OR DEFINED CACHE{MIP_SDK_ROOT_DIR})
set(_MIP_SDK_ROOT_DIR "${MIP_SDK_ROOT_DIR}")
elseif(DEFINED ENV{MIP_SDK_ROOT_DIR})
set(_MIP_SDK_ROOT_DIR "$ENV{MIP_SDK_ROOT_DIR}")
else()
set(_MIP_SDK_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
# We need to find MicroStrain and MIP SDK in a standalone project
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
list(APPEND CMAKE_PREFIX_PATH "${_MIP_SDK_ROOT_DIR}")
find_package(mip REQUIRED CONFIG)
find_package(microstrain REQUIRED CONFIG)
endif()
# Make sure the MIP libraries are found
if(NOT DEFINED CACHE{MIP_LIBRARIES} AND NOT DEFINED MIP_LIBRARIES)
message(FATAL_ERROR "Could not find the required MIP libraries.")
endif()
# Make sure the MicroStrain libraries are found
if(NOT DEFINED CACHE{MICROSTRAIN_LIBRARIES} AND NOT DEFINED MICROSTRAIN_LIBRARIES)
message(FATAL_ERROR "Could not find the required MicroStrain libraries.")
endif()
# Create the example
add_executable(${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/mip_packet_example.cpp"
)
# Configure the project in a sub-folder for IDEs that support it
if(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
file(RELATIVE_PATH PROJECT_RELATIVE_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/..")
set_target_properties(${PROJECT_NAME} PROPERTIES
FOLDER "${PROJECT_RELATIVE_PATH}"
)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE
${MIP_LIBRARIES}
${MICROSTRAIN_LIBRARIES}
)
target_include_directories(${PROJECT_NAME} PRIVATE
${MIP_INCLUDE_DIRS}
${MICROSTRAIN_INCLUDE_DIRS}
)
if(MSVC)
set(COMPILE_OPTIONS
"/W4" # Enable warnings
"/WX" # Warnings as errors
"/Zc:__cplusplus" # Enable updated __cplusplus value
"/MP" # Multi-process compilation
)
else()
set(COMPILE_OPTIONS
"-Wall" # Enable warnings
"-Wextra" # Enable extra warnings
"-Werror" # Warnings as errors
)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE
"${COMPILE_OPTIONS}"
)