-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
183 lines (164 loc) · 6.67 KB
/
Copy pathCMakeLists.txt
File metadata and controls
183 lines (164 loc) · 6.67 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# ____ _ _
# | _ \| |_ _ __ _(_)_ __
# | |_) | | | | |/ _` | | '_ \
# | __/| | |_| | (_| | | | | |
# |_| |_|\__,_|\__, |_|_| |_|
# |___/
# A Template for MachinetoolPlugin, a Sink Plugin
# Generated by the command: plugin -t sink machinetool -d mt_plugin
# Hostname: Fram-IV.local
# Current working directory: /Users/p4010/Develop/MADS_plugins
# Creation date: 2026-03-05T19:28:13.964+0100
# NOTICE: MADS Version 2.0.0
cmake_minimum_required(VERSION 3.28)
# Match the prebuilt rerun_c library's deployment target to suppress
# "was built for newer macOS version" linker warnings.
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "26.2" CACHE STRING "Minimum macOS deployment target")
endif()
project(machinetool VERSION 2.0.0 LANGUAGES CXX)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/Users/p4010/usr/local" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
set(PLUGIN_SUFFIX "" CACHE STRING "Suffix for the plugin file, identifying the architecture, e.g. arm64, x86_64, etc.")
if(PLUGIN_SUFFIX STREQUAL "")
message(WARNING "No PLUGIN_SUFFIX set, using default plugin name. In multi-platform environment with OTA plugins it is advised to set PLUGIN_SUFFIX to the architecture, e.g. arm64, x86_64, etc.")
else()
message(STATUS "PLUGIN_SUFFIX set to: ${PLUGIN_SUFFIX}")
endif()
# PROJECT SETTINGS #############################################################
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
add_compile_options(-fPIC)
endif()
# DEPENDENCIES #################################################################
include(FetchContent)
# pugg is for the plugin system
FetchContent_Declare(pugg
GIT_REPOSITORY https://github.com/pbosetti/pugg.git
GIT_TAG 1.0.2
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
)
set(BUILD_TESTING OFF CACHE INTERNAL "")
set(JSON_BuildTests OFF CACHE INTERNAL "")
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
)
FetchContent_Declare(rerun_cpp_sdk
URL https://github.com/rerun-io/rerun/releases/download/0.31.4/rerun_cpp_sdk.zip
EXCLUDE_FROM_ALL
# Arrow (a rerun dependency) is downloaded as a tarball, so "git apply" in
# rerun's own PATCH_COMMAND always fails silently. We replace it with a
# cmake -P script that applies the same fixes without needing git history.
# See patches/patch_arrow_cmake4.cmake for details.
PATCH_COMMAND ${CMAKE_COMMAND}
-DPATCHES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/patches
-P ${CMAKE_CURRENT_SOURCE_DIR}/patches/patch_rerun_sdk.cmake
)
# rerun_cpp tests call this helper when building standalone; define a no-op fallback.
if(NOT COMMAND rerun_strict_warning_settings)
function(rerun_strict_warning_settings)
endfunction()
endif()
# rerun_cpp tests reference loguru::loguru even when tests are not built by us.
if(NOT TARGET loguru::loguru)
add_library(loguru::loguru INTERFACE IMPORTED GLOBAL)
endif()
FetchContent_MakeAvailable(pugg json rerun_cpp_sdk)
FetchContent_Populate(plugin
GIT_REPOSITORY https://github.com/pbosetti/mads_plugin.git
GIT_TAG v2.0-P7
GIT_SHALLOW TRUE
SUBBUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/plugin-subbuild
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/plugin-src
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/plugin-build
)
include_directories(${plugin_SOURCE_DIR}/src)
# MACROS #######################################################################
# Call: add_plugin(name [SRCS src1 src2 ...] [LIBS lib1 lib2 ...])
# the source file ${SRC_DIR}/plugin/<name>.cpp is implicitly added
macro(add_plugin name)
# on MacOS only, plugins can be compiled as executables
set(multiValueArgs LIBS SRCS)
cmake_parse_arguments(plugin "" "" "${multiValueArgs}" ${ARGN})
if (APPLE)
add_executable(${name} ${SRC_DIR}/${name}.cpp ${plugin_SRCS})
set_target_properties(${name} PROPERTIES ENABLE_EXPORTS TRUE)
set(${name}_EXEC ${name}.plugin)
else()
add_library(${name} SHARED ${SRC_DIR}/${name}.cpp ${plugin_SRCS})
add_executable(${name}_main ${SRC_DIR}/${name}.cpp ${plugin_SRCS})
target_link_libraries(${name}_main PRIVATE pugg ${plugin_LIBS})
if(WIN32)
set_target_properties(${name}_main PROPERTIES
OUTPUT_NAME ${name}
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/exe"
PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/exe")
else()
set_target_properties(${name}_main PROPERTIES OUTPUT_NAME ${name})
endif()
set(${name}_EXEC ${name})
list(APPEND TARGET_LIST ${name}_main)
endif()
target_link_libraries(${name} PRIVATE pugg ${plugin_LIBS})
set_target_properties(${name} PROPERTIES PREFIX "")
if (PLUGIN_SUFFIX)
set_target_properties(${name} PROPERTIES SUFFIX "_${PLUGIN_SUFFIX}.plugin")
target_compile_definitions(${name} PRIVATE PLUGIN_NAME="${name}_${PLUGIN_SUFFIX}")
else()
set_target_properties(${name} PROPERTIES SUFFIX ".plugin")
target_compile_definitions(${name} PRIVATE PLUGIN_NAME="${name}")
endif()
list(APPEND TARGET_LIST ${name})
endmacro()
# BUILD SETTINGS ###############################################################
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
include_directories(/opt/homebrew/include)
link_directories(/opt/homebrew/lib)
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib;/usr/local/lib")
endif()
include_directories(${json_SOURCE_DIR}/include)
# These plugins are always build and use for testing
add_plugin(machinetool SRCS ${SRC_DIR}/machine_viewer.cpp LIBS rerun_sdk)
add_executable(machine_viewer_example
${SRC_DIR}/machine_viewer_example.cpp
${SRC_DIR}/machine_viewer.cpp
)
target_link_libraries(machine_viewer_example PRIVATE rerun_sdk)
# INSTALL ######################################################################
if(APPLE)
install(TARGETS ${TARGET_LIST}
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT MadsApps
)
else()
install(TARGETS ${TARGET_LIST}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
COMPONENT MadsApps
)
endif()
# machine_viewer_example is a standalone executable, always installed to bin/
# install(TARGETS machine_viewer_example
# RUNTIME DESTINATION bin
# COMPONENT MadsApps
# )