This repository was archived by the owner on Jun 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
143 lines (128 loc) · 4.94 KB
/
Copy pathCMakeLists.txt
File metadata and controls
143 lines (128 loc) · 4.94 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
# ____ _ _
# | _ \| |_ _ __ _(_)_ __
# | |_) | | | | |/ _` | | '_ \
# | __/| | |_| | (_| | | | | |
# |_| |_|\__,_|\__, |_|_| |_|
# |___/
# A Template for SourcePlugin, a Source Plugin
# Generated by the command: plugin source -d replay_plugin replay
# Hostname: Fram-IV.local
# Current working directory: /Users/p4010/Develop/MADS_plugins
# Creation date: 2025-09-05T16:04:08.433+0200
# NOTICE: MADS Version 1.3.5
cmake_minimum_required(VERSION 3.28)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
project(source VERSION 1.3.5 LANGUAGES CXX)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/Users/p4010/usr/local/lib" 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 17)
set(CMAKE_CXX_STANDARD_REQUIRED 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(replay
GIT_REPOSITORY https://github.com/pbosetti/replay.git
GIT_TAG HEAD
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(pugg json replay)
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
${replay_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})
set_target_properties(${name}_main PROPERTIES OUTPUT_NAME ${name})
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(replay)
# INSTALL ######################################################################
if(APPLE)
install(TARGETS ${TARGET_LIST}
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
ARCHIVE DESTINATION lib
)
else()
install(TARGETS ${TARGET_LIST}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
)
endif()